Skip to content

Commit

Permalink
Accessibility UI fixes (#1685)
Browse files Browse the repository at this point in the history
* Fix accessibiliity in room attachment picker

* Fix FormattingToolbar accessibility

* Cleanup

* Fix ui tests
  • Loading branch information
alfogrillo authored Sep 12, 2023
1 parent 27408fe commit dc5514b
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 16 additions & 11 deletions ElementX/Sources/Screens/ComposerToolbar/View/ComposerToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dc5514b

Please sign in to comment.