modeling entryField
This commit is contained in:
parent
1eec90e8e1
commit
86ce3c9d4f
@ -12,7 +12,7 @@
|
||||
//--------------------------------------------------
|
||||
|
||||
public override class var identifier: String {
|
||||
return "DateDropdownEntryField"
|
||||
return "dateDropdownEntryField"
|
||||
}
|
||||
|
||||
public var dateFormat: String?
|
||||
|
||||
@ -8,13 +8,12 @@
|
||||
|
||||
|
||||
@objcMembers public class DigitEntryFieldModel: TextEntryFieldModel {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
public override class var identifier: String {
|
||||
return "DigitEntryField"
|
||||
return "digitTextField"
|
||||
}
|
||||
|
||||
public var digits: Int?
|
||||
|
||||
@ -119,6 +119,7 @@ import UIKit
|
||||
feedbackLabel.text = newFeedback
|
||||
feedbackLabel.accessibilityElementsHidden = feedbackLabel.text?.isEmpty ?? true
|
||||
entryFieldContainer.refreshUI()
|
||||
delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import Foundation
|
||||
|
||||
|
||||
@objcMembers public class EntryFieldModel: MoleculeModelProtocol {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
@ -28,7 +27,9 @@ import Foundation
|
||||
public var isSelected: Bool?
|
||||
|
||||
public var fieldKey: String?
|
||||
|
||||
public var isValid: Bool?
|
||||
public var isRequired: Bool?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Keys
|
||||
//--------------------------------------------------
|
||||
@ -38,10 +39,12 @@ import Foundation
|
||||
case title
|
||||
case isDisabled
|
||||
case feedback
|
||||
case errorMessage
|
||||
case errorMessage = "errorMsg"
|
||||
case isLocked
|
||||
case isSelected
|
||||
case fieldKey
|
||||
case isValid
|
||||
case isRequired = "required"
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -58,6 +61,7 @@ import Foundation
|
||||
isLocked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isLocked)
|
||||
isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected)
|
||||
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
||||
isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -70,5 +74,6 @@ import Foundation
|
||||
try container.encodeIfPresent(isLocked, forKey: .isLocked)
|
||||
try container.encodeIfPresent(isSelected, forKey: .isSelected)
|
||||
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
||||
try container.encodeIfPresent(isValid, forKey: .isValid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
//--------------------------------------------------
|
||||
|
||||
public override class var identifier: String {
|
||||
return "ItemDropdownEntryField"
|
||||
return "dropDown"
|
||||
}
|
||||
|
||||
public var options: [String]?
|
||||
|
||||
@ -12,6 +12,6 @@
|
||||
//--------------------------------------------------
|
||||
|
||||
public override class var identifier: String {
|
||||
return "MdnEntryField"
|
||||
return "mdnEntryField"
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,9 +308,7 @@ import UIKit
|
||||
break
|
||||
}
|
||||
|
||||
let regex = model.regex ?? ""
|
||||
|
||||
if !regex.isEmpty {
|
||||
if let regex = model.regex, !regex.isEmpty {
|
||||
validationBlock = { enteredValue in
|
||||
guard let value = enteredValue else { return false }
|
||||
return MVMCoreUIUtility.validate(value, withRegularExpression: regex)
|
||||
|
||||
@ -8,13 +8,12 @@
|
||||
|
||||
|
||||
@objcMembers public class TextEntryFieldModel: EntryFieldModel {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
public override class var identifier: String {
|
||||
return "TextEntryField"
|
||||
return "textField"
|
||||
}
|
||||
|
||||
public var text: String?
|
||||
|
||||
@ -29,6 +29,10 @@ extension MFViewController: MoleculeDelegateProtocol {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@objc public func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public extension MFViewController {
|
||||
|
||||
@ -35,12 +35,10 @@
|
||||
@"footer": FooterView.class,
|
||||
@"caretView": CaretView.class,
|
||||
@"caretLink": CaretButton.class,
|
||||
@"textField": MFTextField.class,
|
||||
@"digitTextField": MFDigitTextField.class,
|
||||
@"digitEntryField": DigitEntryField.class,
|
||||
@"textEntryField": TextEntryField.class,
|
||||
@"digitTextField": DigitEntryField.class,
|
||||
@"textField": TextEntryField.class,
|
||||
@"mdnEntryField": MdnEntryField.class,
|
||||
@"itemDropdownEntryField": ItemDropdownEntryField.class,
|
||||
@"dropDown": ItemDropdownEntryField.class,
|
||||
@"dateDropdownEntryField": DateDropdownEntryField.class,
|
||||
@"checkbox": Checkbox.class,
|
||||
@"checkboxLabel": CheckboxWithLabelView.class,
|
||||
|
||||
@ -33,7 +33,7 @@ import Foundation
|
||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CaretButton.self, viewModelClass: CaretLinkModel.self)
|
||||
|
||||
// Entry Field
|
||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextFieldModel.self)
|
||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: TextEntryField.self, viewModelClass: TextEntryFieldModel.self)
|
||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MdnEntryField.self, viewModelClass: MdnEntryFieldModel.self)
|
||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: DigitEntryField.self, viewModelClass: DigitEntryFieldModel.self)
|
||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ItemDropdownEntryField.self, viewModelClass: ItemDropdownEntryFieldModel.self)
|
||||
|
||||
@ -123,7 +123,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
}
|
||||
|
||||
// MARK: - MoleculeDelegateProtocol
|
||||
open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
||||
open override func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
||||
if let tableView = tableView {
|
||||
let point = molecule.convert(molecule.bounds.origin, to: tableView)
|
||||
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user