diff --git a/ElementX/Resources/Localizations/en.lproj/Localizable.strings b/ElementX/Resources/Localizations/en.lproj/Localizable.strings index 858a60cc0..25ebc0e93 100644 --- a/ElementX/Resources/Localizations/en.lproj/Localizable.strings +++ b/ElementX/Resources/Localizations/en.lproj/Localizable.strings @@ -25,6 +25,7 @@ "a11y_show_password" = "Show password"; "a11y_start_call" = "Start a call"; "a11y_user_menu" = "User menu"; +"a11y_view_avatar" = "View avatar"; "a11y_view_details" = "View details"; "a11y_voice_message" = "Voice message, duration: %1$@"; "a11y_voice_message_record" = "Record voice message."; diff --git a/ElementX/Sources/Generated/Strings.swift b/ElementX/Sources/Generated/Strings.swift index 1b9080ae4..96dc68665 100644 --- a/ElementX/Sources/Generated/Strings.swift +++ b/ElementX/Sources/Generated/Strings.swift @@ -92,6 +92,8 @@ internal enum L10n { internal static var a11yStartCall: String { return L10n.tr("Localizable", "a11y_start_call") } /// User menu internal static var a11yUserMenu: String { return L10n.tr("Localizable", "a11y_user_menu") } + /// View avatar + internal static var a11yViewAvatar: String { return L10n.tr("Localizable", "a11y_view_avatar") } /// View details internal static var a11yViewDetails: String { return L10n.tr("Localizable", "a11y_view_details") } /// Voice message, duration: %1$@ diff --git a/ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift b/ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift index 1145f8701..4eee1b71e 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift @@ -152,6 +152,18 @@ struct AvatarHeaderView: View { } } + private var avatarAccessibilityLabel: String { + guard onAvatarTap != nil else { + return L10n.a11yAvatar + } + switch avatarInfo { + case .room(let roomAvatar): + return roomAvatar.hasURL ? L10n.a11yViewAvatar : L10n.a11yAvatar + case .user(let userProfileProxy): + return userProfileProxy.avatarURL != nil ? L10n.a11yViewAvatar : L10n.a11yAvatar + } + } + @ViewBuilder private var avatar: some View { switch avatarInfo { @@ -160,7 +172,7 @@ struct AvatarHeaderView: View { avatarSize: avatarSize, mediaProvider: mediaProvider, onAvatarTap: onAvatarTap) - .accessibilityLabel(L10n.a11yAvatar) + .accessibilityLabel(avatarAccessibilityLabel) case .user(let userProfile): LoadableAvatarImage(url: userProfile.avatarURL, @@ -169,7 +181,7 @@ struct AvatarHeaderView: View { avatarSize: avatarSize, mediaProvider: mediaProvider, onTap: onAvatarTap) - .accessibilityLabel(L10n.a11yAvatar) + .accessibilityLabel(avatarAccessibilityLabel) } } diff --git a/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift b/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift index ef23fc68d..854a713d3 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift @@ -26,6 +26,17 @@ enum RoomAvatar: Equatable { .tombstoned } } + + var hasURL: Bool { + switch self { + case let .room(_, _, url): + return url != nil + case let .heroes(heroes): + return heroes.first?.avatarURL != nil + case .tombstoned: + return false + } + } } /// A view that shows the avatar for a room, or a cluster of heroes if provided.