Skip to content

Commit f363467

Browse files
authored
Merge pull request #254 from TaskarCenterAtUW/fix-user-profile-text
Fix user full name
2 parents b67ac0d + b7740b2 commit f363467

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

GoInfoGame/GoInfoGame/UserProfile/Model/UserProfile.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ import Foundation
1515
// MARK: - UserProfileResponse
1616
struct TdeiUserProfile: Codable {
1717
let id, firstName, lastName, email: String?
18+
19+
func getFullName()-> String {
20+
var fullName: String = ""
21+
if let firstName = firstName {
22+
fullName += firstName
23+
}
24+
25+
if let lastName = lastName {
26+
if !fullName.isEmpty {
27+
fullName += " "
28+
}
29+
fullName += lastName
30+
}
31+
return fullName
32+
}
1833
}
1934

2035

GoInfoGame/GoInfoGame/UserProfile/View/UserProfileView.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ struct UserProfileView: View {
4545
}
4646

4747
private func userFullName() -> String {
48-
var fullName = ""
49-
if let firstName = viewModel.user?.firstName, let lastNane = viewModel.user?.lastName {
50-
fullName = firstName + " " + lastNane
48+
if let userModel = viewModel.user {
49+
return userModel.getFullName()
5150
}
52-
return fullName
51+
return ""
5352

5453
}
5554

0 commit comments

Comments
 (0)