add accessibility ids

pull/891/head
Ryan ZHAO 1 year ago
parent 72fa1ae52a
commit 98ab03c454

@ -72,6 +72,12 @@ struct MyQRCodeScreen: View {
logo: "SessionWhite40",
themeStyle: ThemeManager.currentTheme.interfaceStyle
)
.accessibility(
Accessibility(
identifier: "QR code",
label: "QR code"
)
)
.aspectRatio(1, contentMode: .fit)
Text("settings_view_my_qr_code_explanation".localized())

@ -158,7 +158,7 @@ class SettingsViewModel: SessionTableViewModel, NavigationItemSource, Navigatabl
image: UIImage(named: "QRCode")?
.withRenderingMode(.alwaysTemplate),
style: .plain,
accessibilityIdentifier: "Show QR code button",
accessibilityIdentifier: "View QR code",
action: { [weak self] in
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: QRCodeScreen())
viewController.setNavBarTitle("vc_qr_code_title".localized())
@ -249,6 +249,7 @@ class SettingsViewModel: SessionTableViewModel, NavigationItemSource, Navigatabl
backgroundStyle: .noBackground
),
accessibility: Accessibility(
identifier: "User settings",
label: "Profile picture"
),
onTap: {
@ -300,16 +301,24 @@ class SettingsViewModel: SessionTableViewModel, NavigationItemSource, Navigatabl
id: .idActions,
leftAccessory: .button(
style: .bordered,
title: "copy".localized(),
run: { button in
self?.copySessionId(state.profile.id, button: button)
title: "share".localized(),
accessibility: Accessibility(
identifier: "Share button",
label: "Share button"
),
run: { _ in
self?.shareSessionId(state.profile.id)
}
),
rightAccessory: .button(
style: .bordered,
title: "share".localized(),
run: { _ in
self?.shareSessionId(state.profile.id)
title: "copy".localized(),
accessibility: Accessibility(
identifier: "Copy button",
label: "Copy button"
),
run: { button in
self?.copySessionId(state.profile.id, button: button)
}
),
styling: SessionCell.StyleInfo(

@ -135,7 +135,10 @@ extension View {
public func accessibility(_ accessibility: Accessibility) -> some View {
if #available(iOSApplicationExtension 14.0, *) {
return accessibilityIdentifier(accessibility.identifier ?? "").accessibilityLabel(accessibility.label ?? "")
guard let identifier = accessibility.identifier else {
return self
}
return accessibilityIdentifier(identifier).accessibilityLabel(accessibility.label ?? "")
} else {
return self
}

Loading…
Cancel
Save