Timeline VoiceOver Improvements (#241)

* status row view voiceover updates

* formatting?
This commit is contained in:
richkolasa 2023-01-22 00:35:13 -05:00 committed by GitHub
parent 781b09c539
commit d9307748ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,10 +67,31 @@ public struct StatusRowView: View {
viewModel.displaySpoiler = false viewModel.displaySpoiler = false
} }
} }
.contextMenu { .contextMenu {
StatusRowContextMenu(viewModel: viewModel) StatusRowContextMenu(viewModel: viewModel)
} }
.background { .accessibilityElement(children: viewModel.isFocused ? .contain : .combine)
.accessibilityActions {
// Add the individual mentions as accessibility actions
ForEach(viewModel.status.mentions, id: \.id) { mention in
Button("@\(mention.username)") {
routerPath.navigate(to: .accountDetail(id: mention.id))
}
}
Button(viewModel.displaySpoiler ? "status.show-more" : "status.show-less") {
withAnimation {
viewModel.displaySpoiler.toggle()
}
}
Button("@\(viewModel.status.account.username)") {
routerPath.navigate(to: .accountDetail(id: viewModel.status.account.id))
}
StatusRowContextMenu(viewModel: viewModel)
}
.background {
Color.clear Color.clear
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { .onTapGesture {
@ -104,9 +125,15 @@ public struct StatusRowView: View {
Text("status.row.was-boosted") Text("status.row.was-boosted")
} else { } else {
Text("status.row.you-boosted") Text("status.row.you-boosted")
} }
} }
.font(.scaledFootnote) .accessibilityElement()
.accessibilityLabel(
Text("\(viewModel.status.account.safeDisplayName)")
+ Text(" ")
+ Text(viewModel.status.account.username != account.account?.username ? "status.row.was-boosted" : "status.row.you-boosted")
)
.font(.scaledFootnote)
.foregroundColor(.gray) .foregroundColor(.gray)
.fontWeight(.semibold) .fontWeight(.semibold)
.onTapGesture { .onTapGesture {
@ -161,18 +188,26 @@ public struct StatusRowView: View {
} }
} label: { } label: {
accountView(status: status) accountView(status: status)
}.buttonStyle(.plain) }
.buttonStyle(.plain)
Spacer() Spacer()
menuButton menuButton
.accessibilityHidden(true)
} }
.accessibilityElement()
.accessibilityLabel(Text("\(status.account.displayName), \(status.createdAt.formatted)"))
} }
makeStatusContentView(status: status) makeStatusContentView(status: status)
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { .onTapGesture {
viewModel.navigateToDetail(routerPath: routerPath) viewModel.navigateToDetail(routerPath: routerPath)
} }
} }
} }
.accessibilityElement(children: viewModel.isFocused ? .contain : .combine)
.accessibilityAction {
viewModel.navigateToDetail(routerPath: routerPath)
}
} }
private func makeStatusContentView(status: AnyStatus) -> some View { private func makeStatusContentView(status: AnyStatus) -> some View {
@ -188,6 +223,7 @@ public struct StatusRowView: View {
Text(viewModel.displaySpoiler ? "status.show-more" : "status.show-less") Text(viewModel.displaySpoiler ? "status.show-more" : "status.show-less")
} }
.buttonStyle(.bordered) .buttonStyle(.bordered)
.accessibilityHidden(true)
} }
if !viewModel.displaySpoiler { if !viewModel.displaySpoiler {
@ -207,6 +243,7 @@ public struct StatusRowView: View {
} }
makeMediasView(status: status) makeMediasView(status: status)
.accessibilityHidden(!viewModel.isFocused)
makeCardView(status: status) makeCardView(status: status)
} }
} }