updated model
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
5c8907b4a9
commit
908c3bddc3
@ -18,14 +18,15 @@ extension Styler.Font {
|
|||||||
return style
|
return style
|
||||||
}
|
}
|
||||||
|
|
||||||
public func vdsSubsetStyle<T: EnumSubset>() -> T? {
|
public func vdsSubsetStyle<T: EnumSubset>() throws -> T {
|
||||||
guard let style = vdsTextStyle() else { return nil }
|
guard let style = vdsTextStyle(), let rawValue = style.toStandardStyle().rawValue as? T.RawValue, let standardStyle = T(rawValue: rawValue) else {
|
||||||
guard let rawValue = style.rawValue as? T.RawValue,
|
let err = "\(rawValue) was not found in the \(T.self), only these cases exist:\r\(T.allCases)"
|
||||||
let found = T(rawValue: rawValue) else {
|
throw MVMCoreError.errorObject(MVMCoreErrorObject(title: "\(T.self) conversion Issue",
|
||||||
print("Style: \(style.rawValue) is not in enum \(T.self)\ronly these cases exist:\r\(T.allCases)")
|
messageToLog: err,
|
||||||
return nil
|
code: 999,
|
||||||
|
domain: ErrorDomainNative,
|
||||||
|
location: #file)!)
|
||||||
}
|
}
|
||||||
return found
|
return standardStyle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,38 +90,59 @@ public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtoco
|
|||||||
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 }
|
||||||
let attrs = eyebrow.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
let attrs = eyebrow.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
let style: TextStyle? = eyebrow.fontStyle?.vdsTextStyle()
|
do {
|
||||||
if let style, let standardStyle = VDS.TitleLockup.OtherStandardStyle(rawValue: style.toStandardStyle().rawValue) {
|
if let style = eyebrow.fontStyle {
|
||||||
return .init(text: eyebrow.text, isBold: style.isBold, standardStyle: standardStyle, textAttributes: attrs, numberOfLines: eyebrow.numberOfLines ?? 0)
|
return .init(text: eyebrow.text,
|
||||||
} else {
|
isBold: style.isBold(),
|
||||||
return .init(text: eyebrow.text, textAttributes: attrs, numberOfLines: eyebrow.numberOfLines ?? 0)
|
standardStyle: try style.vdsSubsetStyle(),
|
||||||
}
|
textAttributes: attrs,
|
||||||
|
numberOfLines: eyebrow.numberOfLines ?? 0)
|
||||||
|
}
|
||||||
|
} catch MVMCoreError.errorObject(let object) {
|
||||||
|
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||||
|
} catch { }
|
||||||
|
|
||||||
|
return .init(text: eyebrow.text, 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 {
|
||||||
let attrs = title.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
let attrs = title.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
let style: TextStyle? = title.fontStyle?.vdsTextStyle()
|
do {
|
||||||
if let style, let standardStyle = VDS.TitleLockup.TitleStandardStyle(rawValue: style.toStandardStyle().rawValue) {
|
if let style = title.fontStyle {
|
||||||
return .init(text: title.text, textAttributes: attrs, isBold: style.isBold, standardStyle: standardStyle, numberOfLines: title.numberOfLines ?? 0)
|
return .init(text: title.text,
|
||||||
} else {
|
textAttributes: attrs,
|
||||||
return .init(text: title.text, textAttributes: attrs, numberOfLines: title.numberOfLines ?? 0)
|
isBold: style.isBold(),
|
||||||
}
|
standardStyle: try style.vdsSubsetStyle(),
|
||||||
|
numberOfLines: title.numberOfLines ?? 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch MVMCoreError.errorObject(let object) {
|
||||||
|
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||||
|
} catch { }
|
||||||
|
|
||||||
|
return .init(text: title.text, 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 }
|
||||||
let attrs = subTitle.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
let attrs = subTitle.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||||
let style: TextStyle? = subTitle.fontStyle?.vdsTextStyle()
|
|
||||||
if let style, let standardStyle = VDS.TitleLockup.OtherStandardStyle(rawValue: style.toStandardStyle().rawValue) {
|
do {
|
||||||
return .init(text: subTitle.text, standardStyle: standardStyle, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0)
|
if let style = subTitle.fontStyle {
|
||||||
} else {
|
return .init(text: subTitle.text,
|
||||||
return .init(text: subTitle.text, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0)
|
standardStyle: try style.vdsSubsetStyle(),
|
||||||
}
|
textAttributes: attrs,
|
||||||
|
numberOfLines: subTitle.numberOfLines ?? 0)
|
||||||
|
}
|
||||||
|
} catch MVMCoreError.errorObject(let object) {
|
||||||
|
MVMCoreLoggingHandler.shared()?.addError(toLog: object)
|
||||||
|
} catch { }
|
||||||
|
|
||||||
|
return .init(text: subTitle.text, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extension TitleLockupModel {
|
extension TitleLockupModel {
|
||||||
public var surface: Surface { inverted ? .dark : .light }
|
public var surface: Surface { inverted ? .dark : .light }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user