Skip to content

Commit 7e8cd5c

Browse files
authored
Accessibility mark iii (#779)
1 parent 1ef9903 commit 7e8cd5c

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

Demo/Demo/Gravatar-Demo/DemoQuickEditorViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class DemoQuickEditorViewController: BaseFormViewController {
4848
)
4949

5050
lazy var initialPageButton = ButtonLabelField(
51-
title: "Initital Page",
51+
title: "Initial Page",
5252
subtitle: selectedInitialPage.rawValue,
5353
buttonTitle: "Select",
5454
menuActions: InitialPage.allCases.compactMap { [weak self] page in

Sources/GravatarUI/Resources/en.lproj/Localizable.strings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,9 @@
264264

265265
/* This confirmation message shows when the user updates fields of their profile. */
266266
"Profile.Update.Success" = "Profile updated successfully";
267+
268+
/* Accessible label for button to switch to the About editor. */
269+
"AvatarPickerProfile.PageSwitchButton.AboutEditor" = "Switch to about editor";
270+
271+
/* Accessible label for button to switch to the Avatar picker. */
272+
"AvatarPickerProfile.PageSwitchButton.AvatarPicker" = "Switch to avatar picker";

Sources/GravatarUI/SwiftUI/AboutEditor/AboutEditorView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ struct AboutEditorView: View {
218218
Text(title)
219219
.font(Constants.primaryFont)
220220
.multilineTextAlignment(.leading)
221+
.accessibilityHidden(true)
221222
if isLarge {
222223
TextEditor(text: value)
223224
.font(Constants.primaryFont)
@@ -227,6 +228,7 @@ struct AboutEditorView: View {
227228
.inputBorders(colorScheme: colorScheme)
228229
.frame(height: dynamicTypeSize >= .accessibility1 ? 150 : 120)
229230
.disabled(isSaving)
231+
.accessibilityLabel(title)
230232
} else {
231233
TextField(
232234
"",
@@ -236,6 +238,7 @@ struct AboutEditorView: View {
236238
.padding(.DS.Padding.split)
237239
.inputBorders(colorScheme: colorScheme)
238240
.disabled(isSaving)
241+
.accessibilityLabel(title)
239242
}
240243

241244
if let footerText {

Sources/GravatarUI/SwiftUI/AvatarPicker/AvatarPickerProfileViewWrapper.swift

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct AvatarPickerProfileViewWrapper: View {
2727
isLoading: $isLoading,
2828
avatarAccessoryView: {
2929
if case .avatar = buttonsMode {
30-
editButton {
30+
editButton(accessibilityLabel: .localizedEditAvatarsButtonLabel) {
3131
buttonTapHandler?(.avatar)
3232
}
3333
} else {
@@ -47,7 +47,7 @@ struct AvatarPickerProfileViewWrapper: View {
4747
.background(profileBackground)
4848
.cornerRadius(8)
4949
if case .aboutInfo = buttonsMode {
50-
editButton {
50+
editButton(accessibilityLabel: .localizedEditAboutEditorButtonLabel) {
5151
buttonTapHandler?(.aboutInfo)
5252
}.padding()
5353
}
@@ -74,7 +74,7 @@ struct AvatarPickerProfileViewWrapper: View {
7474
}
7575

7676
@ViewBuilder
77-
private func editButton(action: @escaping () -> Void) -> some View {
77+
private func editButton(accessibilityLabel: String, action: @escaping () -> Void) -> some View {
7878
Button(action: action) {
7979
Image("pencil", bundle: Bundle.module)
8080
.resizable()
@@ -83,10 +83,29 @@ struct AvatarPickerProfileViewWrapper: View {
8383
.padding(6)
8484
.background(Color.white)
8585
.clipShape(Circle())
86+
.accessibilityLabel(accessibilityLabel)
8687
}
8788
}
8889
}
8990

91+
extension String {
92+
fileprivate static var localizedEditAboutEditorButtonLabel: String {
93+
SDKLocalizedString(
94+
"AvatarPickerProfile.PageSwitchButton.AboutEditor",
95+
value: "Switch to about editor",
96+
comment: "Accessible label for button to switch to the About editor"
97+
)
98+
}
99+
100+
fileprivate static var localizedEditAvatarsButtonLabel: String {
101+
SDKLocalizedString(
102+
"AvatarPickerProfile.PageSwitchButton.AvatarPicker",
103+
value: "Switch to avatar picker",
104+
comment: "Accessible label for button to switch to the Avatar picker"
105+
)
106+
}
107+
}
108+
90109
#Preview {
91110
AvatarPickerProfileViewWrapper(
92111
avatarID: .constant(nil),

0 commit comments

Comments
 (0)