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
|
||||
}
|
||||
|
||||
public func vdsSubsetStyle<T: EnumSubset>() -> T? {
|
||||
guard let style = vdsTextStyle() else { return nil }
|
||||
guard let rawValue = style.rawValue as? T.RawValue,
|
||||
let found = T(rawValue: rawValue) else {
|
||||
print("Style: \(style.rawValue) is not in enum \(T.self)\ronly these cases exist:\r\(T.allCases)")
|
||||
return nil
|
||||
public func vdsSubsetStyle<T: EnumSubset>() throws -> T {
|
||||
guard let style = vdsTextStyle(), let rawValue = style.toStandardStyle().rawValue as? T.RawValue, let standardStyle = T(rawValue: rawValue) else {
|
||||
let err = "\(rawValue) was not found in the \(T.self), only these cases exist:\r\(T.allCases)"
|
||||
throw MVMCoreError.errorObject(MVMCoreErrorObject(title: "\(T.self) conversion Issue",
|
||||
messageToLog: err,
|
||||
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? {
|
||||
guard let eyebrow else { return nil }
|
||||
let attrs = eyebrow.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData)
|
||||
let style: TextStyle? = eyebrow.fontStyle?.vdsTextStyle()
|
||||
if let style, let standardStyle = VDS.TitleLockup.OtherStandardStyle(rawValue: style.toStandardStyle().rawValue) {
|
||||
return .init(text: eyebrow.text, isBold: style.isBold, standardStyle: standardStyle, textAttributes: attrs, numberOfLines: eyebrow.numberOfLines ?? 0)
|
||||
} else {
|
||||
return .init(text: eyebrow.text, textAttributes: attrs, numberOfLines: eyebrow.numberOfLines ?? 0)
|
||||
}
|
||||
do {
|
||||
if let style = eyebrow.fontStyle {
|
||||
return .init(text: eyebrow.text,
|
||||
isBold: style.isBold(),
|
||||
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 style: TextStyle? = title.fontStyle?.vdsTextStyle()
|
||||
if let style, let standardStyle = VDS.TitleLockup.TitleStandardStyle(rawValue: style.toStandardStyle().rawValue) {
|
||||
return .init(text: title.text, textAttributes: attrs, isBold: style.isBold, standardStyle: standardStyle, numberOfLines: title.numberOfLines ?? 0)
|
||||
} else {
|
||||
return .init(text: title.text, textAttributes: attrs, numberOfLines: title.numberOfLines ?? 0)
|
||||
}
|
||||
do {
|
||||
if let style = title.fontStyle {
|
||||
return .init(text: title.text,
|
||||
textAttributes: attrs,
|
||||
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? {
|
||||
guard let subTitle else { return nil }
|
||||
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) {
|
||||
return .init(text: subTitle.text, standardStyle: standardStyle, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0)
|
||||
} else {
|
||||
return .init(text: subTitle.text, textAttributes: attrs, numberOfLines: subTitle.numberOfLines ?? 0)
|
||||
}
|
||||
|
||||
do {
|
||||
if let style = subTitle.fontStyle {
|
||||
return .init(text: subTitle.text,
|
||||
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 {
|
||||
public var surface: Surface { inverted ? .dark : .light }
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user