Skip to content

Commit

Permalink
Merge pull request #24 from tchapgouv/23-personnalisation-du-nom-de-l…
Browse files Browse the repository at this point in the history
…utilisateur-step-2

Personnalisation du nom de l’utilisateur (suite)
  • Loading branch information
NicolasBuquet authored Nov 12, 2024
2 parents 8579ca5 + 29dfeff commit b0b1928
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 41 deletions.
3 changes: 3 additions & 0 deletions ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,16 @@ struct AvatarHeaderView<Footer: View>: View {
.multilineTextAlignment(.center)
.textSelection(.enabled)

// Tchap: only display User ID or Room canonical alias in room info when in debug mode.
#if DEBUG
if let subtitle {
Text(subtitle)
.foregroundColor(.compound.textSecondary)
.font(.compound.bodyLG)
.multilineTextAlignment(.center)
.textSelection(.enabled)
}
#endif

if !badges.isEmpty {
badgesStack
Expand Down
7 changes: 7 additions & 0 deletions ElementX/Sources/Other/SwiftUI/Views/RoomInviterLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ struct RoomInviterDetails: Equatable {

// Pre-compute the attributed string.
let placeholder = "{displayname}"
// Tchap: only display User ID of Inviter when in debug mode
#if DEBUG
var string = AttributedString(L10n.screenInvitesInvitedYou(placeholder, id))
#else
var string = AttributedString(L10n.screenInvitesInvitedYou(placeholder, ""))
// Tchap: the template string contains mandatory " (%2$@)" placeholder. Suppress it.
string.replace(" ()", with: "")
#endif
var displayNameString = AttributedString(nameOrLocalPart)
displayNameString.bold()
displayNameString.foregroundColor = .compound.textPrimary
Expand Down
5 changes: 5 additions & 0 deletions ElementX/Sources/Other/SwiftUI/Views/UserProfileListRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ struct UserProfileListRow: View {
if let membershipText = membership?.localizedDescription {
return membershipText
} else if user.displayName != nil {
// Tchap: only display matrixID in debug mode.
#if DEBUG
return user.userID
#else
return nil
#endif
} else {
return nil
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ struct BlockedUsersScreen: View {
} else {
Form {
ForEach(context.viewState.blockedUsers, id: \.self) { user in
ListRow(label: .avatar(title: user.displayName ?? user.userID, icon: avatar(for: user)),
// Tchap: calculate displayname from userId if necessary.
// ListRow(label: .avatar(title: user.displayName ?? user.userID, icon: avatar(for: user)),
// details: .isWaiting(context.viewState.processingUserID == user.userID),
// kind: .button(action: { context.send(viewAction: .unblockUser(user)) }))
ListRow(label: .avatar(title: user.displayName ?? MatrixIdFromString(user.userID).userDisplayName?.displayName ?? user.userID, icon: avatar(for: user)),
details: .isWaiting(context.viewState.processingUserID == user.userID),
kind: .button(action: { context.send(viewAction: .unblockUser(user)) }))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ struct HomeScreenInviteCell: View {
.foregroundColor(.compound.textPrimary)
.lineLimit(2)

// Tchap: only display User ID in Invite list when in debug mode
#if DEBUG
if let subtitle {
Text(subtitle)
.font(.compound.bodyMD)
.foregroundColor(.compound.textPlaceholder)
}
#endif
}
.frame(maxWidth: .infinity, alignment: .leading)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ struct InviteUsersScreenSelectedItem: View {
VStack(spacing: 0) {
avatar

Text(user.displayName ?? user.userID)
// Tchap: calculate displayname from userId if necessary.
// Text(user.displayName ?? user.userID)
Text((user.displayName ?? MatrixIdFromString(user.userID).userDisplayName?.displayName) ?? user.userID)
.font(.compound.bodyMD)
.foregroundColor(.compound.textPrimary)
.lineLimit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ struct RoomChangeRolesScreenRow: View {
let action: () -> Void

var body: some View {
// Tchap: only display User ID of Inviter when in debug mode
#if DEBUG
ListRow(label: .avatar(title: member.name ?? member.id,
status: member.isInvited ? L10n.screenRoomMemberListPendingHeaderTitle : nil,
description: member.name == nil ? nil : member.id,
icon: avatar),
kind: .multiSelection(isSelected: isSelected, action: action))
#else
ListRow(label: .avatar(title: member.name ?? member.id,
status: member.isInvited ? L10n.screenRoomMemberListPendingHeaderTitle : nil,
description: nil,
icon: avatar),
kind: .multiSelection(isSelected: isSelected, action: action))
#endif
}

var avatar: LoadableAvatarImage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ struct RoomMembersListScreenMemberCell: View {
.foregroundColor(.compound.textPrimary)
.lineLimit(1)

// Tchap: only display matrixID in debug mode
#if DEBUG
if let subtitle {
Text(subtitle)
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
.lineLimit(1)
}
#endif
}
.frame(maxWidth: .infinity, alignment: .leading)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ struct MentionSuggestionItemView: View {
.font(.compound.bodyLG)
.foregroundColor(.compound.textPrimary)
.lineLimit(1)
// Tchap: only display User ID in Mention list when in debug mode.
#if DEBUG
if item.displayName != nil {
Text(item.id)
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
.lineLimit(1)
}
#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ struct SettingsScreen: View {
Text(context.viewState.userDisplayName ?? "")
.font(.compound.headingMD)
.foregroundColor(.compound.textPrimary)
// Tchap: only display User ID of Settings when in debug mode
#if DEBUG
Text(context.viewState.userID)
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
#endif
}

Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ struct UserDetailsEditScreen: View {
Section {
avatar
} footer: {
// Tchap: only display User ID of Edit Profile when in debug mode
#if DEBUG
Text(context.viewState.userID)
.frame(maxWidth: .infinity)
.font(.compound.bodyLG)
.foregroundColor(.compound.textPrimary)
.padding(.bottom, 16)
#endif
}

nameSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ struct ReadReceiptCell: View {
.lineLimit(1)
}
}
// Tchap: only display User ID in "Seen by"" list when in debug mode.
#if DEBUG
Text(subtitle)
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
.lineLimit(1)
#endif
}
}
.padding(.vertical, 8)
Expand Down

0 comments on commit b0b1928

Please sign in to comment.