mild changes
This commit is contained in:
parent
d7beae4ae5
commit
7a1c0dd0fd
@ -19,8 +19,8 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var enabledColor: UIColor = .black
|
public var enabledColor: UIColor = .mvmBlack
|
||||||
public var disabledColor: UIColor = .mfSilver()
|
public var disabledColor: UIColor = .mvmCoolGray3
|
||||||
public var delegateObject: MVMCoreUIDelegateObject?
|
public var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
public var radioModel: RadioButtonModel? {
|
public var radioModel: RadioButtonModel? {
|
||||||
@ -108,7 +108,7 @@ import UIKit
|
|||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
|
||||||
backgroundColor = .white
|
backgroundColor = .mvmWhite
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
widthConstraint = widthAnchor.constraint(equalToConstant: 30)
|
widthConstraint = widthAnchor.constraint(equalToConstant: 30)
|
||||||
widthConstraint?.isActive = true
|
widthConstraint?.isActive = true
|
||||||
@ -133,6 +133,6 @@ import UIKit
|
|||||||
|
|
||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
backgroundColor = .white
|
backgroundColor = .mvmWhite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,24 +7,35 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
|
||||||
|
|
||||||
@objcMembers public class RadioButtonSelectionHelper: FormFieldProtocol {
|
@objcMembers public class RadioButtonSelectionHelper: FormFieldProtocol {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
public var groupName: String = FormValidator.defaultGroupName
|
public var groupName: String = FormValidator.defaultGroupName
|
||||||
private var selectedRadioButton: RadioButton?
|
private var selectedRadioButton: RadioButton?
|
||||||
private var fieldGroupName: String?
|
private var fieldGroupName: String?
|
||||||
public var baseValue: AnyHashable?
|
public var baseValue: AnyHashable?
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializer
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
init(_ fieldKey: String?) {
|
init(_ fieldKey: String?) {
|
||||||
self.fieldKey = fieldKey
|
self.fieldKey = fieldKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - FUnctions
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) {
|
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
guard let groupName = radioButtonModel.fieldKey,
|
guard let groupName = radioButtonModel.fieldKey,
|
||||||
let formValidator = delegateObject?.formHolderDelegate?.formValidator else {
|
let formValidator = delegateObject?.formHolderDelegate?.formValidator
|
||||||
return
|
else { return }
|
||||||
}
|
|
||||||
|
|
||||||
let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey)
|
let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey)
|
||||||
radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey
|
radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey
|
||||||
@ -45,6 +56,7 @@ import UIKit
|
|||||||
|
|
||||||
// MARK: - FormValidationFormFieldProtocol
|
// MARK: - FormValidationFormFieldProtocol
|
||||||
extension RadioButtonSelectionHelper {
|
extension RadioButtonSelectionHelper {
|
||||||
|
|
||||||
public func formFieldGroupName() -> String? {
|
public func formFieldGroupName() -> String? {
|
||||||
return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName
|
return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol {
|
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import MVMCore
|
import MVMCore
|
||||||
|
|
||||||
|
|
||||||
@objcMembers public class FormValidator: NSObject {
|
@objcMembers public class FormValidator: NSObject {
|
||||||
|
|
||||||
static var defaultGroupName: String = "default"
|
static var defaultGroupName: String = "default"
|
||||||
|
|||||||
@ -8,25 +8,34 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
public class RuleAnyValueChangedModel: RulesProtocol {
|
public class RuleAnyValueChangedModel: RulesProtocol {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static var identifier: String = "anyValueChanged"
|
public static var identifier: String = "anyValueChanged"
|
||||||
public var type: String = RuleAnyValueChangedModel.identifier
|
public var type: String = RuleAnyValueChangedModel.identifier
|
||||||
public var fields: [String]
|
public var fields: [String]
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Validation
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
||||||
return formField.baseValue != formField.formFieldValue()
|
return formField.baseValue != formField.formFieldValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||||
|
|
||||||
for formKey in fields {
|
for formKey in fields {
|
||||||
guard let formField = fieldMolecules[formKey] else {
|
guard let formField = fieldMolecules[formKey] else { continue }
|
||||||
continue
|
|
||||||
}
|
|
||||||
if isValid(formField) {
|
if isValid(formField) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user