accessibile togle

This commit is contained in:
Kevin G Christiano 2020-03-26 12:48:23 -04:00
parent 88349bc651
commit f133bad78c
3 changed files with 5 additions and 3 deletions

View File

@ -127,6 +127,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
private var widthConstraint: NSLayoutConstraint?
private func constrainKnob() {
knobLeadingConstraint?.isActive = !isOn
knobTrailingConstraint?.isActive = isOn
}
@ -343,7 +344,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
guard let model = model as? ToggleModel else { return }
accessibilityLabel = model.accessibilityText ?? MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel")
isOn = model.state
FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate)
setWithJSON(model.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
}

View File

@ -15,7 +15,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
public static var identifier: String = "toggle"
public var backgroundColor: Color?
public var state: Bool = true
public var state: Bool = false
public var action: ActionModelProtocol?
public var alternateAction: ActionModelProtocol?
public var accessibilityText: String?
@ -60,6 +60,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
self.state = state
}

View File

@ -46,7 +46,7 @@
// Switch / Toggle
"mfswitch_buttonlabel" = "Switch Button";
"Toggle_buttonlabel" = "Toggle Button"
"Toggle_buttonlabel" = "Toggle Button";
"AccOn" = "on";
"AccOff" = "off";
"AccToggleHint" = "double tap to toggle";