Make sure the inviter's avatar is hidden in the JoinRoomScreen. (#5151)
* Make sure the inviter's avatar is hidden in the JoinRoomScreen. * Update preview tests to use an inviter that has an avatar… * Also hide avatars in the Space invite avatar pile.
This commit is contained in:
@@ -11,6 +11,7 @@ import SwiftUI
|
||||
|
||||
struct JoinedMembersBadgeView: View {
|
||||
let heroes: [UserProfileProxy]
|
||||
var shouldHideAvatars = false
|
||||
let joinedCount: Int
|
||||
|
||||
let mediaProvider: MediaProviderProtocol?
|
||||
@@ -43,7 +44,7 @@ struct JoinedMembersBadgeView: View {
|
||||
var heroesFacePile: some View {
|
||||
HStack(spacing: -8) {
|
||||
ForEach(heroes.prefix(3).reversed()) { hero in
|
||||
LoadableAvatarImage(url: hero.avatarURL,
|
||||
LoadableAvatarImage(url: shouldHideAvatars ? nil : hero.avatarURL,
|
||||
name: hero.displayName,
|
||||
contentID: hero.userID,
|
||||
avatarSize: .user(on: .spaceHeader),
|
||||
|
||||
@@ -87,6 +87,7 @@ struct JoinRoomScreen: View {
|
||||
|
||||
if !context.viewState.isDMInvite, let memberCount = context.viewState.roomDetails?.memberCount {
|
||||
JoinedMembersBadgeView(heroes: context.viewState.roomDetails?.heroes ?? [],
|
||||
shouldHideAvatars: context.viewState.shouldHideAvatars,
|
||||
joinedCount: memberCount,
|
||||
mediaProvider: context.mediaProvider)
|
||||
}
|
||||
@@ -101,35 +102,10 @@ struct JoinRoomScreen: View {
|
||||
}
|
||||
|
||||
if let inviter = context.viewState.roomDetails?.inviter {
|
||||
VStack(spacing: 8) {
|
||||
Text(L10n.screenJoinRoomInvitedBy)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
LoadableAvatarImage(url: inviter.avatarURL,
|
||||
name: inviter.displayName,
|
||||
contentID: inviter.id,
|
||||
avatarSize: .custom(52),
|
||||
mediaProvider: context.mediaProvider)
|
||||
.accessibilityHidden(true)
|
||||
|
||||
VStack(spacing: 4) {
|
||||
if let displayName = inviter.displayName {
|
||||
Text(displayName)
|
||||
.font(.compound.bodyLGSemibold)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
|
||||
Text(inviter.id)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
.accessibilityElement(children: .combine)
|
||||
.padding(.top, 16)
|
||||
InviterView(inviter: inviter,
|
||||
shouldHideAvatar: context.viewState.shouldHideAvatars,
|
||||
mediaProvider: context.mediaProvider)
|
||||
.padding(.top, 16)
|
||||
}
|
||||
|
||||
if context.viewState.mode == .knockable {
|
||||
@@ -326,6 +302,44 @@ struct JoinRoomScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
private struct InviterView: View {
|
||||
let inviter: RoomInviterDetails
|
||||
let shouldHideAvatar: Bool
|
||||
|
||||
let mediaProvider: MediaProviderProtocol?
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 8) {
|
||||
Text(L10n.screenJoinRoomInvitedBy)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
LoadableAvatarImage(url: shouldHideAvatar ? nil : inviter.avatarURL,
|
||||
name: inviter.displayName,
|
||||
contentID: inviter.id,
|
||||
avatarSize: .custom(52),
|
||||
mediaProvider: mediaProvider)
|
||||
.accessibilityHidden(true)
|
||||
|
||||
VStack(spacing: 4) {
|
||||
if let displayName = inviter.displayName {
|
||||
Text(displayName)
|
||||
.font(.compound.bodyLGSemibold)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
|
||||
Text(inviter.id)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
.accessibilityElement(children: .combine)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct JoinRoomScreen_Previews: PreviewProvider, TestablePreview {
|
||||
@@ -409,16 +423,9 @@ struct JoinRoomScreenPreviewWrapper: Identifiable {
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.inviteRequired)
|
||||
clientProxy.roomForIdentifierReturnValue = nil
|
||||
case .invited(let isDM):
|
||||
if isDM {
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.inviteDM())
|
||||
clientProxy.roomForIdentifierClosure = { _ in
|
||||
.invited(InvitedRoomProxyMock(.init(avatarURL: .mockMXCAvatar)))
|
||||
}
|
||||
} else {
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.invited())
|
||||
clientProxy.roomForIdentifierClosure = { _ in
|
||||
.invited(InvitedRoomProxyMock(.init(avatarURL: .mockMXCAvatar)))
|
||||
}
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(isDM ? RoomPreviewProxyMock.inviteDM() : .invited())
|
||||
clientProxy.roomForIdentifierClosure = { _ in
|
||||
.invited(InvitedRoomProxyMock(.init(avatarURL: .mockMXCAvatar, inviter: .mockDan)))
|
||||
}
|
||||
case .knockable:
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.knockable)
|
||||
|
||||
Reference in New Issue
Block a user