standardize modal & input error accessibility ids

pull/1033/head
Ryan ZHAO 6 months ago
parent a1c3d53569
commit b2ce98ea83

@ -96,7 +96,6 @@ extension ConversationVC:
title: "callsPermissionsRequired".localized(),
body: .text("callsPermissionsRequiredDescription".localized()),
confirmTitle: "sessionSettings".localized(),
confirmAccessibility: Accessibility(identifier: "Settings"),
dismissOnConfirm: false // Custom dismissal logic
) { [weak self] _ in
self?.dismiss(animated: true) {
@ -160,9 +159,7 @@ extension ConversationVC:
.localizedFormatted(baseFont: .systemFont(ofSize: Values.smallFontSize))
),
confirmTitle: "blockUnblock".localized(),
confirmAccessibility: Accessibility(identifier: "Confirm block"),
confirmStyle: .danger,
cancelAccessibility: Accessibility(identifier: "Cancel block"),
confirmStyle: .danger,
cancelStyle: .alert_text,
dismissOnConfirm: false // Custom dismissal logic
) { [weak self] _ in
@ -921,9 +918,7 @@ extension ConversationVC:
info: ConfirmationModal.Info(
title: "disappearingMessagesFollowSetting".localized(),
body: .attributedText(modalBodyString.formatted(baseFont: .systemFont(ofSize: Values.smallFontSize))),
accessibility: Accessibility(identifier: "Follow setting dialog"),
confirmTitle: modalConfirmTitle,
confirmAccessibility: Accessibility(identifier: "Set button"),
confirmStyle: .danger,
cancelStyle: .textPrimary,
dismissOnConfirm: false // Custom dismissal logic
@ -955,8 +950,6 @@ extension ConversationVC:
title: "attachmentsAutoDownloadModalTitle".localized(),
body: .attributedText(message),
confirmTitle: "download".localized(),
confirmAccessibility: Accessibility(identifier: "Download media"),
cancelAccessibility: Accessibility(identifier: "Don't download media"),
dismissOnConfirm: false // Custom dismissal logic
) { [weak self] _ in
self?.viewModel.trustContact()

@ -707,7 +707,6 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
"blockUnblock".localized() :
"block".localized()
),
confirmAccessibility: Accessibility(identifier: "Confirm block"),
confirmStyle: .danger,
cancelStyle: .alert_text
),

