Merge branch 'develop' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui.git into feature/monarch
This commit is contained in:
commit
f71d991b9d
@ -45,6 +45,7 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{
|
|||||||
} else if let percentage = viewModel.textPercentage {
|
} else if let percentage = viewModel.textPercentage {
|
||||||
textWidth = .percentage(percentage)
|
textWidth = .percentage(percentage)
|
||||||
}
|
}
|
||||||
|
eyebrowModel = viewModel.eyebrowModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData)
|
titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData)
|
subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
badgeModel = viewModel.badge
|
badgeModel = viewModel.badge
|
||||||
|
|||||||
@ -19,6 +19,7 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
|||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var badge: Tilelet.BadgeModel?
|
public var badge: Tilelet.BadgeModel?
|
||||||
|
public var eyebrow: LabelModel?
|
||||||
public var title: LabelModel?
|
public var title: LabelModel?
|
||||||
public var subTitle: LabelModel?
|
public var subTitle: LabelModel?
|
||||||
public var descriptiveIcon: Tilelet.DescriptiveIcon?
|
public var descriptiveIcon: Tilelet.DescriptiveIcon?
|
||||||
@ -30,6 +31,7 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
|||||||
case id
|
case id
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case badge
|
case badge
|
||||||
|
case eyebrow
|
||||||
case title
|
case title
|
||||||
case subTitle
|
case subTitle
|
||||||
case descriptiveIcon
|
case descriptiveIcon
|
||||||
@ -41,6 +43,7 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
|||||||
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
|
||||||
badge = try container.decodeIfPresent(Tilelet.BadgeModel.self, forKey: .badge)
|
badge = try container.decodeIfPresent(Tilelet.BadgeModel.self, forKey: .badge)
|
||||||
|
eyebrow = try container.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
||||||
title = try container.decodeIfPresent(LabelModel.self, forKey: .title)
|
title = try container.decodeIfPresent(LabelModel.self, forKey: .title)
|
||||||
subTitle = try container.decodeIfPresent(LabelModel.self, forKey: .subTitle)
|
subTitle = try container.decodeIfPresent(LabelModel.self, forKey: .subTitle)
|
||||||
descriptiveIcon = try container.decodeIfPresent(Tilelet.DescriptiveIcon.self, forKey: .descriptiveIcon)
|
descriptiveIcon = try container.decodeIfPresent(Tilelet.DescriptiveIcon.self, forKey: .descriptiveIcon)
|
||||||
@ -50,13 +53,43 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
|||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func eyebrowModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.EyebrowModel? {
|
||||||
|
guard let eyebrow else { return nil }
|
||||||
|
|
||||||
|
var eyebrowColor: TitleLockup.TextColor = .primary
|
||||||
|
if let color = eyebrow.textColor?.uiColor {
|
||||||
|
eyebrowColor = .custom(color, color)
|
||||||
|
}
|
||||||
|
|
||||||
|
let attrs = eyebrow.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
do {
|
||||||
|
if let style = eyebrow.fontStyle {
|
||||||
|
return .init(text: eyebrow.text,
|
||||||
|
textColor: eyebrowColor,
|
||||||
|
textAttributes: attrs, isBold: style.isBold(),
|
||||||
|
standardStyle: try style.vdsSubsetStyle())
|
||||||
|
}
|
||||||
|
} catch MVMCoreError.errorObject(let object) {
|
||||||
|
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||||
|
} catch { }
|
||||||
|
|
||||||
|
return .init(text: eyebrow.text, textColor: eyebrowColor, textAttributes: attrs)
|
||||||
|
}
|
||||||
|
|
||||||
public func titleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.TitleModel? {
|
public func titleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.TitleModel? {
|
||||||
guard let title else { return nil }
|
guard let title else { return nil }
|
||||||
|
|
||||||
|
var titleColor: TitleLockup.TitleTextColor = .primary
|
||||||
|
if let color = title.textColor?.uiColor {
|
||||||
|
titleColor = .custom(color, color)
|
||||||
|
}
|
||||||
|
|
||||||
let attrs = title.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
let attrs = title.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if let style = title.fontStyle {
|
if let style = title.fontStyle {
|
||||||
return .init(text: title.text,
|
return .init(text: title.text,
|
||||||
|
textColor: titleColor,
|
||||||
textAttributes: attrs,
|
textAttributes: attrs,
|
||||||
standardStyle: try style.vdsSubsetStyle())
|
standardStyle: try style.vdsSubsetStyle())
|
||||||
}
|
}
|
||||||
@ -65,23 +98,30 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
|||||||
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
return .init(text: title.text, textAttributes: attrs)
|
return .init(text: title.text, textColor: titleColor, textAttributes: attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func subTitleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.SubTitleModel? {
|
public func subTitleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.SubTitleModel? {
|
||||||
guard let subTitle else { return nil }
|
guard let subTitle else { return nil }
|
||||||
|
|
||||||
|
var subTitleColor: TitleLockup.TextColor = .primary
|
||||||
|
if let color = subTitle.textColor?.uiColor {
|
||||||
|
subTitleColor = .custom(color, color)
|
||||||
|
}
|
||||||
|
|
||||||
let attrs = subTitle.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
let attrs = subTitle.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
do {
|
do {
|
||||||
if let style = subTitle.fontStyle {
|
if let style = subTitle.fontStyle {
|
||||||
return .init(text: subTitle.text,
|
return .init(text: subTitle.text,
|
||||||
otherStandardStyle: try style.vdsSubsetStyle(),
|
otherStandardStyle: try style.vdsSubsetStyle(),
|
||||||
|
textColor: subTitleColor,
|
||||||
textAttributes: attrs)
|
textAttributes: attrs)
|
||||||
}
|
}
|
||||||
} catch MVMCoreError.errorObject(let object) {
|
} catch MVMCoreError.errorObject(let object) {
|
||||||
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
return .init(text: subTitle.text, textAttributes: attrs)
|
return .init(text: subTitle.text, textColor: subTitleColor, textAttributes: attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
@ -89,8 +129,9 @@ open class TileletModel: TileContainerBaseModel<Tilelet.Padding, Tilelet>, Molec
|
|||||||
try container.encode(id, forKey: .id)
|
try container.encode(id, forKey: .id)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(badge, forKey: .badge)
|
try container.encodeIfPresent(badge, forKey: .badge)
|
||||||
try container.encodeIfPresent(title, forKey: .title)
|
try container.encodeModelIfPresent(eyebrow, forKey: .eyebrow)
|
||||||
try container.encodeIfPresent(subTitle, forKey: .subTitle)
|
try container.encodeModelIfPresent(title, forKey: .title)
|
||||||
|
try container.encodeModelIfPresent(subTitle, forKey: .subTitle)
|
||||||
try container.encodeIfPresent(descriptiveIcon, forKey: .descriptiveIcon)
|
try container.encodeIfPresent(descriptiveIcon, forKey: .descriptiveIcon)
|
||||||
try container.encodeIfPresent(directionalIcon, forKey: .directionalIcon)
|
try container.encodeIfPresent(directionalIcon, forKey: .directionalIcon)
|
||||||
try container.encodeIfPresent(textWidth, forKey: .textWidth)
|
try container.encodeIfPresent(textWidth, forKey: .textWidth)
|
||||||
|
|||||||
@ -75,7 +75,7 @@ extension VDS.TileContainerBase.BackgroundColor: Codable {
|
|||||||
var container = encoder.singleValueContainer()
|
var container = encoder.singleValueContainer()
|
||||||
switch self {
|
switch self {
|
||||||
case .custom(let value):
|
case .custom(let value):
|
||||||
try container.encode(value)
|
try container.encode(Color(uiColor: value))
|
||||||
default:
|
default:
|
||||||
try container.encode(String(reflecting: self))
|
try container.encode(String(reflecting: self))
|
||||||
}
|
}
|
||||||
@ -96,9 +96,9 @@ extension VDS.TileContainerBase.BackgroundColor: Codable {
|
|||||||
self = .black
|
self = .black
|
||||||
default:
|
default:
|
||||||
if let color = try? Color(from: decoder) {
|
if let color = try? Color(from: decoder) {
|
||||||
self = .custom(color.hex)
|
self = .custom(color.uiColor)
|
||||||
} else {
|
} else {
|
||||||
self = .custom(type)
|
self = .custom(UIColor(hexString: type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,9 +128,9 @@ extension VDS.TileContainerBase.BackgroundEffect: Codable {
|
|||||||
case .none:
|
case .none:
|
||||||
self = .none
|
self = .none
|
||||||
case .gradient:
|
case .gradient:
|
||||||
let firstColor = try container.decode(String.self, forKey: .firstColor)
|
let firstColor = try container.decode(Color.self, forKey: .firstColor)
|
||||||
let secondColor = try container.decode(String.self, forKey: .secondColor)
|
let secondColor = try container.decode(Color.self, forKey: .secondColor)
|
||||||
self = .gradient(firstColor, secondColor)
|
self = .gradient(firstColor.uiColor, secondColor.uiColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,8 +143,8 @@ extension VDS.TileContainerBase.BackgroundEffect: Codable {
|
|||||||
try container.encode(BackgroundEffectType.none.rawValue, forKey: .type)
|
try container.encode(BackgroundEffectType.none.rawValue, forKey: .type)
|
||||||
case .gradient(let firstColor, let secondColor):
|
case .gradient(let firstColor, let secondColor):
|
||||||
try container.encode(BackgroundEffectType.gradient.rawValue, forKey: .type)
|
try container.encode(BackgroundEffectType.gradient.rawValue, forKey: .type)
|
||||||
try container.encode(firstColor, forKey: .firstColor)
|
try container.encode(Color(uiColor: firstColor), forKey: .firstColor)
|
||||||
try container.encode(secondColor, forKey: .secondColor)
|
try container.encode(Color(uiColor: secondColor), forKey: .secondColor)
|
||||||
@unknown default:
|
@unknown default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
public var eyebrow: LabelModel?
|
public var eyebrow: LabelModel?
|
||||||
public var title: LabelModel
|
public var title: LabelModel
|
||||||
public var subTitle: LabelModel?
|
public var subTitle: LabelModel?
|
||||||
public var subTitleColor: Use = .primary
|
|
||||||
|
|
||||||
public var alignment: VDS.TitleLockup.TextAlignment = .left
|
public var alignment: VDS.TitleLockup.TextAlignment = .left
|
||||||
public var inverted: Bool = false
|
public var inverted: Bool = false
|
||||||
@ -61,7 +60,6 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
case eyebrow
|
case eyebrow
|
||||||
case title
|
case title
|
||||||
case subTitle
|
case subTitle
|
||||||
case subTitleColor
|
|
||||||
case inverted
|
case inverted
|
||||||
case alignment
|
case alignment
|
||||||
}
|
}
|
||||||
@ -78,17 +76,6 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow)
|
||||||
subTitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subTitle)
|
subTitle = try typeContainer.decodeMoleculeIfPresent(codingKey: .subTitle)
|
||||||
|
|
||||||
/// look for color hex code
|
|
||||||
if let color = try? typeContainer.decodeIfPresent(Color.self, forKey: .subTitleColor) {
|
|
||||||
self.subTitleColor = color.uiColor.isDark() ? .primary : .secondary
|
|
||||||
|
|
||||||
} else if let subTitleColor = try? typeContainer.decodeIfPresent(Use.self, forKey: .subTitleColor) {
|
|
||||||
self.subTitleColor = subTitleColor
|
|
||||||
|
|
||||||
} else {
|
|
||||||
subTitleColor = .primary
|
|
||||||
}
|
|
||||||
|
|
||||||
if let newAlignment = try typeContainer.decodeIfPresent(VDS.TitleLockup.TextAlignment.self, forKey: .alignment) {
|
if let newAlignment = try typeContainer.decodeIfPresent(VDS.TitleLockup.TextAlignment.self, forKey: .alignment) {
|
||||||
alignment = newAlignment
|
alignment = newAlignment
|
||||||
}
|
}
|
||||||
@ -109,17 +96,23 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
|
try container.encodeIfPresent(eyebrow, forKey: .eyebrow)
|
||||||
try container.encodeModel(title, forKey: .title)
|
try container.encodeModel(title, forKey: .title)
|
||||||
try container.encodeIfPresent(subTitle, forKey: .subTitle)
|
try container.encodeIfPresent(subTitle, forKey: .subTitle)
|
||||||
try container.encode(subTitleColor, forKey: .subTitleColor)
|
|
||||||
try container.encode(alignment, forKey: .alignment)
|
try container.encode(alignment, forKey: .alignment)
|
||||||
try container.encode(inverted, forKey: .inverted)
|
try container.encode(inverted, forKey: .inverted)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func eyebrowModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.EyebrowModel? {
|
public func eyebrowModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.EyebrowModel? {
|
||||||
guard let eyebrow else { return nil }
|
guard let eyebrow else { return nil }
|
||||||
|
|
||||||
|
var eyebrowColor: TitleLockup.TextColor = .primary
|
||||||
|
if let color = eyebrow.textColor?.uiColor {
|
||||||
|
eyebrowColor = .custom(color, color)
|
||||||
|
}
|
||||||
|
|
||||||
let attrs = eyebrow.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
let attrs = eyebrow.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
do {
|
do {
|
||||||
if let style = eyebrow.fontStyle {
|
if let style = eyebrow.fontStyle {
|
||||||
return .init(text: eyebrow.text,
|
return .init(text: eyebrow.text,
|
||||||
|
textColor: eyebrowColor,
|
||||||
isBold: style.isBold(),
|
isBold: style.isBold(),
|
||||||
standardStyle: try style.vdsSubsetStyle(),
|
standardStyle: try style.vdsSubsetStyle(),
|
||||||
textAttributes: attrs,
|
textAttributes: attrs,
|
||||||
@ -129,14 +122,21 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
return .init(text: eyebrow.text, textAttributes: attrs, numberOfLines: eyebrow.numberOfLines ?? 0)
|
return .init(text: eyebrow.text, textColor: eyebrowColor, textAttributes: attrs, numberOfLines: eyebrow.numberOfLines ?? 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func titleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.TitleModel {
|
public func titleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.TitleModel {
|
||||||
|
|
||||||
|
var titleColor: TitleLockup.TitleTextColor = .primary
|
||||||
|
if let color = title.textColor?.uiColor {
|
||||||
|
titleColor = .custom(color, color)
|
||||||
|
}
|
||||||
|
|
||||||
let attrs = title.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
let attrs = title.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
do {
|
do {
|
||||||
if let style = title.fontStyle {
|
if let style = title.fontStyle {
|
||||||
return .init(text: title.text,
|
return .init(text: title.text,
|
||||||
|
textColor: titleColor,
|
||||||
textAttributes: attrs,
|
textAttributes: attrs,
|
||||||
isBold: style.isBold(),
|
isBold: style.isBold(),
|
||||||
standardStyle: try style.vdsSubsetStyle(),
|
standardStyle: try style.vdsSubsetStyle(),
|
||||||
@ -147,11 +147,17 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
return .init(text: title.text, textAttributes: attrs, numberOfLines: title.numberOfLines ?? 0)
|
return .init(text: title.text, textColor: titleColor, textAttributes: attrs, numberOfLines: title.numberOfLines ?? 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func subTitleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.SubTitleModel? {
|
public func subTitleModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> VDS.TitleLockup.SubTitleModel? {
|
||||||
guard let subTitle else { return nil }
|
guard let subTitle else { return nil }
|
||||||
|
|
||||||
|
var subTitleColor: TitleLockup.TextColor = .primary
|
||||||
|
if let color = subTitle.textColor?.uiColor {
|
||||||
|
subTitleColor = .custom(color, color)
|
||||||
|
}
|
||||||
|
|
||||||
let attrs = subTitle.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
let attrs = subTitle.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|||||||
@ -86,11 +86,14 @@ public final class Color: Codable {
|
|||||||
let colorString = try container.decode(String.self)
|
let colorString = try container.decode(String.self)
|
||||||
|
|
||||||
if let vdsColor = UIColor.VDSColor(rawValue: colorString) {
|
if let vdsColor = UIColor.VDSColor(rawValue: colorString) {
|
||||||
self.uiColor = vdsColor.uiColor
|
uiColor = vdsColor.uiColor
|
||||||
hex = uiColor.hexString ?? ""
|
hex = uiColor.hexString ?? ""
|
||||||
|
} else if let color = Color(name: colorString) {
|
||||||
|
uiColor = color.uiColor
|
||||||
|
hex = color.hex
|
||||||
} else {
|
} else {
|
||||||
let components = try Color.getColorComponents(for: colorString)
|
let components = try Color.getColorComponents(for: colorString)
|
||||||
self.uiColor = components.color
|
uiColor = components.color
|
||||||
hex = components.hex
|
hex = components.hex
|
||||||
name = components.name ?? ""
|
name = components.name ?? ""
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user