|
|
|
@ -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)
|
|
|
|
|