@ -207,13 +207,7 @@ class MessageRequestsViewModel: SessionTableViewModel, NavigatableStateHolder, O
info: ConfirmationModal.Info(
title: "clearAll".localized(),
body: .text("messageRequestsClearAllExplanation".localized()),
accessibility: Accessibility(
identifier: "Clear all"
),
confirmTitle: "clear".localized(),
confirmAccessibility: Accessibility(
identifier: "Clear"
),
confirmStyle: .danger,
cancelStyle: .alert_text,
onConfirm: { _ in

File diff suppressed because one or more lines are too long

@ -150,16 +150,8 @@ struct LandingScreen: View {
title: "urlOpen".localized(),
body: .text("urlOpenBrowser".localized()),
confirmTitle: "onboardingTos".localized(),
confirmAccessibility: Accessibility(
identifier: "Terms of service button",
label: "Terms of service button"
),
confirmStyle: .textPrimary,
cancelTitle: "onboardingPrivacy".localized(),
cancelAccessibility: Accessibility(
identifier: "Privacy policy button",
label: "Privacy policy button"
),
cancelStyle: .textPrimary,
hasCloseButton: true,
onConfirm: { _ in

@ -308,7 +308,6 @@ class PrivacySettingsViewModel: SessionTableViewModel, NavigationItemSource, Nav
body: .text("callsVoiceAndVideoModalDescription".localized()),
showCondition: .disabled,
confirmTitle: "theContinue".localized(),
confirmAccessibility: Accessibility(identifier: "Enable"),
confirmStyle: .danger,
cancelStyle: .alert_text,
onConfirm: { _ in Permissions.requestMicrophonePermissionIfNeeded() }

@ -254,15 +254,7 @@ struct RecoveryPasswordScreen: View {
title: "recoveryPasswordHidePermanently".localized(),
body: .text("recoveryPasswordHidePermanentlyDescription1".localized()),
confirmTitle: "theContinue".localized(),
confirmAccessibility: Accessibility(
identifier: "Continue",
label: "Continue"
),
confirmStyle: .danger,
cancelAccessibility: Accessibility(
identifier: "Cancel",
label: "Cancel"
),
cancelStyle: .textPrimary,
onConfirm: { modal in
guard let presentingViewController: UIViewController = modal.presentingViewController else {
@ -274,16 +266,8 @@ struct RecoveryPasswordScreen: View {
title: "recoveryPasswordHidePermanently".localized(),
body: .text("recoveryPasswordHidePermanentlyDescription2".localized()),
confirmTitle: "cancel".localized(),
confirmAccessibility: Accessibility(
identifier: "Cancel",
label: "Cancel"
),
confirmStyle: .textPrimary,
cancelTitle: "yes".localized(),
cancelAccessibility: Accessibility(
identifier: "Confirm button",
label: "Confirm button"
),
cancelStyle: .danger,
onCancel: { modal in
modal.dismiss(animated: true) {

@ -166,7 +166,6 @@ public class SessionHostingViewController<Content>: UIHostingController<Modified
.localized()
),
confirmTitle: "quitButton".localized(),
confirmAccessibility: Accessibility(identifier: "Quit"),
confirmStyle: .danger,
cancelStyle: .textPrimary,
onConfirm: { [weak self] confirmationModal in

@ -133,9 +133,6 @@ public extension UIContextualAction {
title: "clearMessages".localized(),
body: .text("clearMessagesNoteToSelfDescription".localized()),
confirmTitle: "clear".localized(),
confirmAccessibility: Accessibility(
identifier: "Clear"
),
confirmStyle: .danger,
cancelStyle: .alert_text,
dismissOnConfirm: true,
@ -183,9 +180,6 @@ public extension UIContextualAction {
title: "noteToSelfHide".localized(),
body: .text("noteToSelfHideDescription".localized()),
confirmTitle: "hide".localized(),
confirmAccessibility: Accessibility(
identifier: "Hide"
),
confirmStyle: .danger,
cancelStyle: .alert_text,
dismissOnConfirm: true,
@ -375,7 +369,6 @@ public extension UIContextualAction {
.localizedFormatted(baseFont: .systemFont(ofSize: Values.smallFontSize))
),
confirmTitle: "block".localized(),
confirmAccessibility: Accessibility(identifier: "Confirm block"),
confirmStyle: .danger,
cancelStyle: .alert_text,
dismissOnConfirm: true,
@ -432,9 +425,6 @@ public extension UIContextualAction {
title: confirmationModalTitle,
body: .attributedText(confirmationModalExplanation),
confirmTitle: "leave".localized(),
confirmAccessibility: Accessibility(
identifier: "Leave"
),
confirmStyle: .danger,
cancelStyle: .alert_text,
dismissOnConfirm: true,
@ -538,9 +528,6 @@ public extension UIContextualAction {
title: confirmationModalTitle,
body: .attributedText(confirmationModalExplanation),
confirmTitle: "delete".localized(),
confirmAccessibility: Accessibility(
identifier: "Confirm delete"
),
confirmStyle: .danger,
cancelStyle: .alert_text,
dismissOnConfirm: true,

@ -257,16 +257,15 @@ public class ConfirmationModal: Modal, UITextFieldDelegate {
imageViewTapGestureRecognizer.isEnabled = true
}
confirmButton.accessibilityLabel = info.confirmAccessibility?.label
confirmButton.accessibilityIdentifier = info.confirmAccessibility?.identifier
confirmButton.accessibilityIdentifier = info.confirmTitle
confirmButton.isAccessibilityElement = true
confirmButton.setTitle(info.confirmTitle, for: .normal)
confirmButton.setThemeTitleColor(info.confirmStyle, for: .normal)
confirmButton.setThemeTitleColor(.disabled, for: .disabled)
confirmButton.isHidden = (info.confirmTitle == nil)
confirmButton.isEnabled = info.confirmEnabled
cancelButton.accessibilityLabel = info.cancelAccessibility?.label
cancelButton.accessibilityIdentifier = info.cancelAccessibility?.identifier
cancelButton.accessibilityIdentifier = info.cancelTitle
cancelButton.isAccessibilityElement = true
cancelButton.setTitle(info.cancelTitle, for: .normal)
cancelButton.setThemeTitleColor(info.cancelStyle, for: .normal)
@ -274,8 +273,11 @@ public class ConfirmationModal: Modal, UITextFieldDelegate {
cancelButton.isEnabled = info.cancelEnabled
closeButton.isHidden = !info.hasCloseButton
contentView.accessibilityLabel = info.accessibility?.label
contentView.accessibilityIdentifier = info.accessibility?.identifier
titleLabel.isAccessibilityElement = true
titleLabel.accessibilityIdentifier = "Modal heading" // stringlint:disable
explanationLabel.isAccessibilityElement = true
explanationLabel.accessibilityIdentifier = "Modal description" // stringlint:disable
}
// MARK: - UITextFieldDelegate
@ -329,14 +331,11 @@ public extension ConfirmationModal {
struct Info: Equatable, Hashable {
let title: String
let body: Body
let accessibility: Accessibility?
public let showCondition: ShowCondition
let confirmTitle: String?
let confirmAccessibility: Accessibility?
let confirmStyle: ThemeValue
let confirmEnabled: Bool
let cancelTitle: String
let cancelAccessibility: Accessibility?
let cancelStyle: ThemeValue
let cancelEnabled: Bool
let hasCloseButton: Bool
@ -351,16 +350,11 @@ public extension ConfirmationModal {
public init(
title: String,
body: Body = .none,
accessibility: Accessibility? = nil,
showCondition: ShowCondition = .none,
confirmTitle: String? = nil,
confirmAccessibility: Accessibility? = nil,
confirmStyle: ThemeValue = .alert_text,
confirmEnabled: Bool = true,
cancelTitle: String = "cancel".localized(),
cancelAccessibility: Accessibility? = Accessibility(
identifier: "Cancel"
),
cancelStyle: ThemeValue = .danger,
cancelEnabled: Bool = true,
hasCloseButton: Bool = false,
@ -372,14 +366,11 @@ public extension ConfirmationModal {
) {
self.title = title
self.body = body
self.accessibility = accessibility
self.showCondition = showCondition
self.confirmTitle = confirmTitle
self.confirmAccessibility = confirmAccessibility
self.confirmStyle = confirmStyle
self.confirmEnabled = confirmEnabled
self.cancelTitle = cancelTitle
self.cancelAccessibility = cancelAccessibility
self.cancelStyle = cancelStyle
self.cancelEnabled = cancelEnabled
self.hasCloseButton = hasCloseButton
@ -403,14 +394,11 @@ public extension ConfirmationModal {
return Info(
title: self.title,
body: (body ?? self.body),
accessibility: self.accessibility,
showCondition: self.showCondition,
confirmTitle: self.confirmTitle,
confirmAccessibility: self.confirmAccessibility,
confirmStyle: self.confirmStyle,
confirmEnabled: (confirmEnabled ?? self.confirmEnabled),
cancelTitle: self.cancelTitle,
cancelAccessibility: self.cancelAccessibility,
cancelStyle: self.cancelStyle,
cancelEnabled: (cancelEnabled ?? self.cancelEnabled),
hasCloseButton: self.hasCloseButton,
@ -428,14 +416,11 @@ public extension ConfirmationModal {
return (
lhs.title == rhs.title &&
lhs.body == rhs.body &&
lhs.accessibility == rhs.accessibility &&
lhs.showCondition == rhs.showCondition &&
lhs.confirmTitle == rhs.confirmTitle &&
lhs.confirmAccessibility == rhs.confirmAccessibility &&
lhs.confirmStyle == rhs.confirmStyle &&
lhs.confirmEnabled == rhs.confirmEnabled &&
lhs.cancelTitle == rhs.cancelTitle &&
lhs.cancelAccessibility == rhs.cancelAccessibility &&
lhs.cancelStyle == rhs.cancelStyle &&
lhs.cancelEnabled == rhs.cancelEnabled &&
lhs.hasCloseButton == rhs.hasCloseButton &&
@ -447,14 +432,11 @@ public extension ConfirmationModal {
public func hash(into hasher: inout Hasher) {
title.hash(into: &hasher)
body.hash(into: &hasher)
accessibility.hash(into: &hasher)
showCondition.hash(into: &hasher)
confirmTitle.hash(into: &hasher)
confirmAccessibility.hash(into: &hasher)
confirmStyle.hash(into: &hasher)
confirmEnabled.hash(into: &hasher)
cancelTitle.hash(into: &hasher)
cancelAccessibility.hash(into: &hasher)
cancelStyle.hash(into: &hasher)
cancelEnabled.hash(into: &hasher)
hasCloseButton.hash(into: &hasher)

@ -122,8 +122,7 @@ public struct SessionTextField<ExplanationView>: View where ExplanationView: Vie
.multilineTextAlignment(.center)
.accessibility(
Accessibility(
identifier: "Error message",
label: "Error message"
identifier: "Error message"
)
)
} else {

Loading…
Cancel
Save