Merge branch 'feature/further_accesibilty' into 'develop'
Accessibility fixes. See merge request BPHV_MIPS/mvm_core_ui!218
This commit is contained in:
commit
cdeddb3de4
@ -91,6 +91,7 @@ public typealias ActionBlock = () -> ()
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
clauses = []
|
||||
accessibilityCustomActions = []
|
||||
accessibilityTraits = .staticText
|
||||
|
||||
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(textLinkTapped(_:)))
|
||||
tapGesture.numberOfTapsRequired = 1
|
||||
@ -522,6 +523,7 @@ public typealias ActionBlock = () -> ()
|
||||
|
||||
func appendActionableClause(range: NSRange, actionBlock: @escaping ActionBlock) {
|
||||
|
||||
accessibilityTraits = .button
|
||||
let accessibleAction = customAccessibilityAction(range: range)
|
||||
clauses.append(ActionableClause(range: range, actionBlock: actionBlock, accessibilityID: accessibleAction?.hash ?? -1))
|
||||
}
|
||||
@ -582,6 +584,7 @@ extension Label {
|
||||
styleB2(true)
|
||||
accessibilityCustomActions = []
|
||||
clauses = []
|
||||
accessibilityTraits = .staticText
|
||||
}
|
||||
|
||||
@objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
@ -721,7 +724,6 @@ extension UITapGestureRecognizer {
|
||||
if label.makeWholeViewClickable {
|
||||
return true
|
||||
}
|
||||
|
||||
guard let abstractContainer = label.abstractTextContainer() else { return false }
|
||||
let textContainer = abstractContainer.0
|
||||
let layoutManager = abstractContainer.1
|
||||
@ -775,7 +777,7 @@ extension Label {
|
||||
}
|
||||
|
||||
@objc public func accessibilityCustomAction(_ action: UIAccessibilityCustomAction) {
|
||||
|
||||
|
||||
for clause in clauses {
|
||||
if action.hash == clause.accessibilityID {
|
||||
clause.performAction()
|
||||
@ -783,4 +785,19 @@ extension Label {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open override func accessibilityActivate() -> Bool {
|
||||
|
||||
guard let accessibleActions = accessibilityCustomActions else { return false }
|
||||
|
||||
for clause in clauses {
|
||||
for action in accessibleActions {
|
||||
if action.hash == clause.accessibilityID {
|
||||
clause.performAction()
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user