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