Accessibility UI fixes (#1685)

* Fix accessibiliity in room attachment picker

* Fix FormattingToolbar accessibility

* Cleanup

* Fix ui tests
This commit is contained in:
Alfonso Grillo 2023-09-12 12:46:56 +02:00 committed by GitHub
parent 27408fe818
commit dc5514bc0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 46 additions and 30 deletions

View File

@ -17,7 +17,11 @@
import SwiftUI
struct FixedIconSizeLabelStyle: LabelStyle {
@ScaledMetric private var iconSize = 24.0
@ScaledMetric private var iconSize: CGFloat
init(iconSize: Double = 24.0) {
_iconSize = .init(wrappedValue: iconSize)
}
var spacing: CGFloat = 16

View File

@ -54,24 +54,29 @@ struct ComposerToolbar: View {
}
private var bottomBar: some View {
HStack(alignment: .bottom, spacing: 10) {
Button {
context.composerActionsEnabled = false
context.composerExpanded = false
} label: {
Image(systemName: "xmark.circle.fill")
.font(.compound.headingLG)
.foregroundColor(.compound.textActionPrimary)
}
.accessibilityIdentifier(A11yIdentifiers.roomScreen.composerToolbar.closeFormattingOptions)
.padding(.bottom, 5) // centre align with the send button
HStack(alignment: .center, spacing: 10) {
closeRTEButton
FormattingToolbar(formatItems: context.formatItems) { action in
context.send(viewAction: .composerAction(action: action.composerAction))
}
sendButton
}
}
private var closeRTEButton: some View {
Button {
context.composerActionsEnabled = false
context.composerExpanded = false
} label: {
Image(systemName: "xmark.circle.fill")
.font(.compound.headingLG)
.foregroundColor(.compound.textActionPrimary)
}
.accessibilityIdentifier(A11yIdentifiers.roomScreen.composerToolbar.closeFormattingOptions)
}
private var sendButton: some View {
Button {
context.send(viewAction: .sendMessage)

View File

@ -22,6 +22,8 @@ struct FormattingToolbar: View {
/// The action when an item is selected
var formatAction: (FormatType) -> Void
@ScaledMetric private var toolbarButtonIconSize = 24
var body: some View {
ScrollView(.horizontal) {
HStack(spacing: 4) {
@ -31,10 +33,13 @@ struct FormattingToolbar: View {
} label: {
item.icon
.renderingMode(.template)
.resizable()
.scaledToFit()
.frame(width: toolbarButtonIconSize, height: toolbarButtonIconSize)
.foregroundColor(item.foregroundColor)
.padding(10)
}
.disabled(item.state == .disabled)
.frame(width: 44, height: 44)
.background(item.backgroundColor)
.cornerRadius(8)
.accessibilityIdentifier(item.accessibilityIdentifier)

View File

@ -115,8 +115,10 @@ struct RoomAttachmentPicker: View {
Text(title)
} icon: {
icon
.resizable()
.scaledToFit()
}
.labelStyle(FixedIconSizeLabelStyle())
.labelStyle(FixedIconSizeLabelStyle(iconSize: 20))
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(16)