diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 61bf9a12..2b491d07 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -54,7 +54,6 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { return false } - //------------------------------------------------------ // MARK: - Initialization //------------------------------------------------------ @@ -88,61 +87,115 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { } //------------------------------------------------------ - // MARK: - Enum + // MARK: - Enum Generator //------------------------------------------------------ enum Style { - case commonLabelB2(scale: Bool) - case commonLabelH1(scale: Bool) - case commonLabelH2(scale: Bool) - case commonLabelH32(scale: Bool) - case commonLabelH3(scale: Bool) - case commonLabelB3(scale: Bool) - case commonLabelB20(scale: Bool) - case commonLabelB1(scale: Bool) + case B1(scale: Bool) + case B2(scale: Bool) + case B3(scale: Bool) + case B20(scale: Bool) + case H1(scale: Bool) + case H2(scale: Bool) + case H3(scale: Bool) + case H32(scale: Bool) + case none - func createLabel() -> Label { + func create() -> Label { let label = Label() switch self { - case .commonLabelB2(let scale): + case .B1(let scale): + label.styleB1(scale) + + case .B2(let scale): label.styleB2(scale) - case .commonLabelH1(let scale): - label.styleH1(scale) - - case .commonLabelH2(let scale): - label.styleH2(scale) - - case .commonLabelH32(let scale): - label.styleH32(scale) - - case .commonLabelH3(let scale): - label.styleH3(scale) - - case .commonLabelB3(let scale): + case .B3(let scale): label.styleB3(scale) - case .commonLabelB20(let scale): + case .B20(let scale): label.styleB20(scale) - case .commonLabelB1(let scale): - label.styleB1(scale) + case .H1(let scale): + label.styleH1(scale) + + case .H2(let scale): + label.styleH2(scale) + + case .H3(let scale): + label.styleH3(scale) + + case .H32(let scale): + label.styleH32(scale) + + case .none: + break; } return label } } + + /* + class func commonLabelH1(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleH1(scale) + return label + } + + class func commonLabelH2(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleH2(scale) + return label + } + + class func commonLabelH3(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleH3(scale) + return label + } + + class func commonLabelH32(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleH32(scale) + return label + } + + class func commonLabelB1(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleB1(scale) + return label + } + + class func commonLabelB2(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleB2(scale) + return label + } + + class func commonLabelB3(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleB3(scale) + return label + } + + class func commonLabelB20(_ scale: Bool) -> MFLabel { + let label = MFLabel.label() + label.styleB20(scale) + return label + } + + class func label() -> MFLabel { + return Label(frame: CGRect.zero) + } + */ //------------------------------------------------------ // MARK: - Functions //------------------------------------------------------ - static func label() -> Label { - return Label(frame: CGRect.zero) - } - static func setLabel(_ label: UILabel?, withHTML html: String?) { let data: Data? = html?.data(using: .utf8) if data != nil { @@ -152,6 +205,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol { options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil) + // compare with above... // label?.attributedText = try? NSAttributedString(data: data, options: [ // NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue // ], documentAttributes: nil)