Further cleaning

This commit is contained in:
Pfeil, Scott Robert 2020-03-24 12:45:01 -04:00
parent 7fdff34eeb
commit 7a86b0356b
39 changed files with 194 additions and 116 deletions

View File

@ -192,6 +192,8 @@
C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; }; C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; };
C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012023E8303200396FBD /* ListRVWheel.swift */; }; C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012023E8303200396FBD /* ListRVWheel.swift */; };
C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012223E846C300396FBD /* ListRVWheelModel.swift */; }; C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012223E846C300396FBD /* ListRVWheelModel.swift */; };
D202AFE4242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D202AFE3242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift */; };
D202AFE6242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D202AFE5242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift */; };
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; }; D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; };
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; };
@ -573,6 +575,8 @@
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = "<group>"; }; C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = "<group>"; };
C7F8012023E8303200396FBD /* ListRVWheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRVWheel.swift; sourceTree = "<group>"; }; C7F8012023E8303200396FBD /* ListRVWheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRVWheel.swift; sourceTree = "<group>"; };
C7F8012223E846C300396FBD /* ListRVWheelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRVWheelModel.swift; sourceTree = "<group>"; }; C7F8012223E846C300396FBD /* ListRVWheelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRVWheelModel.swift; sourceTree = "<group>"; };
D202AFE3242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSTextAlignment+Extension.swift"; sourceTree = "<group>"; };
D202AFE5242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionViewScrollPosition+Extension.swift"; 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>"; };
D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = "<group>"; }; D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = "<group>"; };
D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; };
@ -807,6 +811,7 @@
011B58EE23A2AA850085F53C /* ModelProtocols */ = { 011B58EE23A2AA850085F53C /* ModelProtocols */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D2E2A9A023E095AB000B42E6 /* ButtonModelProtocol.swift */,
014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */, 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */,
012A88C3238D86E600FE3DA1 /* CarouselItemModelProtocol.swift */, 012A88C3238D86E600FE3DA1 /* CarouselItemModelProtocol.swift */,
012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */, 012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */,
@ -843,14 +848,6 @@
path = CustomPrimitives; path = CustomPrimitives;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
01509D96232803B200EF99AA /* Models */ = {
isa = PBXGroup;
children = (
011B58EE23A2AA850085F53C /* ModelProtocols */,
);
path = Models;
sourceTree = "<group>";
};
01C74D87224298E2009C25A3 /* FormUIHelpers */ = { 01C74D87224298E2009C25A3 /* FormUIHelpers */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -1001,6 +998,17 @@
path = RightVariable; path = RightVariable;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
D202AFE2242A5F1400E5BEDF /* Extensions */ = {
isa = PBXGroup;
children = (
D202AFE3242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift */,
0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */,
D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */,
D202AFE5242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
D213347423842FE3008E41B3 /* Controllers */ = { D213347423842FE3008E41B3 /* Controllers */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -1293,7 +1301,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D2C78CD324252F4E00B69FDE /* Atomic */, D2C78CD324252F4E00B69FDE /* Atomic */,
01509D96232803B200EF99AA /* Models */,
012A88EF23985E0100FE3DA1 /* CustomPrimitives */, 012A88EF23985E0100FE3DA1 /* CustomPrimitives */,
D2B18B7D236090D500A9AEDC /* BaseClasses */, D2B18B7D236090D500A9AEDC /* BaseClasses */,
01C74D87224298E2009C25A3 /* FormUIHelpers */, 01C74D87224298E2009C25A3 /* FormUIHelpers */,
@ -1459,8 +1466,6 @@
D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */, D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */,
D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */, D29DF2A821E7B2F9003B2FB9 /* MVMCoreUIConstants.m */,
0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */, 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */,
0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */,
D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */,
); );
path = Utility; path = Utility;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1678,7 +1683,6 @@
D2B18B7D236090D500A9AEDC /* BaseClasses */ = { D2B18B7D236090D500A9AEDC /* BaseClasses */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D2E2A9A023E095AB000B42E6 /* ButtonModelProtocol.swift */,
C003506023AA94CD00B6AC29 /* Button.swift */, C003506023AA94CD00B6AC29 /* Button.swift */,
D2B18B7E2360913400A9AEDC /* Control.swift */, D2B18B7E2360913400A9AEDC /* Control.swift */,
D2B18B802360945C00A9AEDC /* View.swift */, D2B18B802360945C00A9AEDC /* View.swift */,
@ -1693,6 +1697,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */, 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */,
D202AFE2242A5F1400E5BEDF /* Extensions */,
D2C78CD424252F5D00B69FDE /* Protocols */, D2C78CD424252F5D00B69FDE /* Protocols */,
D29DF10D21E67A70003B2FB9 /* Atoms */, D29DF10D21E67A70003B2FB9 /* Atoms */,
D29DF10E21E67A77003B2FB9 /* Molecules */, D29DF10E21E67A77003B2FB9 /* Molecules */,
@ -1708,6 +1713,7 @@
012A88C7238DB02000FE3DA1 /* MoleculeDelegateProtocol.swift */, 012A88C7238DB02000FE3DA1 /* MoleculeDelegateProtocol.swift */,
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */,
012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */, 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */,
011B58EE23A2AA850085F53C /* ModelProtocols */,
); );
path = Protocols; path = Protocols;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1920,6 +1926,7 @@
9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */, 9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */,
522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */, 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */,
9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */,
D202AFE4242A5F5E00E5BEDF /* NSTextAlignment+Extension.swift in Sources */,
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */,
01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */, 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */,
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */, D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
@ -1958,6 +1965,7 @@
52B201D324081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift in Sources */, 52B201D324081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift in Sources */,
525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */, 525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */,
D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */,
D202AFE6242A6A9C00E5BEDF /* UICollectionViewScrollPosition+Extension.swift in Sources */,
8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */,
94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */, 94C0150C2421564A005811A9 /* ActionCollapseNotificationModel.swift in Sources */,
014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */,

View File

@ -291,15 +291,12 @@ import UIKit
placeholder = model.placeholder placeholder = model.placeholder
switch model.type { switch model.type {
case "password": case .password:
textField.isSecureTextEntry = true textField.isSecureTextEntry = true
case .number:
case "number":
textField.keyboardType = .numberPad textField.keyboardType = .numberPad
case .email:
case "email":
textField.keyboardType = .emailAddress textField.keyboardType = .emailAddress
default: default:
break break
} }

View File

@ -8,6 +8,13 @@
@objcMembers public class TextEntryFieldModel: EntryFieldModel { @objcMembers public class TextEntryFieldModel: EntryFieldModel {
public enum EntryType: String, Codable {
case password
case number
case email
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
@ -19,7 +26,7 @@
public var placeholder: String? public var placeholder: String?
public var enabledTextColor: Color? public var enabledTextColor: Color?
public var disabledTextColor: Color? public var disabledTextColor: Color?
public var type: String? public var type: EntryType?
public var regex: String? public var regex: String?
//-------------------------------------------------- //--------------------------------------------------
@ -47,7 +54,7 @@
placeholder = try typeContainer.decodeIfPresent(String.self, forKey: .placeholder) placeholder = try typeContainer.decodeIfPresent(String.self, forKey: .placeholder)
enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledTextColor) enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledTextColor)
disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor) disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor)
type = try typeContainer.decodeIfPresent(String.self, forKey: .type) type = try typeContainer.decodeIfPresent(EntryType.self, forKey: .type)
regex = try typeContainer.decodeIfPresent(String.self, forKey: .regex) regex = try typeContainer.decodeIfPresent(String.self, forKey: .regex)
} }

