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 */ = {
isa = PBXGroup;
children = (
0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */,
0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */,
0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */,
0A21DB7E235DECC500C160A2 /* EntryField.swift */,
0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */,
0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */,
0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */,
0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */,
0A8321AE2355FE9500CB7F00 /* DigitBox.swift */,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -120,12 +120,10 @@ open class ItemDropdownEntryField: BaseDropdownEntryField {
// MARK:- Base Picker Delegate
extension ItemDropdownEntryField: UIPickerViewDelegate, UIPickerViewDataSource {
@objc public func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
@objc public func numberOfComponents(in pickerView: UIPickerView) -> Int { 1 }
@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? {

View File

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

View File

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

View File

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