Merge branch 'feature/monarch' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/monarch
This commit is contained in:
commit
58c462c15e
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import VDS
|
import VDS
|
||||||
|
import MVMCore
|
||||||
|
|
||||||
open class TileContainerModel: TileContainerBaseModel<TileContainer.Padding, TileContainer>, ParentMoleculeModelProtocol, MoleculeModelProtocol {
|
open class TileContainerModel: TileContainerBaseModel<TileContainer.Padding, TileContainer>, ParentMoleculeModelProtocol, MoleculeModelProtocol {
|
||||||
|
|
||||||
@ -33,10 +34,11 @@ open class TileContainerModel: TileContainerBaseModel<TileContainer.Padding, Til
|
|||||||
case moleculeName
|
case moleculeName
|
||||||
case molecule
|
case molecule
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
molecule = try container.decodeModelIfPresent(codingKey: .molecule)
|
molecule = try container.decodeMoleculeIfPresent(codingKey: .molecule)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +85,7 @@ open class TileContainerBaseModel<PaddingType: DefaultValuing & Codable, TileCon
|
|||||||
case aspectRatio
|
case aspectRatio
|
||||||
case backgroundEffect
|
case backgroundEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
inverted = try container.decodeIfPresent(Bool.self, forKey: .inverted) ?? false
|
inverted = try container.decodeIfPresent(Bool.self, forKey: .inverted) ?? false
|
||||||
@ -97,7 +100,6 @@ open class TileContainerBaseModel<PaddingType: DefaultValuing & Codable, TileCon
|
|||||||
color = try container.decodeIfPresent(TileContainerType.BackgroundColor.self, forKey: .color) ?? .black
|
color = try container.decodeIfPresent(TileContainerType.BackgroundColor.self, forKey: .color) ?? .black
|
||||||
aspectRatio = try container.decodeIfPresent(TileContainerType.AspectRatio.self, forKey: .aspectRatio) ?? .ratio1x1
|
aspectRatio = try container.decodeIfPresent(TileContainerType.AspectRatio.self, forKey: .aspectRatio) ?? .ratio1x1
|
||||||
backgroundEffect = try container.decodeIfPresent(TileContainerType.BackgroundEffect.self, forKey: .backgroundEffect) ?? .none
|
backgroundEffect = try container.decodeIfPresent(TileContainerType.BackgroundEffect.self, forKey: .backgroundEffect) ?? .none
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -95,7 +95,11 @@ extension VDS.TileContainerBase.BackgroundColor: Codable {
|
|||||||
case "black":
|
case "black":
|
||||||
self = .black
|
self = .black
|
||||||
default:
|
default:
|
||||||
self = .custom(type)
|
if let color = try? Color(from: decoder) {
|
||||||
|
self = .custom(color.hex)
|
||||||
|
} else {
|
||||||
|
self = .custom(type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ public struct DeprecatedHeadlineBodyHelper {
|
|||||||
|
|
||||||
public func createTitleLockupModel(defaultStyle: HeadlineBodyModel.Style = .header, headlineBody: HeadlineBodyModel) throws -> TitleLockupModel {
|
public func createTitleLockupModel(defaultStyle: HeadlineBodyModel.Style = .header, headlineBody: HeadlineBodyModel) throws -> TitleLockupModel {
|
||||||
guard let headline = headlineBody.headline else { throw ModelRegistry.Error.decoderOther(message: "headline is required for this use case.") }
|
guard let headline = headlineBody.headline else { throw ModelRegistry.Error.decoderOther(message: "headline is required for this use case.") }
|
||||||
var body = headlineBody.body
|
let body = headlineBody.body
|
||||||
switch headlineBody.style ?? defaultStyle {
|
switch headlineBody.style ?? defaultStyle {
|
||||||
case .landingHeader:
|
case .landingHeader:
|
||||||
headline.fontStyle = Styler.Font.RegularTitle2XLarge
|
headline.fontStyle = Styler.Font.RegularTitle2XLarge
|
||||||
@ -103,13 +103,13 @@ public struct DeprecatedHeadlineBodyHelper {
|
|||||||
headline.fontStyle = Styler.Font.RegularTitleXLarge
|
headline.fontStyle = Styler.Font.RegularTitleXLarge
|
||||||
body?.fontStyle = Styler.Font.RegularTitleMedium
|
body?.fontStyle = Styler.Font.RegularTitleMedium
|
||||||
}
|
}
|
||||||
let model = try TitleLockupModel(title: headline, subTitle: body)
|
let model = TitleLockupModel(title: headline, subTitle: body)
|
||||||
model.id = headlineBody.id
|
model.id = headlineBody.id
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
|
|
||||||
public func createHeadlineBodyModel(titleLockup: TitleLockupModel) -> HeadlineBodyModel {
|
public func createHeadlineBodyModel(titleLockup: TitleLockupModel) -> HeadlineBodyModel {
|
||||||
var headlineBody = HeadlineBodyModel(headline: titleLockup.title)
|
let headlineBody = HeadlineBodyModel(headline: titleLockup.title)
|
||||||
headlineBody.body = titleLockup.subTitle
|
headlineBody.body = titleLockup.subTitle
|
||||||
headlineBody.id = titleLockup.id
|
headlineBody.id = titleLockup.id
|
||||||
return headlineBody
|
return headlineBody
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user