View File

@ -16,8 +16,8 @@ public enum CheckboxPosition: String, Codable {
@objcMembers public class CheckboxLabelModel: MoleculeModelProtocol { @objcMembers public class CheckboxLabelModel: MoleculeModelProtocol {
public static var identifier: String = "checkboxLabel" public static var identifier: String = "checkboxLabel"
public var moleculeName: String
public var backgroundColor: Color? public var backgroundColor: Color?
public var checkboxAlignment: CheckboxPosition? public var checkboxAlignment: CheckboxPosition?
public var checkbox: CheckboxModel public var checkbox: CheckboxModel
public var label: LabelModel public var label: LabelModel

View File

@ -323,14 +323,11 @@ public typealias ActionBlock = () -> ()
hero = labelModel.hero hero = labelModel.hero
Label.setLabel(self, withHTML: labelModel.html) Label.setLabel(self, withHTML: labelModel.html)
let alignment = LabelAlignment(rawValue: labelModel.textAlignment ?? "") switch labelModel.textAlignment {
switch alignment {
case .center: case .center:
textAlignment = .center textAlignment = .center
case .right: case .right:
textAlignment = .right textAlignment = .right
default: default:
textAlignment = .left textAlignment = .left
} }
@ -344,8 +341,7 @@ public typealias ActionBlock = () -> ()
accessibilityLabel = accessibilityText accessibilityLabel = accessibilityText
} }
if let fontStyle = labelModel.fontStyle { if let fontStyle = labelModel.fontStyle?.rawValue {
MFStyler.styleLabel(self, withStyle: fontStyle)
MFStyler.styleLabel(self, withStyle: fontStyle, genericScaling: false) MFStyler.styleLabel(self, withStyle: fontStyle, genericScaling: false)
standardFontSize = font.pointSize standardFontSize = font.pointSize
} else { } else {
@ -378,9 +374,9 @@ public typealias ActionBlock = () -> ()
attributedString.addAttribute(.baselineOffset, value: 0, range: range) attributedString.addAttribute(.baselineOffset, value: 0, range: range)
case let colorAtt as LabelAttributeColorModel: case let colorAtt as LabelAttributeColorModel:
if let colorHex = colorAtt.textColor, !colorHex.isEmpty { if let colorHex = colorAtt.textColor {
attributedString.removeAttribute(.foregroundColor, range: range) attributedString.removeAttribute(.foregroundColor, range: range)
attributedString.addAttribute(.foregroundColor, value: UIColor.mfGet(forHex: colorHex), range: range) attributedString.addAttribute(.foregroundColor, value: colorHex.uiColor, range: range)
} }
case let imageAtt as LabelAttributeImageModel: case let imageAtt as LabelAttributeImageModel:
@ -401,7 +397,7 @@ public typealias ActionBlock = () -> ()
attributedString.insert(mutableString, at: imageAtt.location) attributedString.insert(mutableString, at: imageAtt.location)
case let fontAtt as LabelAttributeFontModel: case let fontAtt as LabelAttributeFontModel:
if let fontStyle = fontAtt.style { if let fontStyle = fontAtt.style?.rawValue {
let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle) let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle)
attributedString.removeAttribute(.font, range: range) attributedString.removeAttribute(.font, range: range)
attributedString.removeAttribute(.foregroundColor, range: range) attributedString.removeAttribute(.foregroundColor, range: range)

View File

@ -17,7 +17,7 @@ import UIKit
return "color" return "color"
} }
var textColor: String? var textColor: Color?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys
@ -33,7 +33,7 @@ import UIKit
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)
textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor)
try super.init(from: decoder) try super.init(from: decoder)
} }

