background color
This commit is contained in:
parent
2bc0282410
commit
565c01148c
@ -12,5 +12,6 @@ public protocol PageModelProtocol {
|
||||
var pageType: String { get set }
|
||||
/// Temporary: for legacy response
|
||||
var screenHeading: String? { get set }
|
||||
var backgroundColor: Color? { get set }
|
||||
var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set }
|
||||
}
|
||||
|
||||
@ -22,5 +22,8 @@ public extension TemplateProtocol where Self: ViewController {
|
||||
let templateModel = try decoder.decode(TemplateModel.self, from: data)
|
||||
self.templateModel = templateModel
|
||||
self.pageModel = templateModel as? MVMControllerModelProtocol
|
||||
if let backgroundColor = templateModel.backgroundColor {
|
||||
view.backgroundColor = backgroundColor.uiColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import Foundation
|
||||
// Although this is done in the extension, it is needed for the encoding.
|
||||
return Self.identifier
|
||||
}
|
||||
public var backgroundColor: Color?
|
||||
public var screenHeading: String?
|
||||
public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)?
|
||||
public var formRules: [FormGroupRule]?
|
||||
@ -29,6 +30,7 @@ import Foundation
|
||||
case pageType
|
||||
case template
|
||||
case screenHeading
|
||||
case backgroundColor
|
||||
case formRules
|
||||
case navigationItem
|
||||
}
|
||||
@ -37,6 +39,7 @@ import Foundation
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
||||
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules)
|
||||
navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem)
|
||||
}
|
||||
@ -45,6 +48,7 @@ import Foundation
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(pageType, forKey: .pageType)
|
||||
try container.encode(template, forKey: .template)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
|
||||
try container.encodeIfPresent(formRules, forKey: .formRules)
|
||||
try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user