Skip to content

Commit

Permalink
Leaving only location on QE profile card details (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
pinarol authored Jan 27, 2025
2 parents 717ef11 + 2ddbddb commit 60da91e
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public enum PersonalInfoBuildingBlock {
}

extension String {
fileprivate func nilIfEmpty() -> String? {
func nilIfEmpty() -> String? {
isEmpty ? nil : self
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/GravatarUI/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
/* Placeholder text for the name field */
"AvatarPickerProfile.Name.placeholder" = "Your Name";

/* Placeholder text for some profile fields. */
"AvatarPickerProfile.ProfileFields.placeholder" = "Job, location, pronouns etc.";
/* Placeholder text for the profile card. Will show as subtitle bellow the name placeholder. */
"AvatarPickerProfile.ProfileFields.placeholder" = "Location";

/* This error message shows when the user attempts to change the alt text of an avatar and fails. */
"AvatarPickerViewModel.AltText.Error" = "Oops, something didn't quite work out while trying to update the alt text.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ struct AvatarPickerProfileView: View {
var displayName: String
var location: String
var profileURL: URL?
var pronunciation: String
var pronouns: String

var profileDetails: String? {
let joinedFields = [pronunciation, pronouns, location]
.filter { !$0.isEmpty }
.joined(separator: "")
return joinedFields.isEmpty ? nil : joinedFields
location.nilIfEmpty()
}
}

Expand Down Expand Up @@ -147,8 +142,8 @@ extension AvatarPickerProfileView {
)
static let profileDetailsPlaceholder = SDKLocalizedString(
"AvatarPickerProfile.ProfileFields.placeholder",
value: "Job, location, pronouns etc.",
comment: "Placeholder text for some profile fields."
value: "Location",
comment: "Placeholder text for the profile card. Will show as subtitle bellow the name placeholder."
)
}
}
Expand All @@ -163,9 +158,7 @@ extension AvatarPickerProfileView {
.init(
displayName: "Shelly Kimbrough",
location: "San Antonio, TX",
profileURL: URL(string: "https://gravatar.com"),
pronunciation: "SHEL-ee",
pronouns: "she/her"
profileURL: URL(string: "https://gravatar.com")
)
),
isLoading: .constant(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class AvatarPickerViewModel: ObservableObject {
profileModel = .init(
displayName: value.displayName,
location: value.location,
profileURL: value.profileURL,
pronunciation: value.pronunciation,
pronouns: value.pronouns
profileURL: value.profileURL
)
default:
profileModel = nil
Expand Down Expand Up @@ -100,9 +98,7 @@ class AvatarPickerViewModel: ObservableObject {
self.profileModel = .init(
displayName: profileModel.displayName,
location: profileModel.location,
profileURL: profileModel.profileURL,
pronunciation: profileModel.pronunciation,
pronouns: profileModel.pronouns
profileURL: profileModel.profileURL
)
switch profileModel.avatarIdentifier {
case .email(let email):
Expand Down
33 changes: 30 additions & 3 deletions Tests/GravatarUITests/AvatarPickerProfileViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,36 @@ final class AvatarPickerProfileViewTests: XCTestCase {
.init(
displayName: "Shelly Kimbrough",
location: "San Antonio, TX",
profileURL: URL(string: "https://gravatar.com"),
pronunciation: "SHEL-ee",
pronouns: "she/her"
profileURL: URL(string: "https://gravatar.com")
)
),
isLoading: .constant(false)
)
.frame(maxWidth: .infinity, alignment: .leading)
})
.frame(minWidth: Self.width)

assertSnapshots(
of: testView,
as: [
.testStrategy(userInterfaceStyle: .light, layout: .sizeThatFits),
.testStrategy(userInterfaceStyle: .dark, layout: .sizeThatFits),
]
)
}

@MainActor
func testAvatarPickerProfileViewWithoutLocation() throws {
let testView =
VStack(alignment: .leading, content: {
AvatarPickerProfileView(
avatarID: .constant(.email("")),
forceRefreshAvatar: .constant(false),
model: .constant(
.init(
displayName: "Shelly Kimbrough",
location: "",
profileURL: URL(string: "https://gravatar.com")
)
),
isLoading: .constant(false)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 60da91e

Please sign in to comment.