mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
add view avatar a11y label
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
"a11y_show_password" = "Show password";
|
"a11y_show_password" = "Show password";
|
||||||
"a11y_start_call" = "Start a call";
|
"a11y_start_call" = "Start a call";
|
||||||
"a11y_user_menu" = "User menu";
|
"a11y_user_menu" = "User menu";
|
||||||
|
"a11y_view_avatar" = "View avatar";
|
||||||
"a11y_view_details" = "View details";
|
"a11y_view_details" = "View details";
|
||||||
"a11y_voice_message" = "Voice message, duration: %1$@";
|
"a11y_voice_message" = "Voice message, duration: %1$@";
|
||||||
"a11y_voice_message_record" = "Record voice message.";
|
"a11y_voice_message_record" = "Record voice message.";
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ internal enum L10n {
|
|||||||
internal static var a11yStartCall: String { return L10n.tr("Localizable", "a11y_start_call") }
|
internal static var a11yStartCall: String { return L10n.tr("Localizable", "a11y_start_call") }
|
||||||
/// User menu
|
/// User menu
|
||||||
internal static var a11yUserMenu: String { return L10n.tr("Localizable", "a11y_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
|
/// View details
|
||||||
internal static var a11yViewDetails: String { return L10n.tr("Localizable", "a11y_view_details") }
|
internal static var a11yViewDetails: String { return L10n.tr("Localizable", "a11y_view_details") }
|
||||||
/// Voice message, duration: %1$@
|
/// Voice message, duration: %1$@
|
||||||
|
|||||||
@@ -152,6 +152,18 @@ struct AvatarHeaderView<Footer: View>: 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
|
@ViewBuilder
|
||||||
private var avatar: some View {
|
private var avatar: some View {
|
||||||
switch avatarInfo {
|
switch avatarInfo {
|
||||||
@@ -160,7 +172,7 @@ struct AvatarHeaderView<Footer: View>: View {
|
|||||||
avatarSize: avatarSize,
|
avatarSize: avatarSize,
|
||||||
mediaProvider: mediaProvider,
|
mediaProvider: mediaProvider,
|
||||||
onAvatarTap: onAvatarTap)
|
onAvatarTap: onAvatarTap)
|
||||||
.accessibilityLabel(L10n.a11yAvatar)
|
.accessibilityLabel(avatarAccessibilityLabel)
|
||||||
|
|
||||||
case .user(let userProfile):
|
case .user(let userProfile):
|
||||||
LoadableAvatarImage(url: userProfile.avatarURL,
|
LoadableAvatarImage(url: userProfile.avatarURL,
|
||||||
@@ -169,7 +181,7 @@ struct AvatarHeaderView<Footer: View>: View {
|
|||||||
avatarSize: avatarSize,
|
avatarSize: avatarSize,
|
||||||
mediaProvider: mediaProvider,
|
mediaProvider: mediaProvider,
|
||||||
onTap: onAvatarTap)
|
onTap: onAvatarTap)
|
||||||
.accessibilityLabel(L10n.a11yAvatar)
|
.accessibilityLabel(avatarAccessibilityLabel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,17 @@ enum RoomAvatar: Equatable {
|
|||||||
.tombstoned
|
.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.
|
/// A view that shows the avatar for a room, or a cluster of heroes if provided.
|
||||||
|
|||||||
Reference in New Issue
Block a user