fixes for decoding
This commit is contained in:
parent
abbe26b4bd
commit
51b327a6d6
@ -134,7 +134,11 @@ import Foundation
|
|||||||
|
|
||||||
// Other Molecules
|
// Other Molecules
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: DoughnutChartView.self, viewModelClass: DoughnutChartModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: DoughnutChartView.self, viewModelClass: DoughnutChartModel.self)
|
||||||
|
|
||||||
|
// Navigation Molecules
|
||||||
try? ModelRegistry.register(NavigationItemModel.self)
|
try? ModelRegistry.register(NavigationItemModel.self)
|
||||||
|
try? ModelRegistry.register(NavigationImageButtonModel.self)
|
||||||
|
try? ModelRegistry.register(NavigationLabelButtonModel.self)
|
||||||
|
|
||||||
// Other Organisms
|
// Other Organisms
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: Carousel.self, viewModelClass: CarouselModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: Carousel.self, viewModelClass: CarouselModel.self)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// NavigationButtomModelProtocol.swift
|
// NavigationButtonModelProtocol.swift
|
||||||
// MVMCoreUI
|
// MVMCoreUI
|
||||||
//
|
//
|
||||||
// Created by Scott Pfeil on 5/27/20.
|
// Created by Scott Pfeil on 5/27/20.
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public protocol NavigationButtomModelProtocol: ButtonModelProtocol {
|
public protocol NavigationButtonModelProtocol: ButtonModelProtocol {
|
||||||
//var color: Color? { get set }
|
//var color: Color? { get set }
|
||||||
|
|
||||||
func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> BarButtonItem
|
func createNavigationItemButton(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> BarButtonItem
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public class NavigationImageButtonModel: NavigationButtomModelProtocol, MoleculeModelProtocol {
|
public class NavigationImageButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol {
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public static var identifier: String = "navigationImageButton"
|
public static var identifier: String = "navigationImageButton"
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public class NavigationLabelButtonModel: NavigationButtomModelProtocol, MoleculeModelProtocol {
|
public class NavigationLabelButtonModel: NavigationButtonModelProtocol, MoleculeModelProtocol {
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public static var identifier: String = "navigationLabelButton"
|
public static var identifier: String = "navigationLabelButton"
|
||||||
|
|
||||||
|
|||||||
@ -18,16 +18,15 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
|||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var tintColor: Color
|
public var tintColor: Color
|
||||||
public var line: LineModel?
|
public var line: LineModel?
|
||||||
public var backButton: (NavigationButtomModelProtocol & MoleculeModelProtocol)?
|
public var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? = NavigationImageButtonModel(with: "back", action: ActionBackModel())
|
||||||
public var additionalLeftButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]?
|
public var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]?
|
||||||
public var additionalRightButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]?
|
public var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]?
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
hidden = false
|
hidden = false
|
||||||
backgroundColor = Color(uiColor: .white)
|
backgroundColor = Color(uiColor: .white)
|
||||||
tintColor = Color(uiColor: .black)
|
tintColor = Color(uiColor: .black)
|
||||||
line = LineModel(type: .standard)
|
line = LineModel(type: .standard)
|
||||||
backButton = NavigationImageButtonModel(with: "back", action: ActionBackModel())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
@ -50,9 +49,11 @@ public class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProt
|
|||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .white)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) ?? Color(uiColor: .white)
|
||||||
tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black)
|
tintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .tintColor) ?? Color(uiColor: .black)
|
||||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
||||||
backButton = try typeContainer.decodeModelIfPresent(codingKey: .backButton) ?? NavigationImageButtonModel(with: "back", action: ActionBackModel())
|
if let backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol) = try typeContainer.decodeModelIfPresent(codingKey: .backButton) {
|
||||||
additionalLeftButtons = try typeContainer.decodeModels(codingKey: .additionalLeftButtons)
|
self.backButton = backButton
|
||||||
additionalRightButtons = try typeContainer.decodeModels(codingKey: .additionalRightButtons)
|
}
|
||||||
|
additionalLeftButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalLeftButtons)
|
||||||
|
additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons)
|
||||||
}
|
}
|
||||||
|
|
||||||
open func encode(to encoder: Encoder) throws {
|
open func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public protocol NavigationItemModelProtocol {
|
|||||||
var backgroundColor: Color? { get set }
|
var backgroundColor: Color? { get set }
|
||||||
var tintColor: Color { get set }
|
var tintColor: Color { get set }
|
||||||
var line: LineModel? { get set }
|
var line: LineModel? { get set }
|
||||||
var backButton: (NavigationButtomModelProtocol & MoleculeModelProtocol)? { get set }
|
var backButton: (NavigationButtonModelProtocol & MoleculeModelProtocol)? { get set }
|
||||||
var additionalLeftButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? { get set }
|
var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set }
|
||||||
var additionalRightButtons: [(NavigationButtomModelProtocol & MoleculeModelProtocol)]? { get set }
|
var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? { get set }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user