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
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
clauses = []
|
clauses = []
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
|
accessibilityTraits = .staticText
|
||||||
|
|
||||||
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(textLinkTapped(_:)))
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(textLinkTapped(_:)))
|
||||||
tapGesture.numberOfTapsRequired = 1
|
tapGesture.numberOfTapsRequired = 1
|
||||||
@ -522,6 +523,7 @@ public typealias ActionBlock = () -> ()
|
|||||||
|
|
||||||
func appendActionableClause(range: NSRange, actionBlock: @escaping ActionBlock) {
|
func appendActionableClause(range: NSRange, actionBlock: @escaping ActionBlock) {
|
||||||
|
|
||||||
|
accessibilityTraits = .button
|
||||||
let accessibleAction = customAccessibilityAction(range: range)
|
let accessibleAction = customAccessibilityAction(range: range)
|
||||||
clauses.append(ActionableClause(range: range, actionBlock: actionBlock, accessibilityID: accessibleAction?.hash ?? -1))
|
clauses.append(ActionableClause(range: range, actionBlock: actionBlock, accessibilityID: accessibleAction?.hash ?? -1))
|
||||||
}
|
}
|
||||||
@ -582,6 +584,7 @@ extension Label {
|
|||||||
styleB2(true)
|
styleB2(true)
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
clauses = []
|
clauses = []
|
||||||
|
accessibilityTraits = .staticText
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
@objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
@ -721,7 +724,6 @@ extension UITapGestureRecognizer {
|
|||||||
if label.makeWholeViewClickable {
|
if label.makeWholeViewClickable {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let abstractContainer = label.abstractTextContainer() else { return false }
|
guard let abstractContainer = label.abstractTextContainer() else { return false }
|
||||||
let textContainer = abstractContainer.0
|
let textContainer = abstractContainer.0
|
||||||
let layoutManager = abstractContainer.1
|
let layoutManager = abstractContainer.1
|
||||||
@ -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