formatting improvement. testing logic.

This commit is contained in:
Kevin G Christiano 2020-12-09 14:58:46 -05:00
parent 3d5c7bbf4c
commit 88110b6508
13 changed files with 29 additions and 41 deletions

View File

@ -2024,10 +2024,10 @@
D29DF22B21E6A0FA003B2FB9 /* TextFields */ = { D29DF22B21E6A0FA003B2FB9 /* TextFields */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */,
0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */,
0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */, 0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */,
0A21DB7E235DECC500C160A2 /* EntryField.swift */, 0A21DB7E235DECC500C160A2 /* EntryField.swift */,
0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */,
0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */,
0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */, 0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */,
0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */, 0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */,
0A8321AE2355FE9500CB7F00 /* DigitBox.swift */, 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */,

View File

@ -52,15 +52,14 @@ import UIKit
setTitle(model.title, for: .normal) setTitle(model.title, for: .normal)
accessibilityLabel = model.title accessibilityLabel = model.title
accessibilityIdentifier = model.accessibilityIdentifier
setTitleColor((model.inverted ? model.enabledColor_inverted : model.enabledColor).uiColor, for: .normal) setTitleColor((model.inverted ? model.enabledColor_inverted : model.enabledColor).uiColor, for: .normal)
setTitleColor((model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled) setTitleColor((model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled)
isEnabled = model.enabled isEnabled = model.enabled
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 31 }
return 31
}
} }
// MARK: - MVMCoreViewProtocol // MARK: - MVMCoreViewProtocol
@ -98,7 +97,5 @@ extension Link {
// MARK: - MVMCoreUIViewConstrainingProtocol // MARK: - MVMCoreUIViewConstrainingProtocol
extension Link: MVMCoreUIViewConstrainingProtocol { extension Link: MVMCoreUIViewConstrainingProtocol {
open func horizontalAlignment() -> UIStackView.Alignment { open func horizontalAlignment() -> UIStackView.Alignment { .leading }
return .leading
}
} }

View File

@ -19,6 +19,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
} }
public var backgroundColor: Color? public var backgroundColor: Color?
public var accessibilityIdentifier: String?
public var title: String public var title: String
public var action: ActionModelProtocol public var action: ActionModelProtocol
public var enabled = true public var enabled = true
@ -44,6 +45,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case backgroundColor case backgroundColor
case accessibilityIdentifier
case title case title
case action case action
case enabled case enabled
@ -62,6 +64,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
title = try typeContainer.decode(String.self, forKey: .title) title = try typeContainer.decode(String.self, forKey: .title)
action = try typeContainer.decodeModel(codingKey: .action) action = try typeContainer.decodeModel(codingKey: .action)
@ -95,6 +98,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
try container.encode(title, forKey: .title) try container.encode(title, forKey: .title)
try container.encode(moleculeName, forKey: .moleculeName) try container.encode(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
try container.encodeModel(action, forKey: .action) try container.encodeModel(action, forKey: .action)
try container.encode(inverted, forKey: .inverted) try container.encode(inverted, forKey: .inverted)
try container.encode(enabled, forKey: .enabled) try container.encode(enabled, forKey: .enabled)

View File

@ -14,9 +14,7 @@
public var caretView: CaretViewModel? public var caretView: CaretViewModel?
public var action: ActionModelProtocol? public var action: ActionModelProtocol?
public override class var identifier: String { public override class var identifier: String { "" }
return ""
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys

View File

@ -23,15 +23,15 @@ import UIKit
}() }()
public var dateFormat: String? { public var dateFormat: String? {
get { dateDropdownModel?.dateFormat }
set { set {
guard let newValue = newValue else { return } guard let newValue = newValue else { return }
dateDropdownModel?.dateFormat = newValue dateDropdownModel?.dateFormat = newValue
} }
get { return dateDropdownModel?.dateFormat }
} }
public var dateDropdownModel: DateDropdownEntryFieldModel? { public var dateDropdownModel: DateDropdownEntryFieldModel? {
return model as? DateDropdownEntryFieldModel model as? DateDropdownEntryFieldModel
} }
//-------------------------------------------------- //--------------------------------------------------

View File

@ -11,9 +11,7 @@
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String { "dateDropdownEntryField" }
return "dateDropdownEntryField"
}
public var dateFormatter: DateFormatter = { public var dateFormatter: DateFormatter = {
let formatter = DateFormatter() let formatter = DateFormatter()

View File

@ -12,9 +12,7 @@
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String { "digitTextField" }
return "digitTextField"
}
public var digits: Int = 4 public var digits: Int = 4

View File

@ -327,9 +327,7 @@ import UIKit
} }
} }
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 115 }
return 115
}
} }
// MARK: - Accessibility // MARK: - Accessibility

