accessibile togle
This commit is contained in:
parent
88349bc651
commit
f133bad78c
@ -127,6 +127,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
private var widthConstraint: NSLayoutConstraint?
|
private var widthConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
private func constrainKnob() {
|
private func constrainKnob() {
|
||||||
|
|
||||||
knobLeadingConstraint?.isActive = !isOn
|
knobLeadingConstraint?.isActive = !isOn
|
||||||
knobTrailingConstraint?.isActive = isOn
|
knobTrailingConstraint?.isActive = isOn
|
||||||
}
|
}
|
||||||
@ -343,7 +344,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
guard let model = model as? ToggleModel else { return }
|
guard let model = model as? ToggleModel else { return }
|
||||||
|
|
||||||
accessibilityLabel = model.accessibilityText ?? MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel")
|
accessibilityLabel = model.accessibilityText ?? MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel")
|
||||||
|
isOn = model.state
|
||||||
FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate)
|
FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate)
|
||||||
setWithJSON(model.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
|
setWithJSON(model.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
|
|
||||||
public static var identifier: String = "toggle"
|
public static var identifier: String = "toggle"
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var state: Bool = true
|
public var state: Bool = false
|
||||||
public var action: ActionModelProtocol?
|
public var action: ActionModelProtocol?
|
||||||
public var alternateAction: ActionModelProtocol?
|
public var alternateAction: ActionModelProtocol?
|
||||||
public var accessibilityText: String?
|
public var accessibilityText: String?
|
||||||
@ -60,6 +60,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
|
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
|
||||||
self.state = state
|
self.state = state
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
// Switch / Toggle
|
// Switch / Toggle
|
||||||
"mfswitch_buttonlabel" = "Switch Button";
|
"mfswitch_buttonlabel" = "Switch Button";
|
||||||
"Toggle_buttonlabel" = "Toggle Button"
|
"Toggle_buttonlabel" = "Toggle Button";
|
||||||
"AccOn" = "on";
|
"AccOn" = "on";
|
||||||
"AccOff" = "off";
|
"AccOff" = "off";
|
||||||
"AccToggleHint" = "double tap to toggle";
|
"AccToggleHint" = "double tap to toggle";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user