View File

@ -18,7 +18,7 @@ import UIKit
return "font" return "font"
} }
var style: String? var style: LabelModel.FontStyle?
var name: String? var name: String?
var size: CGFloat? var size: CGFloat?
@ -38,7 +38,7 @@ import UIKit
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)
style = try typeContainer.decodeIfPresent(String.self, forKey: .style) style = try typeContainer.decodeIfPresent(LabelModel.FontStyle.self, forKey: .style)
name = try typeContainer.decodeIfPresent(String.self, forKey: .name) name = try typeContainer.decodeIfPresent(String.self, forKey: .name)
size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size) size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size)
try super.init(from: decoder) try super.init(from: decoder)

View File

@ -10,6 +10,18 @@
import Foundation import Foundation
@objcMembers public class LabelModel: MoleculeModelProtocol { @objcMembers public class LabelModel: MoleculeModelProtocol {
public enum FontStyle: String, Codable {
case H1
case H2
case H3
case H32
case B1
case B2
case B3
case B20
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
@ -19,10 +31,10 @@ import Foundation
public var text: String public var text: String
public var accessibilityText: String? public var accessibilityText: String?
public var textColor: Color? public var textColor: Color?
public var fontStyle: String? public var fontStyle: FontStyle?
public var fontName: String? public var fontName: String?
public var fontSize: CGFloat? public var fontSize: CGFloat?
public var textAlignment: String? public var textAlignment: NSTextAlignment?
public var attributes: [LabelAttributeModel]? public var attributes: [LabelAttributeModel]?
public var html: String? public var html: String?
public var hero: Int? public var hero: Int?
@ -70,10 +82,10 @@ import Foundation
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
fontStyle = try typeContainer.decodeIfPresent(String.self, forKey: .fontStyle) fontStyle = try typeContainer.decodeIfPresent(FontStyle.self, forKey: .fontStyle)
fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName) fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize) fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
textAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .textAlignment) textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment)
attributes = try typeContainer.decodeModelsIfPresent(codingKey: .attributes) attributes = try typeContainer.decodeModelsIfPresent(codingKey: .attributes)
html = try typeContainer.decodeIfPresent(String.self, forKey: .html) html = try typeContainer.decodeIfPresent(String.self, forKey: .html)
hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero) hero = try typeContainer.decodeIfPresent(Int.self, forKey: .hero)