View File

@ -19,6 +19,7 @@ import Foundation
} }
public var backgroundColor: Color? public var backgroundColor: Color?
public var accessibilityIdentifier: String?
public var title: String? public var title: String?
public var feedback: String? public var feedback: String?
public var errorMessage: String? public var errorMessage: String?
@ -48,6 +49,7 @@ import Foundation
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case backgroundColor case backgroundColor
case accessibilityIdentifier
case title case title
case enabled case enabled
case feedback case feedback
@ -66,9 +68,7 @@ import Foundation
// MARK: - Validation Methods // MARK: - Validation Methods
//-------------------------------------------------- //--------------------------------------------------
public func formFieldValue() -> AnyHashable? { public func formFieldValue() -> AnyHashable? { text }
return text
}
public func setValidity(_ valid: Bool, rule: RulesProtocol) { public func setValidity(_ valid: Bool, rule: RulesProtocol) {
@ -96,6 +96,7 @@ import Foundation
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
title = try typeContainer.decodeIfPresent(String.self, forKey: .title) title = try typeContainer.decodeIfPresent(String.self, forKey: .title)
feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback) feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback)
errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage)
@ -117,6 +118,7 @@ import Foundation
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(title, forKey: .title)
try container.encodeIfPresent(feedback, forKey: .feedback) try container.encodeIfPresent(feedback, forKey: .feedback)
try container.encodeIfPresent(text, forKey: .text) try container.encodeIfPresent(text, forKey: .text)

View File

@ -120,12 +120,10 @@ open class ItemDropdownEntryField: BaseDropdownEntryField {
// MARK:- Base Picker Delegate // MARK:- Base Picker Delegate
extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource { extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource {
@objc public func numberOfComponents(in pickerView: UIPickerView) -> Int { @objc public func numberOfComponents(in pickerView: UIPickerView) -> Int { 1 }
return 1
}
@objc public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { @objc public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerData.count pickerData.count
} }
@objc public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { @objc public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {

View File

@ -11,7 +11,5 @@
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String { "mdnEntryField" }
return "mdnEntryField"
}
} }

View File

@ -54,9 +54,7 @@ import UIKit
/// Validate when user resigns editing. Default: true /// Validate when user resigns editing. Default: true
public var validateWhenDoneEditing: Bool = true public var validateWhenDoneEditing: Bool = true
public var textEntryFieldModel: TextEntryFieldModel? { public var textEntryFieldModel: TextEntryFieldModel? { model as? TextEntryFieldModel }
return model as? TextEntryFieldModel
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Computed Properties // MARK: - Computed Properties
@ -96,7 +94,7 @@ import UIKit
/// The text of this TextField. /// The text of this TextField.
open override var text: String? { open override var text: String? {
get { return textField.text } get { textField.text }
set { set {
textField.text = newValue textField.text = newValue
textEntryFieldModel?.text = newValue textEntryFieldModel?.text = newValue
@ -105,7 +103,7 @@ import UIKit
/// Placeholder access for the TextField. /// Placeholder access for the TextField.
public var placeholder: String? { public var placeholder: String? {
get { return textField.placeholder } get { textField.placeholder }
set { textField.placeholder = newValue } set { textField.placeholder = newValue }
} }
@ -133,7 +131,7 @@ import UIKit
/// If you're using a ViewController, you must set this to it /// If you're using a ViewController, you must set this to it
public weak var uiTextFieldDelegate: UITextFieldDelegate? { public weak var uiTextFieldDelegate: UITextFieldDelegate? {
get { return textField.delegate } get { textField.delegate }
set { textField.delegate = newValue } set { textField.delegate = newValue }
} }
@ -330,6 +328,7 @@ import UIKit
break break
} }
textField.accessibilityIdentifier = model.accessibilityIdentifier
uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate
observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate
setupTextFieldToolbar() setupTextFieldToolbar()

View File

@ -25,9 +25,7 @@
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public override class var identifier: String { public override class var identifier: String { "textField" }
return "textField"
}
public var placeholder: String? public var placeholder: String?
public var enabledTextColor: Color = Color(uiColor: .mvmBlack) public var enabledTextColor: Color = Color(uiColor: .mvmBlack)