add label model
This commit is contained in:
parent
6303c3f92d
commit
9ec661ae3b
@ -55,6 +55,12 @@
|
|||||||
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; };
|
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; };
|
||||||
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
|
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
|
||||||
94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; };
|
94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */; };
|
||||||
|
94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */; };
|
||||||
|
94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */; };
|
||||||
|
94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */; };
|
||||||
|
94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */; };
|
||||||
|
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */; };
|
||||||
|
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; };
|
||||||
D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; };
|
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; };
|
||||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
||||||
@ -275,6 +281,12 @@
|
|||||||
946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = "<group>"; };
|
946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = "<group>"; };
|
||||||
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
||||||
94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = "<group>"; };
|
94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeModel.swift; sourceTree = "<group>"; };
|
||||||
|
94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeUnderlineModel.swift; sourceTree = "<group>"; };
|
||||||
|
94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeStrikeThroughModel.swift; sourceTree = "<group>"; };
|
||||||
|
94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeFontModel.swift; sourceTree = "<group>"; };
|
||||||
|
94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = "<group>"; };
|
||||||
|
94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = "<group>"; };
|
||||||
|
94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = "<group>"; };
|
||||||
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = "<group>"; };
|
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = "<group>"; };
|
||||||
D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = "<group>"; };
|
D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = "<group>"; };
|
||||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
||||||
@ -514,6 +526,12 @@
|
|||||||
children = (
|
children = (
|
||||||
01EB368823609801006832FA /* LabelModel.swift */,
|
01EB368823609801006832FA /* LabelModel.swift */,
|
||||||
94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */,
|
94C2D9832386F3F80006CF46 /* LabelAttributeModel.swift */,
|
||||||
|
94C2D9A023872BCC0006CF46 /* LabelAttributeUnderlineModel.swift */,
|
||||||
|
94C2D9A223872C110006CF46 /* LabelAttributeStrikeThroughModel.swift */,
|
||||||
|
94C2D9A423872C350006CF46 /* LabelAttributeFontModel.swift */,
|
||||||
|
94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */,
|
||||||
|
94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */,
|
||||||
|
94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */,
|
||||||
);
|
);
|
||||||
path = LabelModel;
|
path = LabelModel;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1150,6 +1168,7 @@
|
|||||||
DBC4391822442197001AB423 /* CaretView.swift in Sources */,
|
DBC4391822442197001AB423 /* CaretView.swift in Sources */,
|
||||||
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */,
|
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */,
|
||||||
D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */,
|
D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */,
|
||||||
|
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */,
|
||||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
||||||
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */,
|
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */,
|
||||||
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
||||||
@ -1184,9 +1203,11 @@
|
|||||||
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
|
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
|
||||||
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
||||||
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
|
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
|
||||||
|
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */,
|
||||||
017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */,
|
017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */,
|
||||||
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
|
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
|
||||||
D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */,
|
D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */,
|
||||||
|
94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */,
|
||||||
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */,
|
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */,
|
||||||
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
|
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
|
||||||
D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */,
|
D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */,
|
||||||
@ -1217,6 +1238,7 @@
|
|||||||
D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */,
|
D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */,
|
||||||
D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */,
|
D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */,
|
||||||
017BEB7B236763000024EF95 /* LineModel.swift in Sources */,
|
017BEB7B236763000024EF95 /* LineModel.swift in Sources */,
|
||||||
|
94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */,
|
||||||
017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */,
|
017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */,
|
||||||
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */,
|
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */,
|
||||||
D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */,
|
D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */,
|
||||||
@ -1251,6 +1273,7 @@
|
|||||||
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
|
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
|
||||||
01EB369323609801006832FA /* HeaderModel.swift in Sources */,
|
01EB369323609801006832FA /* HeaderModel.swift in Sources */,
|
||||||
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */,
|
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */,
|
||||||
|
94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */,
|
||||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */,
|
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */,
|
||||||
D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */,
|
D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */,
|
||||||
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */,
|
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */,
|
||||||
@ -1258,6 +1281,7 @@
|
|||||||
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */,
|
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */,
|
||||||
D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */,
|
D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */,
|
||||||
D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */,
|
D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */,
|
||||||
|
94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */,
|
||||||
D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */,
|
D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */,
|
||||||
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
|
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
|
||||||
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
|
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
|
||||||
|
|||||||
@ -260,7 +260,7 @@ public typealias ActionBlock = () -> ()
|
|||||||
|
|
||||||
if let attributes = labelModel.attributes, let labelText = text {
|
if let attributes = labelModel.attributes, let labelText = text {
|
||||||
let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font as UIFont, NSAttributedString.Key.foregroundColor: textColor as UIColor])
|
let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font as UIFont, NSAttributedString.Key.foregroundColor: textColor as UIColor])
|
||||||
for attribute in attributes {
|
/*for attribute in attributes {
|
||||||
guard let attributeStyle = attribute.type, let location = attribute.location, let length = attribute.length else { continue }
|
guard let attributeStyle = attribute.type, let location = attribute.location, let length = attribute.length else { continue }
|
||||||
let range = NSRange(location: location, length: length)
|
let range = NSRange(location: location, length: length)
|
||||||
switch attributeStyle {
|
switch attributeStyle {
|
||||||
@ -318,7 +318,7 @@ public typealias ActionBlock = () -> ()
|
|||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
originalAttributedString = attributedText
|
originalAttributedString = attributedText
|
||||||
|
|||||||
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// LabelAttributeActionModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Ryan on 11/21/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class LabelAttributeActionModel: LabelAttributeModel {
|
||||||
|
override public class var identifier: String {
|
||||||
|
return "action"
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// LabelAttributeColorModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Ryan on 11/21/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@objcMembers public class LabelAttributeColorModel: LabelAttributeModel {
|
||||||
|
|
||||||
|
override public class var identifier: String {
|
||||||
|
return "color"
|
||||||
|
}
|
||||||
|
|
||||||
|
var textColor: String?
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case textColor
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor)
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encodeIfPresent(textColor, forKey: .textColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// LabelAttributeFontModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Ryan on 11/21/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@objcMembers public class LabelAttributeFontModel: LabelAttributeModel {
|
||||||
|
override public class var identifier: String {
|
||||||
|
return "font"
|
||||||
|
}
|
||||||
|
|
||||||
|
var style: String?
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case style
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style)
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encodeIfPresent(style, forKey: .style)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// LabelAttributeImageModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Ryan on 11/21/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class LabelAttributeImageModel: LabelAttributeModel {
|
||||||
|
|
||||||
|
override public class var identifier: String {
|
||||||
|
return "image"
|
||||||
|
}
|
||||||
|
|
||||||
|
var size: CGFloat?
|
||||||
|
var name: String?
|
||||||
|
var URL: String?
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case size
|
||||||
|
case name
|
||||||
|
case URL
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size)
|
||||||
|
self.name = try typeContainer.decodeIfPresent(String.self, forKey: .name)
|
||||||
|
self.URL = try typeContainer.decodeIfPresent(String.self, forKey: .URL)
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encodeIfPresent(size, forKey: .size)
|
||||||
|
try container.encodeIfPresent(name, forKey: .name)
|
||||||
|
try container.encodeIfPresent(URL, forKey: .URL)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,57 +8,34 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers open class LabelAttributeModel: Codable {
|
@objcMembers open class LabelAttributeModel: Model {
|
||||||
enum ModelType: String, Codable {
|
|
||||||
case underline
|
public class var identifier: String {
|
||||||
case strikethrough
|
return ""
|
||||||
case color
|
|
||||||
case image
|
|
||||||
case font
|
|
||||||
case action
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var type: ModelType?
|
var type: String
|
||||||
var location: Int?
|
var location: Int
|
||||||
var length: Int?
|
var length: Int
|
||||||
var textColor: String?
|
|
||||||
var style: String?
|
|
||||||
var size: CGFloat?
|
|
||||||
var name: String?
|
|
||||||
var URL: String?
|
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case type
|
case type
|
||||||
case location
|
case location
|
||||||
case length
|
case length
|
||||||
case textColor
|
|
||||||
case style
|
|
||||||
case size
|
|
||||||
case name
|
|
||||||
case URL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
self.type = try typeContainer.decodeIfPresent(ModelType.self, forKey: .type)
|
self.type = try typeContainer.decode(String.self, forKey: .type)
|
||||||
self.location = try typeContainer.decodeIfPresent(Int.self, forKey: .location)
|
self.location = try typeContainer.decode(Int.self, forKey: .location)
|
||||||
self.length = try typeContainer.decodeIfPresent(Int.self, forKey: .length)
|
self.length = try typeContainer.decode(Int.self, forKey: .length)
|
||||||
self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor)
|
|
||||||
self.style = try typeContainer.decodeIfPresent(String.self, forKey: .style)
|
|
||||||
self.size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size)
|
|
||||||
self.name = try typeContainer.decodeIfPresent(String.self, forKey: .name)
|
|
||||||
self.URL = try typeContainer.decodeIfPresent(String.self, forKey: .URL)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(type, forKey: .type)
|
try container.encode(type, forKey: .type)
|
||||||
try container.encodeIfPresent(location, forKey: .location)
|
try container.encode(location, forKey: .location)
|
||||||
try container.encodeIfPresent(length, forKey: .length)
|
try container.encode(length, forKey: .length)
|
||||||
try container.encodeIfPresent(textColor, forKey: .textColor)
|
|
||||||
try container.encodeIfPresent(style, forKey: .style)
|
|
||||||
try container.encodeIfPresent(size, forKey: .size)
|
|
||||||
try container.encodeIfPresent(name, forKey: .name)
|
|
||||||
try container.encodeIfPresent(URL, forKey: .URL)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// LabelAttributeStrikeThroughModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Ryan on 11/21/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@objcMembers public class LabelAttributeStrikeThroughModel: LabelAttributeModel {
|
||||||
|
override public class var identifier: String {
|
||||||
|
return "strikethrough"
|
||||||
|
}
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// LabelAttributeUnderlineModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Ryan on 11/21/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@objcMembers public class LabelAttributeUnderlineModel: LabelAttributeModel {
|
||||||
|
override public class var identifier: String {
|
||||||
|
return "underline"
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,4 +24,73 @@ import Foundation
|
|||||||
public var html: String?
|
public var html: String?
|
||||||
public var hero: Int?
|
public var hero: Int?
|
||||||
public var makeWholeViewClickable: Bool?
|
public var makeWholeViewClickable: Bool?
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case moleculeName
|
||||||
|
case text
|
||||||
|
case accessibilityText
|
||||||
|
case textColor
|
||||||
|
case backgroundColor
|
||||||
|
case fontStyle
|
||||||
|
case fontName
|
||||||
|
case fontSize
|
||||||
|
case textAlignment
|
||||||
|
case attributes
|
||||||
|
case html
|
||||||
|
case hero
|
||||||
|
case makeWholeViewClickable
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AttributeTypeKey: String, CodingKey {
|
||||||
|
case type
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName)
|
||||||
|
self.text = try typeContainer.decode(String.self, forKey: .text)
|
||||||
|
self.accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||||
|
self.textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor)
|
||||||
|
self.backgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .backgroundColor)
|
||||||
|
self.fontStyle = try typeContainer.decodeIfPresent(String.self, forKey: .fontStyle)
|
||||||
|
self.fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
|
||||||
|
self.fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
|
||||||
|
self.textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment)
|
||||||
|
do {
|
||||||
|
var attributesContainer = try typeContainer.nestedUnkeyedContainer(forKey: .attributes)
|
||||||
|
var attributes = [LabelAttributeModel]()
|
||||||
|
while !attributesContainer.isAtEnd {
|
||||||
|
guard let attmodel = try attributesContainer.decodeUnKeyedIfPresent(LabelAttributeModel.self, typeCodingKey: AttributeTypeKey.type) else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
attributes.append(attmodel)
|
||||||
|
}
|
||||||
|
self.attributes = attributes
|
||||||
|
} catch {
|
||||||
|
print("no attributes")
|
||||||
|
}
|
||||||
|
self.html = try typeContainer.decodeIfPresent(String.self, forKey: .html)
|
||||||
|
self.hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)
|
||||||
|
self.makeWholeViewClickable = try typeContainer.decodeIfPresent(Bool.self, forKey: .makeWholeViewClickable)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
||||||
|
try container.encode(text, forKey: .moleculeName)
|
||||||
|
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||||
|
try container.encodeIfPresent(textColor, forKey: .textColor)
|
||||||
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
try container.encodeIfPresent(fontStyle, forKey: .fontStyle)
|
||||||
|
try container.encodeIfPresent(fontName, forKey: .fontName)
|
||||||
|
try container.encodeIfPresent(fontSize, forKey: .fontSize)
|
||||||
|
try container.encodeIfPresent(textAlignment, forKey: .textAlignment)
|
||||||
|
// var attributeContainer = container.nestedUnkeyedContainer(forKey: .attributes)
|
||||||
|
// try attributes?.forEach({ (attributeModel) in
|
||||||
|
// try attributeContainer.encode(attributeModel)
|
||||||
|
// })
|
||||||
|
try container.encodeIfPresent(html, forKey: .html)
|
||||||
|
try container.encodeIfPresent(hero, forKey: .hero)
|
||||||
|
try container.encodeIfPresent(makeWholeViewClickable, forKey: .makeWholeViewClickable)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,5 +23,11 @@ import Foundation
|
|||||||
ModelRegistry.register(CaretViewModel.self)
|
ModelRegistry.register(CaretViewModel.self)
|
||||||
ModelRegistry.register(DashLineModel.self)
|
ModelRegistry.register(DashLineModel.self)
|
||||||
ModelRegistry.register(ImageViewModel.self)
|
ModelRegistry.register(ImageViewModel.self)
|
||||||
|
ModelRegistry.register(LabelAttributeFontModel.self)
|
||||||
|
ModelRegistry.register(LabelAttributeColorModel.self)
|
||||||
|
ModelRegistry.register(LabelAttributeImageModel.self)
|
||||||
|
ModelRegistry.register(LabelAttributeUnderlineModel.self)
|
||||||
|
ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
|
||||||
|
ModelRegistry.register(LabelAttributeActionModel.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user