View File

@ -0,0 +1,71 @@
//
// UICollectionViewScrollPosition+Extension.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 3/24/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
enum ScrollPositionError: Error {
case notAPosition
}
extension UICollectionView.ScrollPosition: RawRepresentable {
init?(rawValue: String) {
switch rawValue {
case "left", "leading":
self = .left
case "centeredHorizontally", "center":
self = .centeredHorizontally
case "right", "trailing":
self = .right
case "top":
self = .top
case "bottom":
self = .bottom
case "centeredVertically":
self = .centeredVertically
default:
return nil
}
}
var rawValueString: String {
switch self {
case .left:
return "left"
case .centeredHorizontally:
return "centeredHorizontally"
case .right:
return "right"
case .top:
return "top"
case .bottom:
return "bottom"
case .centeredVertically:
return "centeredVertically"
default:
return ""
}
}
}
extension UICollectionView.ScrollPosition: Codable {
public init(from decoder: Decoder) throws {
let typeContainer = try decoder.singleValueContainer()
let string = try typeContainer.decode(String.self)
guard let position = UICollectionView.ScrollPosition(rawValue: string) else {
throw ScrollPositionError.notAPosition
}
self = position
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValueString)
}
}

View File

@ -20,7 +20,7 @@ public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeMod
// Defaults to set // Defaults to set
override public func setDefaults() { override public func setDefaults() {
super.setDefaults() super.setDefaults()
headlineBody.style = "item" headlineBody.style = .item
} }
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {

View File

@ -26,9 +26,9 @@ public class ListThreeColumnPlanDataDividerModel: ListItemModel, MoleculeModelPr
override public func setDefaults() { override public func setDefaults() {
super.setDefaults() super.setDefaults()
style = "tallDivider" style = "tallDivider"
leftHeadlineBody.style = "itemHeader" leftHeadlineBody.style = .itemHeader
centerHeadlineBody.style = "itemHeader" centerHeadlineBody.style = .itemHeader
rightHeadlineBody.style = "itemHeader" rightHeadlineBody.style = .itemHeader
} }
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {

View File

@ -11,7 +11,7 @@ import Foundation
@objcMembers public class RadioButtonLabelModel: MoleculeModelProtocol { @objcMembers public class RadioButtonLabelModel: MoleculeModelProtocol {
public static var identifier: String = "radioButtonLabel" public static var identifier: String = "radioButtonLabel"
public var backgroundColor: Color? public var backgroundColor: Color?
public var moleculeName: String
public var radioButton: RadioButtonModel public var radioButton: RadioButtonModel
public var label: LabelModel public var label: LabelModel
} }

View File

@ -23,15 +23,15 @@ open class HeadlineBody: View {
} }
// MARK: - Styling // MARK: - Styling
func style(with styleString: String?) { func style(with style: HeadlineBodyModel.Style?) {
guard let styleString = styleString else { return } switch style {
case .landingHeader:
switch styleString { styleLandingPageHeader()
case "header": case .header:
stylePageHeader() stylePageHeader()
case "item": case .item:
styleListItem() styleListItem()
case "itemHeader": case .itemHeader:
styleListItemDivider() styleListItemDivider()
default: break default: break
} }

View File

@ -62,7 +62,7 @@ public class HeadlineBodyCaretLinkImageModel: ContainerModel, MoleculeModelProto
public override func encode(to encoder: Encoder) throws { public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder) try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(HeadlineBodyCaretLinkImageModel.identifier, forKey: .moleculeName) try container.encode(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encode(headlineBody, forKey: .headlineBody) try container.encode(headlineBody, forKey: .headlineBody)
try container.encode(image, forKey: .image) try container.encode(image, forKey: .image)

View File

@ -9,11 +9,19 @@
import Foundation import Foundation
@objcMembers open class HeadlineBodyModel: MoleculeModelProtocol { @objcMembers open class HeadlineBodyModel: MoleculeModelProtocol {
/// Convenience styles for common situations.
public enum Style: String, Codable {
case landingHeader
case header
case itemHeader
case item
}
public static var identifier: String = "headlineBody" public static var identifier: String = "headlineBody"
public var moleculeName: String = HeadlineBodyModel.identifier public var moleculeName: String = HeadlineBodyModel.identifier
public var headline: LabelModel? public var headline: LabelModel?
public var body: LabelModel? public var body: LabelModel?
public var style: String? public var style: Style?
public var backgroundColor: Color? public var backgroundColor: Color?
public init(headline: LabelModel) { public init(headline: LabelModel) {

View File

@ -98,7 +98,9 @@ open class Carousel: View {
setupLayout(with: carouselModel) setupLayout(with: carouselModel)
prepareMolecules(with: carouselModel) prepareMolecules(with: carouselModel)
itemWidthPercent = (carouselModel.itemWidthPercent ?? 100) / 100 itemWidthPercent = (carouselModel.itemWidthPercent ?? 100) / 100
setAlignment(with: carouselModel.itemAlignment) if let alignment = carouselModel.itemAlignment {
itemAlignment = alignment
}
if let height = carouselModel.height { if let height = carouselModel.height {
collectionViewHeight?.constant = CGFloat(height) collectionViewHeight?.constant = CGFloat(height)
@ -167,19 +169,6 @@ open class Carousel: View {
return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule) return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule)
} }
/// Sets the alignment from the string.
open func setAlignment(with string: String?) {
switch string {
case "leading":
itemAlignment = .left
case "trailing":
itemAlignment = .right
case "center":
itemAlignment = .centeredHorizontally
default: break
}
}
/// Adds a paging view. Centers it horizontally with the collection view. The position is the vertical distance from the center of the page view to the bottom of the collection view. /// Adds a paging view. Centers it horizontally with the collection view. The position is the vertical distance from the center of the page view to the bottom of the collection view.
open func addPaging(view: (UIView & MVMCoreUIPagingProtocol)?, position: CGFloat) { open func addPaging(view: (UIView & MVMCoreUIPagingProtocol)?, position: CGFloat) {
pagingView?.removeFromSuperview() pagingView?.removeFromSuperview()

View File

@ -18,7 +18,7 @@ import UIKit
public var loop: Bool? public var loop: Bool?
public var height: Float? public var height: Float?
public var itemWidthPercent: Float? public var itemWidthPercent: Float?
public var itemAlignment: String? public var itemAlignment: UICollectionView.ScrollPosition?
public var pagingMolecule: CarouselPagingModelProtocol? public var pagingMolecule: CarouselPagingModelProtocol?
public init(molecules: [CarouselItemModel]){ public init(molecules: [CarouselItemModel]){
@ -47,7 +47,7 @@ import UIKit
self.loop = try typeContainer.decode(Bool.self, forKey: .loop) self.loop = try typeContainer.decode(Bool.self, forKey: .loop)
self.height = try typeContainer.decode(Float.self, forKey: .height) self.height = try typeContainer.decode(Float.self, forKey: .height)
self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent) self.itemWidthPercent = try typeContainer.decode(Float.self, forKey: .itemWidthPercent)
self.itemAlignment = try typeContainer.decode(String.self, forKey: .itemAlignment) self.itemAlignment = try typeContainer.decode(UICollectionView.ScrollPosition.self, forKey: .itemAlignment)
self.pagingMolecule = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule) self.pagingMolecule = try typeContainer.decodeModelIfPresent(codingKey: .pagingMolecule)
} }

View File

@ -10,6 +10,7 @@ import Foundation
public protocol PageModelProtocol { public protocol PageModelProtocol {
var pageType: String { get set } var pageType: String { get set }
/// Temporary: for legacy response
var screenHeading: String? { get set } var screenHeading: String? { get set }
var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set } var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set }
} }

View File

@ -0,0 +1,20 @@
//
// PageModelProtocol.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/9/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol PageModelProtocol {
var pageType: String { get set }
var screenHeading: String? { get set }
<<<<<<< HEAD
var navigationItem: NavigationItemModelProtocol? { get set }
=======
var isAtomicTabs: Bool? { get set }
var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)? { get set }
>>>>>>> 18f86575e604bb7b53b6bdac4fc677951979031f
}

View File

@ -14,10 +14,10 @@ public protocol MoleculeDelegateProtocol: AnyObject {
func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? func getModuleWithName(_ name: String?) -> [AnyHashable : Any]?
func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol?
/// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. /// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method. Mainly used for list or collections.
func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) //optional func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) //optional
/// Asks the delegate to add or remove molecules. /// Asks the delegate to add or remove molecules. Mainly used for list or collections.
func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath?
func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation) func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation)
func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation)

View File

@ -22,10 +22,10 @@ public protocol MoleculeViewProtocol: UIView {
/// Resets to default state before set with json is called again. /// Resets to default state before set with json is called again.
func reset() func reset()
/// Allows the molecule to set its name for reuse. Default could be moleculeName. /// Allows the molecule to set its name for reuse. Default could be moleculeName. Mainly used for list or collections.
static func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? static func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String?
/// For the molecule list to load more efficiently. /// For the molecule list to load more efficiently. Mainly used for list or collections.
static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat?
/// Can return the required modules /// Can return the required modules

View File

@ -9,7 +9,7 @@
import Foundation import Foundation
public protocol TemplateProtocol: class { public protocol TemplateProtocol: AnyObject {
associatedtype TemplateModel: TemplateModelProtocol associatedtype TemplateModel: TemplateModelProtocol
var templateModel: TemplateModel? { get set } var templateModel: TemplateModel? { get set }
} }
@ -20,6 +20,7 @@ public extension TemplateProtocol where Self: ViewController {
let data = try JSONSerialization.data(withJSONObject: pageJSON) let data = try JSONSerialization.data(withJSONObject: pageJSON)
let decoder = JSONDecoder() let decoder = JSONDecoder()
let templateModel = try decoder.decode(TemplateModel.self, from: data) let templateModel = try decoder.decode(TemplateModel.self, from: data)
print(templateModel.toJSONString() ?? "")
self.templateModel = templateModel self.templateModel = templateModel
self.pageModel = templateModel as? MVMControllerModelProtocol self.pageModel = templateModel as? MVMControllerModelProtocol
} }

View File

@ -36,15 +36,10 @@ import Foundation
//-------------------------------------------------- //--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case template
case pageType
case screenHeading
case molecules case molecules
case header case header
case footer case footer
case line case line
case isAtomicTabs
case formRules
} }
//-------------------------------------------------- //--------------------------------------------------

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
public protocol MoleculeListCellProtocol { public protocol MoleculeListCellProtocol: UITableViewCell {
/// Can set the separator according to what the moleculeList commands. /// Can set the separator according to what the moleculeList commands.
func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath)

View File

@ -24,9 +24,6 @@ import Foundation
} }
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case pageType
case template
case screenHeading
case header case header
case footer case footer
case stack case stack
@ -43,8 +40,6 @@ import Foundation
public override func encode(to encoder: Encoder) throws { public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder) try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(pageType, forKey: .pageType)
try container.encode(template, forKey: .template)
try container.encode(moleculeStack, forKey: .stack) try container.encode(moleculeStack, forKey: .stack)
try container.encodeModelIfPresent(header, forKey: .header) try container.encodeModelIfPresent(header, forKey: .header)
try container.encodeModelIfPresent(footer, forKey: .footer) try container.encodeModelIfPresent(footer, forKey: .footer)

