Merge branch 'feature/radio_form_disable' into 'develop'
Radio form disable See merge request BPHV_MIPS/mvm_core_ui!369
This commit is contained in:
commit
3e5618ea2b
@ -19,9 +19,9 @@ import UIKit
|
||||
widthConstraint?.constant = diameter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public var enabledColor: UIColor = .mvmBlack
|
||||
public var disabledColor: UIColor = .mvmCoolGray6
|
||||
public var disabledColor: UIColor = .mvmCoolGray3
|
||||
public var delegateObject: MVMCoreUIDelegateObject?
|
||||
|
||||
public var radioModel: RadioButtonModel? {
|
||||
@ -41,6 +41,13 @@ import UIKit
|
||||
}
|
||||
}()
|
||||
|
||||
public override var isEnabled: Bool {
|
||||
didSet {
|
||||
isUserInteractionEnabled = isEnabled
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Constraints
|
||||
//--------------------------------------------------
|
||||
@ -72,7 +79,7 @@ import UIKit
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Methods
|
||||
// MARK: - Validation
|
||||
//--------------------------------------------------
|
||||
|
||||
/// The action performed when tapped.
|
||||
@ -129,11 +136,12 @@ import UIKit
|
||||
|
||||
self.delegateObject = delegateObject
|
||||
isSelected = model.state
|
||||
isEnabled = model.enabled
|
||||
RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject)
|
||||
}
|
||||
|
||||
public override func reset() {
|
||||
super.reset()
|
||||
backgroundColor = .white
|
||||
backgroundColor = .mvmWhite
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Method
|
||||
// MARK: - Validation
|
||||
//--------------------------------------------------
|
||||
|
||||
public func formFieldValue() -> AnyHashable? {
|
||||
|
||||
@ -19,7 +19,7 @@ import Foundation
|
||||
private var selectedRadioButton: RadioButton?
|
||||
private var fieldGroupName: String?
|
||||
public var baseValue: AnyHashable?
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
@ -29,7 +29,7 @@ import Foundation
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Methods
|
||||
// MARK: - Functions
|
||||
//--------------------------------------------------
|
||||
|
||||
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) {
|
||||
|
||||
@ -8,12 +8,13 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
|
||||
@objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell {
|
||||
//-----------------------------------------------------
|
||||
// MARK: - Outlets
|
||||
//-----------------------------------------------------
|
||||
|
||||
let radioButton = RadioButton(frame: .zero)
|
||||
let radioButton = RadioButton()
|
||||
let leftImage = MFLoadImageView(pinnedEdges: .all)
|
||||
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink()
|
||||
var stack: Stack<StackModel>
|
||||
@ -57,7 +58,7 @@ import UIKit
|
||||
// MARK: - Molecule
|
||||
//----------------------------------------------------
|
||||
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return}
|
||||
radioButton.set(with: model.radioButton, delegateObject, additionalData)
|
||||
@ -69,7 +70,10 @@ import UIKit
|
||||
return 90
|
||||
}
|
||||
|
||||
public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
radioButton.tapAction()
|
||||
public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
if radioButton.isEnabled {
|
||||
radioButton.tapAction()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
|
||||
@objcMembers open class Control: UIControl, MoleculeViewProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
|
||||
@ -9,8 +9,12 @@
|
||||
import UIKit
|
||||
import MVMCore
|
||||
|
||||
@objcMembers public class FormValidator: NSObject {
|
||||
|
||||
@objcMembers public class FormValidator: NSObject {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
static var defaultGroupName: String = "default"
|
||||
var formRules: [FormGroupRule]?
|
||||
weak var delegate: FormHolderProtocol?
|
||||
@ -18,10 +22,18 @@ import MVMCore
|
||||
var groupWatchers: [FormGroupWatcherFieldProtocol] = []
|
||||
var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:]
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
public init(_ formRules: [FormGroupRule]?) {
|
||||
self.formRules = formRules
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Methods
|
||||
//--------------------------------------------------
|
||||
|
||||
/// Adds the form field to the validator.
|
||||
public func add(_ field: FormFieldProtocol) {
|
||||
if let fieldKey = field.fieldKey {
|
||||
|
||||
@ -8,25 +8,34 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public class RuleAnyValueChangedModel: RulesProtocol {
|
||||
|
||||
public class RuleAnyValueChangedModel: RulesProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
public static var identifier: String = "anyValueChanged"
|
||||
public var type: String = RuleAnyValueChangedModel.identifier
|
||||
public var fields: [String]
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Validation
|
||||
//--------------------------------------------------
|
||||
|
||||
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
||||
return formField.baseValue != formField.formFieldValue()
|
||||
}
|
||||
|
||||
public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||
|
||||
for formKey in fields {
|
||||
guard let formField = fieldMolecules[formKey] else {
|
||||
continue
|
||||
}
|
||||
guard let formField = fieldMolecules[formKey] else { continue }
|
||||
|
||||
if isValid(formField) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user