added to base classes the new accessiblity implmenation
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
4b8d0d985a
commit
a2f7c03b8f
@ -53,6 +53,8 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
|
|||||||
|
|
||||||
open var surface: Surface = .light { didSet { setNeedsUpdate() } }
|
open var surface: Surface = .light { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
|
open var accessibilityAction: ((Control) -> Void)?
|
||||||
|
|
||||||
/// Whether the Control is selected or not.
|
/// Whether the Control is selected or not.
|
||||||
open override var isSelected: Bool { didSet { setNeedsUpdate() } }
|
open override var isSelected: Bool { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
@ -123,9 +125,14 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// Implement accessibilityActivate on an element in order to handle the default action.
|
/// Implement accessibilityActivate on an element in order to handle the default action.
|
||||||
/// - Returns: Based on whether the userInteraction is enabled.
|
/// - Returns: Based on whether the userInteraction is enabled.
|
||||||
override open func accessibilityActivate() -> Bool {
|
open override func accessibilityActivate() -> Bool {
|
||||||
// Hold state in case User wanted isAnimated to remain off.
|
// Hold state in case User wanted isAnimated to remain off.
|
||||||
guard isUserInteractionEnabled else { return false }
|
guard isEnabled, isUserInteractionEnabled else { return false }
|
||||||
|
|
||||||
|
if let accessibilityAction {
|
||||||
|
accessibilityAction(self)
|
||||||
|
}
|
||||||
|
|
||||||
sendActions(for: .touchUpInside)
|
sendActions(for: .touchUpInside)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,8 @@ open class View: UIView, ViewProtocol, UserInfoable {
|
|||||||
|
|
||||||
open var isEnabled: Bool = true { didSet { setNeedsUpdate() } }
|
open var isEnabled: Bool = true { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
|
open var accessibilityAction: ((View) -> Void)?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -87,7 +89,15 @@ open class View: UIView, ViewProtocol, UserInfoable {
|
|||||||
surface = .light
|
surface = .light
|
||||||
isEnabled = true
|
isEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func accessibilityActivate() -> Bool {
|
||||||
|
guard isEnabled, isUserInteractionEnabled else { return false }
|
||||||
|
if let accessibilityAction {
|
||||||
|
accessibilityAction(self)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
open override func layoutSubviews() {
|
open override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
|
|||||||
@ -78,6 +78,8 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
|
|||||||
/// Whether the Button should handle the isHighlighted state.
|
/// Whether the Button should handle the isHighlighted state.
|
||||||
open var shouldHighlight: Bool { isHighlighting == false }
|
open var shouldHighlight: Bool { isHighlighting == false }
|
||||||
|
|
||||||
|
open var accessibilityAction: ((ButtonBase) -> Void)?
|
||||||
|
|
||||||
/// Whether the Control is highlighted or not.
|
/// Whether the Control is highlighted or not.
|
||||||
open override var isHighlighted: Bool {
|
open override var isHighlighted: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
@ -141,6 +143,15 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
|
|||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func accessibilityActivate() -> Bool {
|
||||||
|
guard isEnabled, isUserInteractionEnabled else { return false }
|
||||||
|
if let accessibilityAction {
|
||||||
|
accessibilityAction(self)
|
||||||
|
}
|
||||||
|
sendActions(for: .touchUpInside)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
|
|||||||
@ -132,6 +132,8 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
/// Line break mode for the label, default is set to word wrapping.
|
/// Line break mode for the label, default is set to word wrapping.
|
||||||
open override var lineBreakMode: NSLineBreakMode { didSet { setNeedsUpdate() }}
|
open override var lineBreakMode: NSLineBreakMode { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var accessibilityAction: ((Label) -> Void)?
|
||||||
|
|
||||||
/// Text that will be used in the label.
|
/// Text that will be used in the label.
|
||||||
private var _text: String!
|
private var _text: String!
|
||||||
override open var text: String! {
|
override open var text: String! {
|
||||||
@ -455,7 +457,9 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override func accessibilityActivate() -> Bool {
|
open override func accessibilityActivate() -> Bool {
|
||||||
return false
|
guard let accessibilityAction, isEnabled, isUserInteractionEnabled else { return false }
|
||||||
|
accessibilityAction(self)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,6 +77,8 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
|
|
||||||
open var lineBreakMode: NSLineBreakMode = .byClipping { didSet { setNeedsUpdate() } }
|
open var lineBreakMode: NSLineBreakMode = .byClipping { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
|
open var accessibilityAction: ((TextField) -> Void)?
|
||||||
|
|
||||||
open override var isEnabled: Bool { didSet { setNeedsUpdate() } }
|
open override var isEnabled: Bool { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var textColorConfiguration: AnyColorable = ViewColorConfiguration().with {
|
open var textColorConfiguration: AnyColorable = ViewColorConfiguration().with {
|
||||||
@ -211,6 +213,17 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func accessibilityActivate() -> Bool {
|
||||||
|
guard isEnabled, isUserInteractionEnabled else { return false }
|
||||||
|
|
||||||
|
if let accessibilityAction {
|
||||||
|
accessibilityAction(self)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return super.accessibilityActivate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -68,6 +68,8 @@ open class TextView: UITextView, ViewProtocol, Errorable {
|
|||||||
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false)
|
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false)
|
||||||
}.eraseToAnyColorable(){ didSet { setNeedsUpdate() }}
|
}.eraseToAnyColorable(){ didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var accessibilityAction: ((TextView) -> Void)?
|
||||||
|
|
||||||
open var showError: Bool = false { didSet { setNeedsUpdate() } }
|
open var showError: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var errorText: String? { didSet { setNeedsUpdate() } }
|
open var errorText: String? { didSet { setNeedsUpdate() } }
|
||||||
@ -146,6 +148,17 @@ open class TextView: UITextView, ViewProtocol, Errorable {
|
|||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func accessibilityActivate() -> Bool {
|
||||||
|
guard isEnabled, isUserInteractionEnabled else { return false }
|
||||||
|
|
||||||
|
if let accessibilityAction {
|
||||||
|
accessibilityAction(self)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return super.accessibilityActivate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public protocol ViewProtocol: AnyObject, Initable, Resettable, Enabling, Surface
|
|||||||
var shouldUpdateAccessibility: Bool { get set }
|
var shouldUpdateAccessibility: Bool { get set }
|
||||||
|
|
||||||
/// Used for setting an implementation for the default Accessible Action
|
/// Used for setting an implementation for the default Accessible Action
|
||||||
var accessibilityDefaultAction: ((Self) -> Void)? { get set }
|
var accessibilityAction: ((Self) -> Void)? { get set }
|
||||||
|
|
||||||
/// Executed on initialization for this View.
|
/// Executed on initialization for this View.
|
||||||
func initialSetup()
|
func initialSetup()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user