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
|
widthConstraint?.constant = diameter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var enabledColor: UIColor = .mvmBlack
|
public var enabledColor: UIColor = .mvmBlack
|
||||||
public var disabledColor: UIColor = .mvmCoolGray6
|
public var disabledColor: UIColor = .mvmCoolGray3
|
||||||
public var delegateObject: MVMCoreUIDelegateObject?
|
public var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
public var radioModel: RadioButtonModel? {
|
public var radioModel: RadioButtonModel? {
|
||||||
@ -41,6 +41,13 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
public override var isEnabled: Bool {
|
||||||
|
didSet {
|
||||||
|
isUserInteractionEnabled = isEnabled
|
||||||
|
setNeedsDisplay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -72,7 +79,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Validation
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// The action performed when tapped.
|
/// The action performed when tapped.
|
||||||
@ -129,11 +136,12 @@ import UIKit
|
|||||||
|
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
isSelected = model.state
|
isSelected = model.state
|
||||||
|
isEnabled = model.enabled
|
||||||
RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject)
|
RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
backgroundColor = .white
|
backgroundColor = .mvmWhite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Method
|
// MARK: - Validation
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public func formFieldValue() -> AnyHashable? {
|
public func formFieldValue() -> AnyHashable? {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import Foundation
|
|||||||
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
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -29,7 +29,7 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Functions
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) {
|
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
|
|||||||
@ -8,12 +8,13 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell {
|
@objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell {
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|
||||||
let radioButton = RadioButton(frame: .zero)
|
let radioButton = RadioButton()
|
||||||
let leftImage = MFLoadImageView(pinnedEdges: .all)
|
let leftImage = MFLoadImageView(pinnedEdges: .all)
|
||||||
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink()
|
let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink()
|
||||||
var stack: Stack<StackModel>
|
var stack: Stack<StackModel>
|
||||||
@ -57,7 +58,7 @@ import UIKit
|
|||||||
// MARK: - Molecule
|
// 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)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return}
|
guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return}
|
||||||
radioButton.set(with: model.radioButton, delegateObject, additionalData)
|
radioButton.set(with: model.radioButton, delegateObject, additionalData)
|
||||||
@ -69,7 +70,10 @@ import UIKit
|
|||||||
return 90
|
return 90
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
radioButton.tapAction()
|
|
||||||
|
if radioButton.isEnabled {
|
||||||
|
radioButton.tapAction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol {
|
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class Control: UIControl, MoleculeViewProtocol {
|
@objcMembers open class Control: UIControl, MoleculeViewProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
|
|||||||
@ -9,8 +9,12 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import MVMCore
|
import MVMCore
|
||||||
|
|
||||||
@objcMembers public class FormValidator: NSObject {
|
|
||||||
|
|
||||||
|
@objcMembers public class FormValidator: NSObject {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
static var defaultGroupName: String = "default"
|
static var defaultGroupName: String = "default"
|
||||||
var formRules: [FormGroupRule]?
|
var formRules: [FormGroupRule]?
|
||||||
weak var delegate: FormHolderProtocol?
|
weak var delegate: FormHolderProtocol?
|
||||||
@ -18,10 +22,18 @@ import MVMCore
|
|||||||
var groupWatchers: [FormGroupWatcherFieldProtocol] = []
|
var groupWatchers: [FormGroupWatcherFieldProtocol] = []
|
||||||
var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:]
|
var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:]
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializer
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(_ formRules: [FormGroupRule]?) {
|
public init(_ formRules: [FormGroupRule]?) {
|
||||||
self.formRules = formRules
|
self.formRules = formRules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Methods
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Adds the form field to the validator.
|
/// Adds the form field to the validator.
|
||||||
public func add(_ field: FormFieldProtocol) {
|
public func add(_ field: FormFieldProtocol) {
|
||||||
if let fieldKey = field.fieldKey {
|
if let fieldKey = field.fieldKey {
|
||||||
|
|||||||
@ -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