updated base with fix
This commit is contained in:
parent
ac816f07f0
commit
ec8d4ba1d6
@ -11,7 +11,7 @@ import Combine
|
||||
import VDSCoreTokens
|
||||
|
||||
/// Base Class used to build out a SelectorControlable control.
|
||||
open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable, Changeable, Groupable {
|
||||
open class SelectorItemBase<Selector: SelectorBase>: Control, Errorable, Changeable, Groupable {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -149,6 +149,11 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
||||
|
||||
open var accessibilityLabelText: String {
|
||||
var accessibilityLabels = [String]()
|
||||
|
||||
if isSelected {
|
||||
accessibilityLabels.append("selected")
|
||||
}
|
||||
|
||||
accessibilityLabels.append("\(Selector.self)")
|
||||
|
||||
if let text = labelText, !text.isEmpty {
|
||||
@ -177,8 +182,14 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
||||
open override func initialSetup() {
|
||||
super.initialSetup()
|
||||
onClick = { [weak self] control in
|
||||
self?.toggle()
|
||||
guard let self, isEnabled else { return }
|
||||
toggle()
|
||||
}
|
||||
|
||||
selectorView.accessibilityDefaultAction = { [weak self] in
|
||||
guard let self, isEnabled else { return }
|
||||
toggle()
|
||||
}
|
||||
}
|
||||
|
||||
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
|
||||
@ -209,7 +220,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
||||
open override func updateView() {
|
||||
super.updateView()
|
||||
updateLabels()
|
||||
selectorView.isUserInteractionEnabled = true
|
||||
selectorView.showError = showError
|
||||
selectorView.isSelected = isSelected
|
||||
selectorView.isHighlighted = isHighlighted
|
||||
@ -251,14 +261,16 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
||||
|
||||
/// Overriden to take the hit if there is an onClickSubscriber and the view is not a UIControl
|
||||
open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
guard isEnabled else { return super.hitTest(point, with: event) }
|
||||
|
||||
let labelPoint = convert(point, to: label)
|
||||
let childLabelPoint = convert(point, to: childLabel)
|
||||
|
||||
if label.isAction(for: labelPoint) {
|
||||
return label
|
||||
} else if childLabel.isAction(for: childLabelPoint) {
|
||||
return childLabel
|
||||
} else {
|
||||
guard !UIAccessibility.isVoiceOverRunning else { return nil }
|
||||
return super.hitTest(point, with: event)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user