View File

@ -38,7 +38,7 @@ import Foundation
pageType = try typeContainer.decode(String.self, forKey: .pageType) pageType = try typeContainer.decode(String.self, forKey: .pageType)
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading) screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules)
// navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem) navigationItem = try typeContainer.decodeModelIfPresent(codingKey: .navigationItem)
} }
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
@ -47,6 +47,6 @@ import Foundation
try container.encode(template, forKey: .template) try container.encode(template, forKey: .template)
try container.encodeIfPresent(screenHeading, forKey: .screenHeading) try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
try container.encodeIfPresent(formRules, forKey: .formRules) try container.encodeIfPresent(formRules, forKey: .formRules)
//try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem) try container.encodeModelIfPresent(navigationItem, forKey: .navigationItem)
} }
} }

View File

@ -8,60 +8,40 @@
import Foundation import Foundation
@objcMembers public class ThreeLayerPageTemplateModel: MVMControllerModelProtocol { @objcMembers public class ThreeLayerPageTemplateModel: TemplateModel {
public override class var identifier: String {
public var formRules: [FormGroupRule]? return "threeLayer"
public var formValidator: FormValidator? }
public static var identifier: String = "threeLayer"
public var pageType: String
public var screenHeading: String?
public var isAtomicTabs: Bool?
public var navigationItem: (NavigationItemModelProtocol & MoleculeModelProtocol)?
public var header: MoleculeModelProtocol? public var header: MoleculeModelProtocol?
public var middle: MoleculeModelProtocol? public var middle: MoleculeModelProtocol?
public var footer: MoleculeModelProtocol? public var footer: MoleculeModelProtocol?
public init(pageType: String, header: MoleculeModelProtocol?, middle: MoleculeModelProtocol?, footer: MoleculeModelProtocol?) { public init(pageType: String, header: MoleculeModelProtocol?, middle: MoleculeModelProtocol?, footer: MoleculeModelProtocol?) {
self.pageType = pageType super.init(pageType: pageType)
self.header = header self.header = header
self.middle = middle self.middle = middle
self.footer = footer self.footer = footer
} }
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case pageType
case template
case screenHeading
case header case header
case footer case footer
case middle case middle
case isAtomicTabs
case formRules
} }
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)
pageType = try typeContainer.decode(String.self, forKey: .pageType)
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
header = try typeContainer.decodeModelIfPresent(codingKey: .header) header = try typeContainer.decodeModelIfPresent(codingKey: .header)
middle = try typeContainer.decodeModelIfPresent(codingKey: .middle) middle = try typeContainer.decodeModelIfPresent(codingKey: .middle)
footer = try typeContainer.decodeModelIfPresent(codingKey: .footer) footer = try typeContainer.decodeModelIfPresent(codingKey: .footer)
formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules) try super.init(from: decoder)
} }
public func encode(to encoder: Encoder) throws { public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(pageType, forKey: .pageType)
try container.encode(template, forKey: .template)
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
try container.encodeModelIfPresent(header, forKey: .header) try container.encodeModelIfPresent(header, forKey: .header)
try container.encodeModelIfPresent(header, forKey: .middle) try container.encodeModelIfPresent(header, forKey: .middle)
try container.encodeModelIfPresent(footer, forKey: .footer) try container.encodeModelIfPresent(footer, forKey: .footer)
try container.encodeIfPresent(formRules, forKey: .formRules)
} }
} }

View File

@ -12,7 +12,6 @@ import UIKit
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
open var json: [AnyHashable: Any]?
open var model: MoleculeModelProtocol? open var model: MoleculeModelProtocol?
private var initialSetupPerformed = false private var initialSetupPerformed = false

View File

@ -9,7 +9,6 @@
import UIKit import UIKit
@objcMembers open class View: UIView, MoleculeViewProtocol { @objcMembers open class View: UIView, MoleculeViewProtocol {
open var json: [AnyHashable: Any]?
open var model: MoleculeModelProtocol? open var model: MoleculeModelProtocol?
private var initialSetupPerformed = false private var initialSetupPerformed = false