This commit is contained in:
Kevin G Christiano 2020-01-24 12:33:22 -05:00
parent 7019bdaa78
commit e5948e05e5
4 changed files with 28 additions and 3 deletions

View File

@ -72,7 +72,9 @@ import UIKit
public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData) super.setWithModel(model, delegateObject, additionalData)
dropDownCaretView.setWithModel(model, delegateObject, additionalData) guard let model = model as? BaseDropdownEntryFieldModel else { return }
dropDownCaretView.setWithModel(model.caretView, delegateObject, additionalData)
} }
} }

View File

@ -7,20 +7,39 @@
// //
@objcMembers public class BaseDropdownEntryFieldModel: TextEntryFieldModel { @objcMembers public class BaseDropdownEntryFieldModel: TextEntryFieldModel {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public var caretView: CaretViewModel?
public override class var identifier: String { public override class var identifier: String {
return "" return ""
} }
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case caretView
}
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
try super.init(from: decoder) try super.init(from: decoder)
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
caretView = try typeContainer.decodeIfPresent(CaretViewModel.self, forKey: .caretView)
} }
public override func encode(to encoder: Encoder) throws { public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder) try super.encode(to: encoder)
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(caretView, forKey: .caretView)
} }
} }

View File

@ -116,7 +116,7 @@ import UIKit
guard let model = model as? DateDropdownEntryFieldModel else { return } guard let model = model as? DateDropdownEntryFieldModel else { return }
self.dateFormat = model.dateFormat dateFormat = model.dateFormat
} }
} }

View File

@ -19,6 +19,7 @@ import Foundation
} }
public var backgroundColor: Color? public var backgroundColor: Color?
public var moleculeName: 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 = ""
@ -34,6 +35,7 @@ import Foundation
//-------------------------------------------------- //--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName
case backgroundColor case backgroundColor
case title case title
case isEnabled case isEnabled
@ -52,6 +54,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)
moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
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)
@ -65,6 +68,7 @@ import Foundation
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(title, forKey: .title)
try container.encodeIfPresent(feedback, forKey: .feedback) try container.encodeIfPresent(feedback, forKey: .feedback)