mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
improved a11y in CollapsibleRoomTimelineView
This commit is contained in:
@@ -522,7 +522,7 @@ internal enum L10n {
|
||||
internal static var commonRecoveryKey: String { return L10n.tr("Localizable", "common_recovery_key") }
|
||||
/// Refreshing…
|
||||
internal static var commonRefreshing: String { return L10n.tr("Localizable", "common_refreshing") }
|
||||
/// %1$d replies
|
||||
/// Plural format key: "%#@COUNT@"
|
||||
internal static func commonReplies(_ p1: Int) -> String {
|
||||
return L10n.tr("Localizable", "common_replies", p1)
|
||||
}
|
||||
@@ -2182,6 +2182,10 @@ internal enum L10n {
|
||||
internal static func screenRoomEventPill(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "screen_room_event_pill", String(describing: p1))
|
||||
}
|
||||
/// Expand
|
||||
internal static var screenRoomGroupedViewStatesExpand: String { return L10n.tr("Localizable", "screen_room_grouped_view_states_expand") }
|
||||
/// Reduce
|
||||
internal static var screenRoomGroupedViewStatesReduce: String { return L10n.tr("Localizable", "screen_room_grouped_view_states_reduce") }
|
||||
/// Would you like to invite them back?
|
||||
internal static var screenRoomInviteAgainAlertMessage: String { return L10n.tr("Localizable", "screen_room_invite_again_alert_message") }
|
||||
/// You are alone in this chat
|
||||
|
||||
+22
-3
@@ -8,10 +8,16 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CollapsibleRoomTimelineView: View {
|
||||
enum AccessibilityFocus {
|
||||
case disclosure
|
||||
case events
|
||||
}
|
||||
|
||||
private let timelineItem: CollapsibleTimelineItem
|
||||
private let groupedViewStates: [RoomTimelineItemViewState]
|
||||
|
||||
@State private var isExpanded = false
|
||||
@AccessibilityFocusState private var accessibilityFocusState: AccessibilityFocus?
|
||||
|
||||
init(timelineItem: CollapsibleTimelineItem) {
|
||||
self.timelineItem = timelineItem
|
||||
@@ -21,13 +27,18 @@ struct CollapsibleRoomTimelineView: View {
|
||||
var body: some View {
|
||||
VStack(spacing: 0.0) {
|
||||
Button {
|
||||
withElementAnimation {
|
||||
if !UIAccessibility.isVoiceOverRunning {
|
||||
withElementAnimation {
|
||||
isExpanded.toggle()
|
||||
}
|
||||
} else {
|
||||
isExpanded.toggle()
|
||||
}
|
||||
} label: {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
Text(L10n.screenRoomTimelineStateChanges(timelineItem.items.count))
|
||||
Text(Image(systemName: "chevron.forward"))
|
||||
.accessibilityLabel(isExpanded ? L10n.screenRoomGroupedViewStatesReduce : L10n.screenRoomGroupedViewStatesExpand)
|
||||
.rotationEffect(.degrees(isExpanded ? 90 : 0))
|
||||
.animation(.elementDefault, value: isExpanded)
|
||||
}
|
||||
@@ -40,13 +51,21 @@ struct CollapsibleRoomTimelineView: View {
|
||||
.buttonStyle(.plain)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 8.0)
|
||||
.accessibilityFocused($accessibilityFocusState, equals: .disclosure)
|
||||
|
||||
if isExpanded {
|
||||
ForEach(groupedViewStates) { viewState in
|
||||
RoomTimelineItemView(viewState: viewState)
|
||||
VStack(spacing: 0.0) {
|
||||
ForEach(groupedViewStates) { viewState in
|
||||
RoomTimelineItemView(viewState: viewState)
|
||||
}
|
||||
}
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityFocused($accessibilityFocusState, equals: .events)
|
||||
}
|
||||
}
|
||||
.onChange(of: isExpanded) { _, newValue in
|
||||
accessibilityFocusState = newValue ? .events : .disclosure
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user