selction fixes and reuse fixes
This commit is contained in:
parent
1d6ed35d84
commit
646dfd6a10
@ -19,6 +19,12 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
public override var isSelected: Bool {
|
||||
didSet {
|
||||
radioModel?.state = isSelected
|
||||
}
|
||||
}
|
||||
|
||||
public var enabledColor: UIColor = .black
|
||||
public var disabledColor: UIColor = .mfSilver()
|
||||
public var delegateObject: MVMCoreUIDelegateObject?
|
||||
@ -128,6 +134,9 @@ import UIKit
|
||||
|
||||
self.delegateObject = delegateObject
|
||||
isSelected = model.state
|
||||
if model.state {
|
||||
print("log")
|
||||
}
|
||||
RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject)
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,6 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
||||
|
||||
public init(_ state: Bool) {
|
||||
self.state = state
|
||||
baseValue = state
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -55,7 +54,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
||||
//--------------------------------------------------
|
||||
|
||||
public func formFieldValue() -> AnyHashable? {
|
||||
return state
|
||||
return fieldValue
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -75,7 +74,6 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
||||
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
|
||||
baseValue = state
|
||||
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
||||
if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) {
|
||||
self.groupName = groupName
|
||||
|
||||
@ -16,8 +16,11 @@ import UIKit
|
||||
private var fieldGroupName: String?
|
||||
public var baseValue: AnyHashable?
|
||||
|
||||
init(_ fieldKey: String?) {
|
||||
self.fieldKey = fieldKey
|
||||
init(_ radioButtonModel: RadioButtonModel?) {
|
||||
self.fieldKey = radioButtonModel?.fieldKey
|
||||
if radioButtonModel?.state ?? false {
|
||||
self.baseValue = radioButtonModel?.formFieldValue()
|
||||
}
|
||||
}
|
||||
|
||||
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) {
|
||||
@ -26,7 +29,7 @@ import UIKit
|
||||
return
|
||||
}
|
||||
|
||||
let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey)
|
||||
let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel)
|
||||
radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey
|
||||
formValidator.radioButtonsModelByGroup[groupName] = radioButtonSelectionHelper
|
||||
|
||||
|
||||
@ -66,7 +66,8 @@ import MVMCore
|
||||
return valid
|
||||
}
|
||||
for group in formRules {
|
||||
valid = valid && validateGroup(group)
|
||||
let groupValid = validateGroup(group)
|
||||
valid = valid && groupValid
|
||||
}
|
||||
return valid
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user