From ee85a8972e3dfa8a00ae9c9091d03d830aa2cb7e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 14 Feb 2020 08:58:32 -0500 Subject: [PATCH 01/12] relaigning key name with legacy name. --- MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift index 5f60081e..1030fb8c 100644 --- a/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atoms/TextFields/EntryFieldModel.swift @@ -37,7 +37,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case moleculeName case backgroundColor - case title + case title = "label" case isEnabled case feedback case errorMessage = "errorMsg" From e431ea2de9690a6ae61ed90c9ec9c538cff6af0e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 14 Feb 2020 15:56:36 -0500 Subject: [PATCH 02/12] fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Atoms/Views/ImageViewModel.swift | 24 ++++- MVMCoreUI/Atoms/Views/Label/LabelModel.swift | 6 +- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 48 +++++++++ .../HeadlineBodyModel.swift | 1 + .../MVMCoreUIViewControllerMappingObject.m | 4 +- .../Templates/IsaacLandingTemplate.swift | 100 ++++++++++++++++++ 7 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 MVMCoreUI/Templates/IsaacLandingTemplate.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d114d2ae..6ac575a6 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -50,6 +50,7 @@ 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; + 01B5E6B023F5F276005B5839 /* IsaacLandingTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01B5E6AF23F5F276005B5839 /* IsaacLandingTemplate.swift */; }; 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D223CF9E740021F976 /* LabelToggleModel.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */; }; @@ -382,6 +383,7 @@ 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; + 01B5E6AF23F5F276005B5839 /* IsaacLandingTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IsaacLandingTemplate.swift; sourceTree = ""; }; 01C851D223CF9E740021F976 /* LabelToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggleModel.swift; sourceTree = ""; }; 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeModelProtocol.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; @@ -1068,6 +1070,7 @@ D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */, 014AA72A23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift */, D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */, + 01B5E6AF23F5F276005B5839 /* IsaacLandingTemplate.swift */, ); path = Templates; sourceTree = ""; @@ -1810,6 +1813,7 @@ D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, + 01B5E6B023F5F276005B5839 /* IsaacLandingTemplate.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, C003506123AA94CD00B6AC29 /* Button.swift in Sources */, DBC4391B224421A0001AB423 /* CaretLink.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index ce46a930..f8443da5 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,11 +11,33 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeModelProtocol { public static var identifier: String = "image" public var backgroundColor: Color? - + public var moleculeName: String? public var image: String public var accessibilityText: String? public var fallbackImage: String? public var imageFormat: String? public var width: CGFloat? public var height: CGFloat? + public var contentMode: ContentMode? + + public enum ContentMode : String, Codable { + case scaleToFill + case scaleAspectFit // contents scaled to fit with fixed aspect. remainder is transparent + case scaleAspectFill // contents scaled to fill with fixed aspect. some portion of content may be clipped. + case redraw // redraw on bounds change (calls -setNeedsDisplay) + case center // contents remain same size. positioned adjusted. + case top + case bottom + case left + case right + case topLeft + case topRight + case bottomLeft + case bottomRight + } + + public init(image: String) { + self.image = image + moleculeName = Self.identifier + } } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index 731b23da..a177f414 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -45,7 +45,11 @@ import Foundation enum AttributeTypeKey: String, CodingKey { case type } - + + public init(text: String) { + self.text = text + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 1c54b891..d46a5150 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -232,6 +232,54 @@ import UIKit imageView.animatedImage = nil loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage) } + setContentMode(imageModel) + } + + func setContentMode(_ model: ImageViewModel?) { + switch model?.contentMode { + case .scaleToFill: + imageView.contentMode = .scaleToFill + break + case .scaleAspectFit: + imageView.contentMode = .scaleAspectFit + break + case .scaleAspectFill: + imageView.contentMode = .scaleAspectFill + break + case .redraw: + imageView.contentMode = .redraw + break + case .center: + imageView.contentMode = .center + break + case .top: + imageView.contentMode = .top + break + case .bottom: + imageView.contentMode = .bottom + break + case .left: + imageView.contentMode = .left + break + case .right: + imageView.contentMode = .right + break + case .topLeft: + imageView.contentMode = .topLeft + break + case .topRight: + imageView.contentMode = .topRight + break + case .bottomLeft: + imageView.contentMode = .bottomLeft + break + case .bottomRight: + imageView.contentMode = .bottomRight + break + default: + break + } + } // MARK: - MVMCoreUIMoleculeViewProtocol functions diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 1fbe98e7..8d649995 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -18,5 +18,6 @@ import Foundation public init(headline: LabelModel) { self.headline = headline + moleculeName = Self.identifier } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index 7bdccc8e..fb29096c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -22,8 +22,8 @@ @"stack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], @"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]], @"list" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], - @"threeLayer" : - [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]] + @"threeLayer": [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]], + @"isaacLanding": [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[IsaacLandingTemplate class]] } mutableCopy]; }); return viewControllerMapping; diff --git a/MVMCoreUI/Templates/IsaacLandingTemplate.swift b/MVMCoreUI/Templates/IsaacLandingTemplate.swift new file mode 100644 index 00000000..f6924c12 --- /dev/null +++ b/MVMCoreUI/Templates/IsaacLandingTemplate.swift @@ -0,0 +1,100 @@ +// +// IsaacLandingTemplate.swift +// MVMCoreUI +// +// Created by Suresh, Kamlesh on 2/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + +open class IsaacLandingTemplate: MoleculeListTemplate { + + func parseTemplateJSON() throws { + + } + + @objc public override func parsePageJSON() throws { + guard let pageJSON = self.loadObject?.pageJSON else { return } + + var listItems: [MoleculeListItemModel] = [] + (pageJSON.arrayForKey("items") as? [[AnyHashable: Any]])?.forEach { (itemJson) in + if let item = getListItem(itemJson) { + listItems.append(item) + } + } + + let template = ListPageTemplateModel(pageType: pageJSON.stringForkey(KeyPageType), + screenHeading: pageJSON.stringForkey(KeyScreenHeading), + molecules: listItems) + + + self.templateModel = template + } + + func getListItem(_ moleculeJson: [AnyHashable: Any]) -> MoleculeListItemModel? { + guard let type = moleculeJson.optionalStringForKey("type") else { + return nil + } + + if type == "rewards" { + return getRewardListItem(moleculeJson) + } + + let textcolor = moleculeJson.optionalStringForKey("textColor") + var stackItems: [MoleculeStackItemModel] = [] + + let titleLabel = LabelModel(text: moleculeJson.stringForkey(KeyTitle)) + titleLabel.fontName = "NHaasGroteskDSStd-75Bd" + titleLabel.textColor = textcolor + titleLabel.fontSize = (type == "topHeader") ? 70.0 : 25.0 + + + let messageLabel = LabelModel(text: moleculeJson.stringForkey("message")) + messageLabel.fontStyle = "B2" + messageLabel.textColor = textcolor + + let headlineBodyModel = HeadlineBodyModel(headline: titleLabel) + headlineBodyModel.body = messageLabel + + if let linkMap = moleculeJson.optionalDictionaryForKey("link") { + do { + let linkDict: [String : Any] = ["title": linkMap.stringForkey(KeyTitle), + "action": linkMap] + let data = try JSONSerialization.data(withJSONObject: linkDict) + let decoder = JSONDecoder() + let linkModel = try decoder.decode(LinkModel.self, from: data) + linkModel.textColor = Color(uiColor: UIColor.mfGet(forHex: textcolor ?? "#FFFFFF")) + let headlineBodyLinkModel = HeadlineBodyLinkModel(headlineBody: headlineBodyModel, + link: linkModel) + stackItems.append(MoleculeStackItemModel(with: headlineBodyLinkModel)) + } catch { + + } + } else { + stackItems.append(MoleculeStackItemModel(with: headlineBodyModel)) + } + + if let imageurl = moleculeJson.optionalStringForKey("imageUrl") { + let imageModel = ImageViewModel(image: imageurl) + imageModel.height = moleculeJson.optionalCGFloatForKey("imageHeight") ?? 300 + imageModel.imageFormat = "jpeg" + imageModel.contentMode = .scaleAspectFit + stackItems.append(MoleculeStackItemModel(with: imageModel)) + } + + let stack = MoleculeStackModel(molecules: stackItems) + let listItem = MoleculeListItemModel(with: stack) + + let backgroudColorString = moleculeJson.optionalStringForKey("backgroundColor") ?? "#000000" + listItem.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: backgroudColorString)) + listItem.line = LineModel(type: .none) + return listItem + } + + func getRewardListItem(_ moleculeJson: [AnyHashable: Any]) -> MoleculeListItemModel? { + return nil + } +} + From 87dcde33176eead722a6c6399f9496f6a6d14ff4 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 12:11:57 -0500 Subject: [PATCH 03/12] WIP --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 8 + .../Views/Label/LabelAttributeModel.swift | 8 +- MVMCoreUI/Atoms/Views/Label/LabelModel.swift | 1 + MVMCoreUI/BaseClasses/Button.swift | 7 +- MVMCoreUI/Molecules/FooterModel.swift | 2 + .../TwoButtonViewModel.swift | 5 + .../Items/MoleculeStackItemModel.swift | 2 + .../Templates/IsaacLandingTemplate.swift | 190 +++++++++++++----- 8 files changed, 171 insertions(+), 52 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index cfe8bb2f..5640996f 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -39,12 +39,20 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action + moleculeName = Self.identifier } init(secondaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .secondary + moleculeName = Self.identifier + } + + init(primaryButtonWith title: String, action: ActionModelProtocol) { + self.title = title + self.action = action + style = .primary } private enum CodingKeys: String, CodingKey { diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift index 22bb10d8..3c073b2f 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift @@ -28,7 +28,13 @@ import Foundation var type: String var location: Int var length: Int - + + init(_ type: String, _ location: Int, _ length: Int) { + self.type = type + self.location = location + self.length = length + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index a177f414..76597b44 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -48,6 +48,7 @@ import Foundation public init(text: String) { self.text = text + moleculeName = Self.identifier } required public init(from decoder: Decoder) throws { diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index a780151a..24378184 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -88,12 +88,13 @@ public typealias ButtonAction = (Button) -> () // MARK:- ModelMoleculeViewProtocol open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model - if let backgroundColor = model?.backgroundColor { - self.backgroundColor = backgroundColor.uiColor - } guard let model = model as? ButtonModelProtocol else { return } isEnabled = model.enabled + + if let backgroundColor = (model as? MoleculeModelProtocol)?.backgroundColor { + self.backgroundColor = backgroundColor.uiColor + } set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Molecules/FooterModel.swift b/MVMCoreUI/Molecules/FooterModel.swift index d61d1194..57a81f8b 100644 --- a/MVMCoreUI/Molecules/FooterModel.swift +++ b/MVMCoreUI/Molecules/FooterModel.swift @@ -12,6 +12,7 @@ import Foundation @objcMembers public class FooterModel: MoleculeContainerModel, MoleculeModelProtocol { public static var identifier: String = "footer" public var backgroundColor: Color? + public var moleculeName: String? private enum CodingKeys: String, CodingKey { case moleculeName @@ -37,6 +38,7 @@ import Foundation public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) setDefaults() + moleculeName = Self.identifier } required public init(from decoder: Decoder) throws { diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 5938692b..70d3f743 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -10,6 +10,7 @@ import UIKit public class TwoButtonViewModel: MoleculeModelProtocol { public static var identifier: String = "twoButtonView" + public var moleculeName: String? public var backgroundColor: Color? public var primaryButton: ButtonModel? public var secondaryButton: ButtonModel? @@ -21,6 +22,10 @@ public class TwoButtonViewModel: MoleculeModelProtocol { case secondaryButton } + init() { + moleculeName = Self.identifier + } + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift index 4731ef34..2b23f405 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift @@ -13,6 +13,7 @@ import Foundation public var backgroundColor: Color? public var spacing: CGFloat? public var percent: Int? + public var moleculeName: String? public var gone: Bool = false private enum CodingKeys: String, CodingKey { @@ -24,6 +25,7 @@ import Foundation public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) + moleculeName = Self.identifier } required public init(from decoder: Decoder) throws { diff --git a/MVMCoreUI/Templates/IsaacLandingTemplate.swift b/MVMCoreUI/Templates/IsaacLandingTemplate.swift index f6924c12..99c716d6 100644 --- a/MVMCoreUI/Templates/IsaacLandingTemplate.swift +++ b/MVMCoreUI/Templates/IsaacLandingTemplate.swift @@ -29,8 +29,59 @@ open class IsaacLandingTemplate: MoleculeListTemplate { screenHeading: pageJSON.stringForkey(KeyScreenHeading), molecules: listItems) - + let backgroudColorString = pageJSON.optionalStringForKey("backgroundColor") ?? "#000000" + template.footer = setFooter(pageJSON, template) + //print(template.toJSONString()) self.templateModel = template + + DispatchQueue.main.async { [weak self] in + self?.view.backgroundColor = UIColor.mfGet(forHex: backgroudColorString) + } + } + + func setFooter(_ pageJSON: [AnyHashable: Any], _ template: ListPageTemplateModel) -> FooterModel? { + + let primaryButtonBGColor = pageJSON.optionalStringForKey("primaryButtonBGColor") ?? "#FFFFFF" + let primaryButtonTextColor = pageJSON.optionalStringForKey("primaryButtonTextColor") ?? "#000000" + + let backgroudColorString = pageJSON.optionalStringForKey("backgroundColor") ?? "#000000" + if let buttonMap = pageJSON.optionalDictionaryForKey("ButtonMap") { + let twoButtonModel = TwoButtonViewModel() + + if let primarybutton = buttonMap.optionalDictionaryForKey(KeyPrimaryButton) { + let buttonDict: [String : Any] = ["title": primarybutton.stringForkey(KeyTitle), + "action": primarybutton, + "moleculeName": "button"] + if let data = try? JSONSerialization.data(withJSONObject: buttonDict) { + let decoder = JSONDecoder() + twoButtonModel.primaryButton = try? decoder.decode(ButtonModel.self, from: data) + twoButtonModel.primaryButton?.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonBGColor)) + twoButtonModel.primaryButton?.textColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonTextColor)) + } + } + if let secondaryButton = buttonMap.optionalDictionaryForKey(KeySecondaryButton) { + let buttonDict: [String : Any] = ["title": secondaryButton.stringForkey(KeyTitle), + "action": secondaryButton, + "moleculeName": "button"] + if let data = try? JSONSerialization.data(withJSONObject: buttonDict) { + let decoder = JSONDecoder() + twoButtonModel.secondaryButton = try? decoder.decode(ButtonModel.self, from: data) + twoButtonModel.secondaryButton?.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonTextColor)) + twoButtonModel.secondaryButton?.textColor = Color(uiColor: UIColor.mfGet(forHex:primaryButtonBGColor)) + } + } + + let footerStack = MoleculeStackModel(molecules: [MoleculeStackItemModel(with:LineModel(type: .standard)), + MoleculeStackItemModel(with: twoButtonModel)]) + footerStack.useHorizontalMargins = false + footerStack.spacing = PaddingFour + + let footer = FooterModel(with: footerStack) + footer.useHorizontalMargins = false + footer.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: backgroudColorString)) + return footer + } + return nil } func getListItem(_ moleculeJson: [AnyHashable: Any]) -> MoleculeListItemModel? { @@ -40,61 +91,104 @@ open class IsaacLandingTemplate: MoleculeListTemplate { if type == "rewards" { return getRewardListItem(moleculeJson) - } - - let textcolor = moleculeJson.optionalStringForKey("textColor") - var stackItems: [MoleculeStackItemModel] = [] - - let titleLabel = LabelModel(text: moleculeJson.stringForkey(KeyTitle)) - titleLabel.fontName = "NHaasGroteskDSStd-75Bd" - titleLabel.textColor = textcolor - titleLabel.fontSize = (type == "topHeader") ? 70.0 : 25.0 - - - let messageLabel = LabelModel(text: moleculeJson.stringForkey("message")) - messageLabel.fontStyle = "B2" - messageLabel.textColor = textcolor - - let headlineBodyModel = HeadlineBodyModel(headline: titleLabel) - headlineBodyModel.body = messageLabel - - if let linkMap = moleculeJson.optionalDictionaryForKey("link") { - do { - let linkDict: [String : Any] = ["title": linkMap.stringForkey(KeyTitle), - "action": linkMap] - let data = try JSONSerialization.data(withJSONObject: linkDict) - let decoder = JSONDecoder() - let linkModel = try decoder.decode(LinkModel.self, from: data) - linkModel.textColor = Color(uiColor: UIColor.mfGet(forHex: textcolor ?? "#FFFFFF")) - let headlineBodyLinkModel = HeadlineBodyLinkModel(headlineBody: headlineBodyModel, - link: linkModel) - stackItems.append(MoleculeStackItemModel(with: headlineBodyLinkModel)) - } catch { - - } } else { - stackItems.append(MoleculeStackItemModel(with: headlineBodyModel)) + return getTitleImageListItem(moleculeJson, type) } + } - if let imageurl = moleculeJson.optionalStringForKey("imageUrl") { - let imageModel = ImageViewModel(image: imageurl) - imageModel.height = moleculeJson.optionalCGFloatForKey("imageHeight") ?? 300 - imageModel.imageFormat = "jpeg" - imageModel.contentMode = .scaleAspectFit - stackItems.append(MoleculeStackItemModel(with: imageModel)) - } + func getTitleImageListItem(_ moleculeJson: [AnyHashable: Any], _ type: String) -> MoleculeListItemModel? { + let textcolor = moleculeJson.optionalStringForKey("textColor") + var stackItems: [MoleculeStackItemModel] = [] - let stack = MoleculeStackModel(molecules: stackItems) - let listItem = MoleculeListItemModel(with: stack) + let titleLabel = LabelModel(text: moleculeJson.stringForkey(KeyTitle)) + titleLabel.fontName = "NHaasGroteskDSStd-75Bd" + titleLabel.textColor = textcolor + titleLabel.fontSize = (type == "topHeader") ? 70.0 : 25.0 - let backgroudColorString = moleculeJson.optionalStringForKey("backgroundColor") ?? "#000000" - listItem.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: backgroudColorString)) - listItem.line = LineModel(type: .none) - return listItem + let messageLabel = LabelModel(text: moleculeJson.stringForkey("message")) + messageLabel.fontStyle = "B2" + messageLabel.textColor = textcolor + + let headlineBodyModel = HeadlineBodyModel(headline: titleLabel) + headlineBodyModel.body = messageLabel + + if let linkMap = moleculeJson.optionalDictionaryForKey("link") { + do { + let linkDict: [String : Any] = ["title": linkMap.stringForkey(KeyTitle), + "action": linkMap] + let data = try JSONSerialization.data(withJSONObject: linkDict) + let decoder = JSONDecoder() + let linkModel = try decoder.decode(LinkModel.self, from: data) + linkModel.textColor = Color(uiColor: UIColor.mfGet(forHex: textcolor ?? "#FFFFFF")) + let headlineBodyLinkModel = HeadlineBodyLinkModel(headlineBody: headlineBodyModel, + link: linkModel) + stackItems.append(MoleculeStackItemModel(with: headlineBodyLinkModel)) + } catch { + stackItems.append(MoleculeStackItemModel(with: headlineBodyModel)) + } + } else { + stackItems.append(MoleculeStackItemModel(with: headlineBodyModel)) + } + + if let imageurl = moleculeJson.optionalStringForKey("imageUrl") { + let imageModel = ImageViewModel(image: imageurl) + imageModel.height = moleculeJson.optionalCGFloatForKey("imageHeight") ?? 300 + imageModel.imageFormat = "jpeg" + imageModel.contentMode = .scaleAspectFit + stackItems.append(MoleculeStackItemModel(with: imageModel)) + } + + let stack = MoleculeStackModel(molecules: stackItems) + let listItem = MoleculeListItemModel(with: stack) + + let backgroudColorString = moleculeJson.optionalStringForKey("backgroundColor") ?? "#000000" + listItem.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: backgroudColorString)) + listItem.line = LineModel(type: .none) + return listItem } func getRewardListItem(_ moleculeJson: [AnyHashable: Any]) -> MoleculeListItemModel? { - return nil + + var stackItems: [MoleculeStackItemModel] = [] + + (moleculeJson.arrayForKey("rewards") as? [[AnyHashable: Any]])?.forEach { (rewardItem) in + let textcolor = rewardItem.optionalStringForKey("textColor") + + let titleLabel = LabelModel(text: rewardItem.stringForkey(KeyTitle)) + titleLabel.fontName = "NHaasGroteskDSStd-75Bd" + titleLabel.textColor = textcolor + titleLabel.fontSize = 48 + + let messageLabel = LabelModel(text: rewardItem.stringForkey("message")) + messageLabel.fontName = "NHaasGroteskDSStd-75Bd" + messageLabel.textColor = textcolor + messageLabel.fontSize = 14 + + let titleStackItem = MoleculeStackItemModel(with: titleLabel) + let messageStackItem = MoleculeStackItemModel(with: messageLabel) + + let itemStack = MoleculeStackModel(molecules: [titleStackItem, messageStackItem]) + itemStack.useVerticalMargins = false + itemStack.topMarginPadding = 0 + + itemStack.verticalAlignment = .leading + itemStack.axis = .vertical + itemStack.spacing = 0 + + stackItems.append(MoleculeStackItemModel(with: itemStack)) + } + + let stack = MoleculeStackModel(molecules: stackItems) + stack.axis = .horizontal + stack.spacing = 65 + stack.verticalAlignment = .leading + + let listItem = MoleculeListItemModel(with: stack) + let backgroudColorString = moleculeJson.optionalStringForKey("backgroundColor") ?? "#000000" + listItem.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: backgroudColorString)) + listItem.line = LineModel(type: .none) + + return listItem } } From 06fe32f37b9a118fcf34fcb821f66340d93e63e8 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 17 Feb 2020 12:21:32 -0500 Subject: [PATCH 04/12] changing pumpkin to orange for design update. --- MVMCoreUI/Categories/UIColor+Extension.swift | 177 ++++++++++++++++--- MVMCoreUI/Categories/UIColor+MFConvenience.h | 1 + MVMCoreUI/Categories/UIColor+MFConvenience.m | 5 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 2 +- 4 files changed, 162 insertions(+), 23 deletions(-) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 55a10c03..94bf780d 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -12,24 +12,52 @@ public typealias ColorHexTuple = (uiColor: UIColor, hex: String) extension UIColor { + //-------------------------------------------------- + // MARK: - Convenience Dictionary + //-------------------------------------------------- /// Dictionary to access brand approved colors by name. public static let names: [String: ColorHexTuple] = ["black": (.mvmBlack, "#000000"), "white": (.mvmWhite, "#FFFFFF"), "red": (.mvmRed, "#D52B1E"), - "orange": (.mvmOrange, "#CC4D0F"), - "green": (.mvmGreen, "#008631"), - "blue": (.mvmBlue, "#007AB8"), - "blueGradient": (.mvmBlueGradient, "#007AB8"), + "pink": (.mvmPink, "#D90368"), + "pink33": (.mvmPink33, "#F2ABCD"), + "pink66": (.mvmPink66, "#E6589B"), + "pinkShade1": (.mvmPinkShade1, "#B31C63"), + "pinkShade2": (.mvmPinkShade2, "#830842"), + "purple": (.mvmPurple, "#8C00AC"), + "purple33": (.mvmPurple33, "#D9ABE4"), + "purple66": (.mvmPurple66, "#B356C8"), + "purpleShade1": (.mvmPurpleShade1, "#6C177F"), + "purpleShade2": (.mvmPurpleShade2, "#4A0E58"), + "green": (.mvmGreen, "#008330"), + "green33": (.mvmGreen33, "#ABE4BF"), + "green66": (.mvmGreen66, "#57C880"), + "greenShade1": (.mvmGreenShade1, "#178437"), + "greenShade2": (.mvmGreenShade2, "#0F5B25"), + "orange": (.mvmOrange, "#ED7000"), + "orange66": (.mvmOrange66, "#F3A157"), + "orange33": (.mvmOrange33, "#F9D0AB"), + "orangeShade1": (.mvmOrangeShade1, "#CB5F00"), + "orangeShade2": (.mvmOrangeShade2, "#984700"), + "orangeAA": (.mvmOrangeAA, "#CC4D0F"), + "blue": (.mvmBlue, "#0077B4"), + "blue33": (.mvmBlue33, "#57B1DF"), + "blue66": (.mvmBlue66, "#57B1DF"), + "blueShade1": (.mvmBlueShade1, "#136598"), + "blueShade2": (.mvmBlueShade2, "#0B4467"), "yellow": (.mvmYellow, "#FFBC3D"), + "yellow33": (.mvmYellow33, "#FFE9BF"), + "yellow66": (.mvmYellow66, "#FFD37F"), + "yellowShade1": (.mvmYellowShade1, "#CC9630"), + "yellowShade2": (.mvmYellowShade2, "#997126"), "coolGray1": (.mvmCoolGray1, "#F6F6F6"), "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), "coolGray10": (.mvmCoolGray10, "#333333"), - "vzupGold": (.vzupGold, "#B89B56"), - "vzupYellow1": (.vzupYellow1, "#F9D542"), - "vzupYellow2": (.vzupYellow2, "#F4CA53"), - "vzupYellow3": (.vzupYellow3, "#CC9B2D")] + "upGold1": (.vzupGold1, "#F9D542"), + "upGold2": (.vzupGold2, "#F4CA53"), + "upGold3": (.vzupGold3, "#CC9B2D")] //-------------------------------------------------- // MARK: - Brand @@ -41,24 +69,134 @@ extension UIColor { /// HEX: #FFFFFF public static let mvmWhite = UIColor.white + //-------------------------------------------------- + // MARK: - Red + //-------------------------------------------------- + /// HEX: #D52B1E public static let mvmRed = UIColor.color8Bits(red: 213, green: 43, blue: 30) + //-------------------------------------------------- + // MARK: - Pink + //-------------------------------------------------- + + /// HEX: #D90368 + public static let mvmPink = UIColor.color8Bits(red: 217, green: 3, blue: 104) + + /// HEX: #F2ABCD + public static let mvmPink33 = UIColor.color8Bits(red: 242, green: 171, blue: 205) + + /// HEX: #E6589B + public static let mvmPink66 = UIColor.color8Bits(red: 230, green: 88, blue: 155) + + /// HEX: #B31C63 + public static let mvmPinkShade1 = UIColor.color8Bits(red: 179, green: 28, blue: 99) + + /// HEX: #830842 + public static let mvmPinkShade2 = UIColor.color8Bits(red: 131, green: 8, blue: 66) + + //-------------------------------------------------- + // MARK: - Purple + //-------------------------------------------------- + + /// HEX: #8C00AC + public static let mvmPurple = UIColor.color8Bits(red: 140, green: 0, blue: 172) + + /// HEX: #D9ABE4 + public static let mvmPurple33 = UIColor.color8Bits(red: 217, green: 171, blue: 228) + + /// HEX: #B356C8 + public static let mvmPurple66 = UIColor.color8Bits(red: 179, green: 86, blue: 200) + + /// HEX: #6C177F + public static let mvmPurpleShade1 = UIColor.color8Bits(red: 108, green: 23, blue: 127) + + /// HEX: #4A0E58 + public static let mvmPurpleShade2 = UIColor.color8Bits(red: 74, green: 14, blue: 88) + + //-------------------------------------------------- + // MARK: - Orange + //-------------------------------------------------- + + /// HEX: #ED7000 + public static let mvmOrange = UIColor.color8Bits(red: 237, green: 112, blue: 0) + /// HEX: #CC4D0F - public static let mvmOrange = UIColor.color8Bits(red: 204, green: 77, blue: 15) + public static let mvmOrangeAA = UIColor.color8Bits(red: 204, green: 77, blue: 15) - /// HEX: #008631 - public static let mvmGreen = UIColor.color8Bits(red: 0, green: 134, blue: 49) + /// HEX: #F9D0AB + public static let mvmOrange33 = UIColor.color8Bits(red: 249, green: 208, blue: 171) - /// HEX: #007AB8 - public static let mvmBlue = UIColor.color8Bits(red: 0, green: 122, blue: 184) + /// HEX: #F3A157 + public static let mvmOrange66 = UIColor.color8Bits(red: 243, green: 161, blue: 87) - /// HEX: #007AB8 - public static let mvmBlueGradient = UIColor.color8Bits(red: 0, green: 122, blue: 184) + /// HEX: #CB5F00 + public static let mvmOrangeShade1 = UIColor.color8Bits(red: 203, green: 95, blue: 0) + + /// HEX: #984700 + public static let mvmOrangeShade2 = UIColor.color8Bits(red: 152, green: 71, blue: 0) + + //-------------------------------------------------- + // MARK: - Green + //-------------------------------------------------- + + /// HEX: #008330 + public static let mvmGreen = UIColor.color8Bits(red: 0, green: 134, blue: 48) + + /// HEX: #ABE4BF + public static let mvmGreen33 = UIColor.color8Bits(red: 171, green: 228, blue: 191) + + /// HEX: #57C880 + public static let mvmGreen66 = UIColor.color8Bits(red: 87, green: 200, blue: 128) + + /// HEX: #178437 + public static let mvmGreenShade1 = UIColor.color8Bits(red: 23, green: 132, blue: 55) + + /// HEX: #0F5B25 + public static let mvmGreenShade2 = UIColor.color8Bits(red: 15, green: 91, blue: 37) + + //-------------------------------------------------- + // MARK: - Blue + //-------------------------------------------------- + + /// HEX: #0077B4 + public static let mvmBlue = UIColor.color8Bits(red: 0, green: 119, blue: 180) + + /// HEX: #57B1DF + public static let mvmBlue33 = UIColor.color8Bits(red: 87, green: 177, blue: 223) + + /// HEX: #57B1DF + public static let mvmBlue66 = UIColor.color8Bits(red: 87, green: 177, blue: 223) + + /// HEX: #136598 + public static let mvmBlueShade1 = UIColor.color8Bits(red: 19, green: 101, blue: 152) + + /// HEX: #0B4467 + public static let mvmBlueShade2 = UIColor.color8Bits(red: 11, green: 68, blue: 103) + + //-------------------------------------------------- + // MARK: - Yellow + //-------------------------------------------------- /// HEX: #FFBC3D public static let mvmYellow = UIColor.color8Bits(red: 255, green: 188, blue: 61) + /// HEX: #FFE9BF + public static let mvmYellow33 = UIColor.color8Bits(red: 255, green: 233, blue: 191) + + /// HEX: #FFD37F + public static let mvmYellow66 = UIColor.color8Bits(red: 255, green: 211, blue: 127) + + /// HEX: #CC9630 + public static let mvmYellowShade1 = UIColor.color8Bits(red: 204, green: 150, blue: 48) + + /// HEX: #997126 + public static let mvmYellowShade2 = UIColor.color8Bits(red: 153, green: 113, blue: 38) + + //-------------------------------------------------- + // MARK: - Gray + //-------------------------------------------------- + /// HEX: #F6F6F6 public static let mvmCoolGray1 = UIColor.grayscale(rgb: 246) @@ -75,17 +213,14 @@ extension UIColor { // MARK: - VZ UP Brand //-------------------------------------------------- - /// HEX: #B89B56 - public static let vzupGold = UIColor.color8Bits(red: 184, green: 155, blue: 68) - /// HEX: #F9D542 - public static let vzupYellow1 = UIColor.color8Bits(red: 249, green: 213, blue: 66) + public static let vzupGold1 = UIColor.color8Bits(red: 249, green: 213, blue: 66) /// HEX: #F4CA53 - public static let vzupYellow2 = UIColor.color8Bits(red: 244, green: 202, blue: 83) + public static let vzupGold2 = UIColor.color8Bits(red: 244, green: 202, blue: 83) /// HEX: #CC9B2D - public static let vzupYellow3 = UIColor.color8Bits(red: 204, green: 155, blue: 45) + public static let vzupGold3 = UIColor.color8Bits(red: 204, green: 155, blue: 45) //-------------------------------------------------- // MARK: - Functions diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index 4a51a13b..c3c78c7a 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -21,6 +21,7 @@ + (nonnull UIColor *)mfLightSilver; + (nonnull UIColor *)mfDarkSilver; + (nonnull UIColor *)mfTomatoRed; ++ (nonnull UIColor *)mvmOrange; + (nonnull UIColor *)mfPumpkinColor; + (nonnull UIColor *)mfShamrock; + (nonnull UIColor *)mfCerulean; diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index e56d89bc..6ff8f70f 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -37,7 +37,6 @@ return [UIColor mfColor8bitsWithRed:198 green:197 blue:197 alpha:1.0]; } - + (nonnull UIColor *)mfPrimaryButtonHighlightBlackColor { return [UIColor mfColor8bitsWithRed:51 green:51 blue:51 alpha:1.0]; } @@ -54,6 +53,10 @@ return [UIColor mfColor8bitsWithRed:204 green:77 blue:15 alpha:1.0]; } ++ (nonnull UIColor *)mvmOrange { + return [UIColor mfColor8bitsWithRed:237 green:112 blue:0 alpha:1.0]; +} + + (nonnull UIColor *)mfShamrock { return [UIColor mfColor8bitsWithRed:0 green:134 blue:49 alpha:1.0]; } diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 947e6ffc..d0a027b3 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -108,7 +108,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; - (nonnull UIColor *)getBackgroundColorForType:(nullable NSString *)type { if ([type isEqualToString:ValueTypeError]) { - return [UIColor mfPumpkinColor]; + return [UIColor mvmOrange]; } else { return [UIColor mfShamrock]; } From cf4832bca7984053da7e029de9857e57444d6d90 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 13:39:13 -0500 Subject: [PATCH 05/12] fixes --- MVMCoreUI/Templates/IsaacLandingTemplate.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Templates/IsaacLandingTemplate.swift b/MVMCoreUI/Templates/IsaacLandingTemplate.swift index 99c716d6..0001c744 100644 --- a/MVMCoreUI/Templates/IsaacLandingTemplate.swift +++ b/MVMCoreUI/Templates/IsaacLandingTemplate.swift @@ -168,19 +168,19 @@ open class IsaacLandingTemplate: MoleculeListTemplate { let messageStackItem = MoleculeStackItemModel(with: messageLabel) let itemStack = MoleculeStackModel(molecules: [titleStackItem, messageStackItem]) - itemStack.useVerticalMargins = false - itemStack.topMarginPadding = 0 - - itemStack.verticalAlignment = .leading - itemStack.axis = .vertical + itemStack.verticalAlignment = .top itemStack.spacing = 0 - stackItems.append(MoleculeStackItemModel(with: itemStack)) + let horizontalStack = MoleculeStackItemModel(with: itemStack) + horizontalStack.verticalAlignment = .top + stackItems.append(horizontalStack) } + stackItems.first?.percent = 35 + stackItems.last?.percent = 65 let stack = MoleculeStackModel(molecules: stackItems) stack.axis = .horizontal - stack.spacing = 65 + stack.horizontalAlignment = .leading stack.verticalAlignment = .leading let listItem = MoleculeListItemModel(with: stack) From 6de4fc486445b1f0c66557ee520698c458e1fcbe Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 14:19:17 -0500 Subject: [PATCH 06/12] fill color --- MVMCoreUI/BaseClasses/Button.swift | 9 ++++----- MVMCoreUI/Templates/IsaacLandingTemplate.swift | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 24378184..60e0ab1a 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -88,13 +88,12 @@ public typealias ButtonAction = (Button) -> () // MARK:- ModelMoleculeViewProtocol open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model - - guard let model = model as? ButtonModelProtocol else { return } - isEnabled = model.enabled - - if let backgroundColor = (model as? MoleculeModelProtocol)?.backgroundColor { + if let backgroundColor = model?.backgroundColor { self.backgroundColor = backgroundColor.uiColor } + + guard let model = model as? ButtonModelProtocol else { return } + isEnabled = model.enabled set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Templates/IsaacLandingTemplate.swift b/MVMCoreUI/Templates/IsaacLandingTemplate.swift index 0001c744..c3d9e9cb 100644 --- a/MVMCoreUI/Templates/IsaacLandingTemplate.swift +++ b/MVMCoreUI/Templates/IsaacLandingTemplate.swift @@ -55,7 +55,7 @@ open class IsaacLandingTemplate: MoleculeListTemplate { if let data = try? JSONSerialization.data(withJSONObject: buttonDict) { let decoder = JSONDecoder() twoButtonModel.primaryButton = try? decoder.decode(ButtonModel.self, from: data) - twoButtonModel.primaryButton?.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonBGColor)) + twoButtonModel.primaryButton?.fillColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonBGColor)) twoButtonModel.primaryButton?.textColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonTextColor)) } } @@ -66,7 +66,7 @@ open class IsaacLandingTemplate: MoleculeListTemplate { if let data = try? JSONSerialization.data(withJSONObject: buttonDict) { let decoder = JSONDecoder() twoButtonModel.secondaryButton = try? decoder.decode(ButtonModel.self, from: data) - twoButtonModel.secondaryButton?.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonTextColor)) + twoButtonModel.secondaryButton?.fillColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonTextColor)) twoButtonModel.secondaryButton?.textColor = Color(uiColor: UIColor.mfGet(forHex:primaryButtonBGColor)) } } From 438661dfe1fe1edf4a4ca4cbbc4f9927021fca9a Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 15:05:02 -0500 Subject: [PATCH 07/12] moleculeName --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 6 ++---- MVMCoreUI/Atoms/Views/ImageViewModel.swift | 2 -- MVMCoreUI/Atoms/Views/Label/LabelModel.swift | 4 ---- MVMCoreUI/Molecules/FooterModel.swift | 2 -- .../HorizontalCombinationViews/TwoButtonViewModel.swift | 5 +---- MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift | 4 +--- .../VerticalCombinationViews/HeadlineBodyModel.swift | 2 -- 7 files changed, 4 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 5640996f..2f5e0042 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -20,7 +20,6 @@ public enum ButtonSize: String, Codable { public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { public static var identifier: String = "button" - public var moleculeName: String? public var backgroundColor: Color? public var title: String public var action: ActionModelProtocol @@ -39,14 +38,14 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action - moleculeName = Self.identifier + //moleculeName = Self.identifier } init(secondaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .secondary - moleculeName = Self.identifier + //moleculeName = Self.identifier } init(primaryButtonWith title: String, action: ActionModelProtocol) { @@ -75,7 +74,6 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) title = try typeContainer.decode(String.self, forKey: .title) diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index f8443da5..497b0c86 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -11,7 +11,6 @@ import Foundation @objcMembers public class ImageViewModel: MoleculeModelProtocol { public static var identifier: String = "image" public var backgroundColor: Color? - public var moleculeName: String? public var image: String public var accessibilityText: String? public var fallbackImage: String? @@ -38,6 +37,5 @@ import Foundation public init(image: String) { self.image = image - moleculeName = Self.identifier } } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift index 76597b44..d7fb4fa3 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelModel.swift @@ -11,9 +11,7 @@ import Foundation @objcMembers public class LabelModel: MoleculeModelProtocol { public static var identifier: String = "label" - public var moleculeName: String? public var backgroundColor: Color? - public var text: String public var accessibilityText: String? public var textColor: String? @@ -48,12 +46,10 @@ import Foundation public init(text: String) { self.text = text - moleculeName = Self.identifier } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) text = try typeContainer.decode(String.self, forKey: .text) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor) diff --git a/MVMCoreUI/Molecules/FooterModel.swift b/MVMCoreUI/Molecules/FooterModel.swift index 57a81f8b..d61d1194 100644 --- a/MVMCoreUI/Molecules/FooterModel.swift +++ b/MVMCoreUI/Molecules/FooterModel.swift @@ -12,7 +12,6 @@ import Foundation @objcMembers public class FooterModel: MoleculeContainerModel, MoleculeModelProtocol { public static var identifier: String = "footer" public var backgroundColor: Color? - public var moleculeName: String? private enum CodingKeys: String, CodingKey { case moleculeName @@ -38,7 +37,6 @@ import Foundation public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) setDefaults() - moleculeName = Self.identifier } required public init(from decoder: Decoder) throws { diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 70d3f743..4ddb1575 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -10,7 +10,6 @@ import UIKit public class TwoButtonViewModel: MoleculeModelProtocol { public static var identifier: String = "twoButtonView" - public var moleculeName: String? public var backgroundColor: Color? public var primaryButton: ButtonModel? public var secondaryButton: ButtonModel? @@ -22,9 +21,7 @@ public class TwoButtonViewModel: MoleculeModelProtocol { case secondaryButton } - init() { - moleculeName = Self.identifier - } + init() { } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) diff --git a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift index 2b23f405..dc01fd11 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeStackItemModel.swift @@ -13,7 +13,6 @@ import Foundation public var backgroundColor: Color? public var spacing: CGFloat? public var percent: Int? - public var moleculeName: String? public var gone: Bool = false private enum CodingKeys: String, CodingKey { @@ -25,9 +24,8 @@ import Foundation public override init(with moleculeModel: MoleculeModelProtocol) { super.init(with: moleculeModel) - moleculeName = Self.identifier } - + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 8d649995..fd5be23a 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -10,7 +10,6 @@ import Foundation @objcMembers public class HeadlineBodyModel: MoleculeModelProtocol { public static var identifier: String = "headlineBody" - public var moleculeName: String? public var headline: LabelModel? public var body: LabelModel? public var style: String? @@ -18,6 +17,5 @@ import Foundation public init(headline: LabelModel) { self.headline = headline - moleculeName = Self.identifier } } From 79eceb693ebdfa7421228f56216db207b288caa4 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 15:06:33 -0500 Subject: [PATCH 08/12] moleculeName --- MVMCoreUI/Atoms/Buttons/ButtonModel.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift index 2f5e0042..f02eaf5c 100644 --- a/MVMCoreUI/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atoms/Buttons/ButtonModel.swift @@ -38,14 +38,12 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol { init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action - //moleculeName = Self.identifier } init(secondaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .secondary - //moleculeName = Self.identifier } init(primaryButtonWith title: String, action: ActionModelProtocol) { From 347928a9b68b12e3c93e0870b21cdecd5ac8c9de Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 16:48:42 -0500 Subject: [PATCH 09/12] remove files --- MVMCoreUI.xcodeproj/project.pbxproj | 4 - .../MVMCoreUIViewControllerMappingObject.m | 3 +- .../Templates/IsaacLandingTemplate.swift | 194 ------------------ 3 files changed, 1 insertion(+), 200 deletions(-) delete mode 100644 MVMCoreUI/Templates/IsaacLandingTemplate.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6ac575a6..d114d2ae 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -50,7 +50,6 @@ 0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; }; 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; }; - 01B5E6B023F5F276005B5839 /* IsaacLandingTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01B5E6AF23F5F276005B5839 /* IsaacLandingTemplate.swift */; }; 01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D223CF9E740021F976 /* LabelToggleModel.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */; }; @@ -383,7 +382,6 @@ 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; - 01B5E6AF23F5F276005B5839 /* IsaacLandingTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IsaacLandingTemplate.swift; sourceTree = ""; }; 01C851D223CF9E740021F976 /* LabelToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggleModel.swift; sourceTree = ""; }; 01EB3683236097C0006832FA /* MoleculeModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeModelProtocol.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; @@ -1070,7 +1068,6 @@ D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */, 014AA72A23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift */, D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */, - 01B5E6AF23F5F276005B5839 /* IsaacLandingTemplate.swift */, ); path = Templates; sourceTree = ""; @@ -1813,7 +1810,6 @@ D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, - 01B5E6B023F5F276005B5839 /* IsaacLandingTemplate.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, C003506123AA94CD00B6AC29 /* Button.swift in Sources */, DBC4391B224421A0001AB423 /* CaretLink.swift in Sources */, diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m index fb29096c..5b9592cc 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIViewControllerMappingObject.m @@ -22,8 +22,7 @@ @"stack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]], @"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]], @"list" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]], - @"threeLayer": [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]], - @"isaacLanding": [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[IsaacLandingTemplate class]] + @"threeLayer" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]] } mutableCopy]; }); return viewControllerMapping; diff --git a/MVMCoreUI/Templates/IsaacLandingTemplate.swift b/MVMCoreUI/Templates/IsaacLandingTemplate.swift deleted file mode 100644 index c3d9e9cb..00000000 --- a/MVMCoreUI/Templates/IsaacLandingTemplate.swift +++ /dev/null @@ -1,194 +0,0 @@ -// -// IsaacLandingTemplate.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 2/13/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. -// - -import Foundation - - -open class IsaacLandingTemplate: MoleculeListTemplate { - - func parseTemplateJSON() throws { - - } - - @objc public override func parsePageJSON() throws { - guard let pageJSON = self.loadObject?.pageJSON else { return } - - var listItems: [MoleculeListItemModel] = [] - (pageJSON.arrayForKey("items") as? [[AnyHashable: Any]])?.forEach { (itemJson) in - if let item = getListItem(itemJson) { - listItems.append(item) - } - } - - let template = ListPageTemplateModel(pageType: pageJSON.stringForkey(KeyPageType), - screenHeading: pageJSON.stringForkey(KeyScreenHeading), - molecules: listItems) - - let backgroudColorString = pageJSON.optionalStringForKey("backgroundColor") ?? "#000000" - template.footer = setFooter(pageJSON, template) - //print(template.toJSONString()) - self.templateModel = template - - DispatchQueue.main.async { [weak self] in - self?.view.backgroundColor = UIColor.mfGet(forHex: backgroudColorString) - } - } - - func setFooter(_ pageJSON: [AnyHashable: Any], _ template: ListPageTemplateModel) -> FooterModel? { - - let primaryButtonBGColor = pageJSON.optionalStringForKey("primaryButtonBGColor") ?? "#FFFFFF" - let primaryButtonTextColor = pageJSON.optionalStringForKey("primaryButtonTextColor") ?? "#000000" - - let backgroudColorString = pageJSON.optionalStringForKey("backgroundColor") ?? "#000000" - if let buttonMap = pageJSON.optionalDictionaryForKey("ButtonMap") { - let twoButtonModel = TwoButtonViewModel() - - if let primarybutton = buttonMap.optionalDictionaryForKey(KeyPrimaryButton) { - let buttonDict: [String : Any] = ["title": primarybutton.stringForkey(KeyTitle), - "action": primarybutton, - "moleculeName": "button"] - if let data = try? JSONSerialization.data(withJSONObject: buttonDict) { - let decoder = JSONDecoder() - twoButtonModel.primaryButton = try? decoder.decode(ButtonModel.self, from: data) - twoButtonModel.primaryButton?.fillColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonBGColor)) - twoButtonModel.primaryButton?.textColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonTextColor)) - } - } - if let secondaryButton = buttonMap.optionalDictionaryForKey(KeySecondaryButton) { - let buttonDict: [String : Any] = ["title": secondaryButton.stringForkey(KeyTitle), - "action": secondaryButton, - "moleculeName": "button"] - if let data = try? JSONSerialization.data(withJSONObject: buttonDict) { - let decoder = JSONDecoder() - twoButtonModel.secondaryButton = try? decoder.decode(ButtonModel.self, from: data) - twoButtonModel.secondaryButton?.fillColor = Color(uiColor: UIColor.mfGet(forHex: primaryButtonTextColor)) - twoButtonModel.secondaryButton?.textColor = Color(uiColor: UIColor.mfGet(forHex:primaryButtonBGColor)) - } - } - - let footerStack = MoleculeStackModel(molecules: [MoleculeStackItemModel(with:LineModel(type: .standard)), - MoleculeStackItemModel(with: twoButtonModel)]) - footerStack.useHorizontalMargins = false - footerStack.spacing = PaddingFour - - let footer = FooterModel(with: footerStack) - footer.useHorizontalMargins = false - footer.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: backgroudColorString)) - return footer - } - return nil - } - - func getListItem(_ moleculeJson: [AnyHashable: Any]) -> MoleculeListItemModel? { - guard let type = moleculeJson.optionalStringForKey("type") else { - return nil - } - - if type == "rewards" { - return getRewardListItem(moleculeJson) - } else { - return getTitleImageListItem(moleculeJson, type) - } - } - - func getTitleImageListItem(_ moleculeJson: [AnyHashable: Any], _ type: String) -> MoleculeListItemModel? { - let textcolor = moleculeJson.optionalStringForKey("textColor") - var stackItems: [MoleculeStackItemModel] = [] - - let titleLabel = LabelModel(text: moleculeJson.stringForkey(KeyTitle)) - titleLabel.fontName = "NHaasGroteskDSStd-75Bd" - titleLabel.textColor = textcolor - titleLabel.fontSize = (type == "topHeader") ? 70.0 : 25.0 - - let messageLabel = LabelModel(text: moleculeJson.stringForkey("message")) - messageLabel.fontStyle = "B2" - messageLabel.textColor = textcolor - - let headlineBodyModel = HeadlineBodyModel(headline: titleLabel) - headlineBodyModel.body = messageLabel - - if let linkMap = moleculeJson.optionalDictionaryForKey("link") { - do { - let linkDict: [String : Any] = ["title": linkMap.stringForkey(KeyTitle), - "action": linkMap] - let data = try JSONSerialization.data(withJSONObject: linkDict) - let decoder = JSONDecoder() - let linkModel = try decoder.decode(LinkModel.self, from: data) - linkModel.textColor = Color(uiColor: UIColor.mfGet(forHex: textcolor ?? "#FFFFFF")) - let headlineBodyLinkModel = HeadlineBodyLinkModel(headlineBody: headlineBodyModel, - link: linkModel) - stackItems.append(MoleculeStackItemModel(with: headlineBodyLinkModel)) - } catch { - stackItems.append(MoleculeStackItemModel(with: headlineBodyModel)) - } - } else { - stackItems.append(MoleculeStackItemModel(with: headlineBodyModel)) - } - - if let imageurl = moleculeJson.optionalStringForKey("imageUrl") { - let imageModel = ImageViewModel(image: imageurl) - imageModel.height = moleculeJson.optionalCGFloatForKey("imageHeight") ?? 300 - imageModel.imageFormat = "jpeg" - imageModel.contentMode = .scaleAspectFit - stackItems.append(MoleculeStackItemModel(with: imageModel)) - } - - let stack = MoleculeStackModel(molecules: stackItems) - let listItem = MoleculeListItemModel(with: stack) - - let backgroudColorString = moleculeJson.optionalStringForKey("backgroundColor") ?? "#000000" - listItem.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: backgroudColorString)) - listItem.line = LineModel(type: .none) - return listItem - } - - func getRewardListItem(_ moleculeJson: [AnyHashable: Any]) -> MoleculeListItemModel? { - - var stackItems: [MoleculeStackItemModel] = [] - - (moleculeJson.arrayForKey("rewards") as? [[AnyHashable: Any]])?.forEach { (rewardItem) in - let textcolor = rewardItem.optionalStringForKey("textColor") - - let titleLabel = LabelModel(text: rewardItem.stringForkey(KeyTitle)) - titleLabel.fontName = "NHaasGroteskDSStd-75Bd" - titleLabel.textColor = textcolor - titleLabel.fontSize = 48 - - let messageLabel = LabelModel(text: rewardItem.stringForkey("message")) - messageLabel.fontName = "NHaasGroteskDSStd-75Bd" - messageLabel.textColor = textcolor - messageLabel.fontSize = 14 - - let titleStackItem = MoleculeStackItemModel(with: titleLabel) - let messageStackItem = MoleculeStackItemModel(with: messageLabel) - - let itemStack = MoleculeStackModel(molecules: [titleStackItem, messageStackItem]) - itemStack.verticalAlignment = .top - itemStack.spacing = 0 - - let horizontalStack = MoleculeStackItemModel(with: itemStack) - horizontalStack.verticalAlignment = .top - stackItems.append(horizontalStack) - } - - stackItems.first?.percent = 35 - stackItems.last?.percent = 65 - let stack = MoleculeStackModel(molecules: stackItems) - stack.axis = .horizontal - stack.horizontalAlignment = .leading - stack.verticalAlignment = .leading - - let listItem = MoleculeListItemModel(with: stack) - let backgroudColorString = moleculeJson.optionalStringForKey("backgroundColor") ?? "#000000" - listItem.backgroundColor = Color(uiColor: UIColor.mfGet(forHex: backgroudColorString)) - listItem.line = LineModel(type: .none) - - return listItem - } -} - From 68bf45f58310e40b2f96c9bd2a5984fffe5dbff7 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 17:35:20 -0500 Subject: [PATCH 10/12] content mode --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + MVMCoreUI/Atoms/Views/ImageViewModel.swift | 18 +--- MVMCoreUI/Atoms/Views/MFLoadImageView.swift | 48 +-------- .../Categories/UIContentMode+Extension.swift | 98 +++++++++++++++++++ .../TwoButtonViewModel.swift | 5 +- 5 files changed, 109 insertions(+), 64 deletions(-) create mode 100644 MVMCoreUI/Categories/UIContentMode+Extension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d114d2ae..03743382 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 012A88F123985E0100FE3DA1 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88F023985E0100FE3DA1 /* Color.swift */; }; 012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; }; 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; }; + 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */; }; 014AA72423C501E2006F3E93 /* MoleculeContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */; }; 014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72223C501E2006F3E93 /* ContainerModel.swift */; }; 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */; }; @@ -359,6 +360,7 @@ 012A88F023985E0100FE3DA1 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = ""; }; 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = ""; }; + 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIContentMode+Extension.swift"; sourceTree = ""; }; 014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeContainerModel.swift; sourceTree = ""; }; 014AA72223C501E2006F3E93 /* ContainerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerModel.swift; sourceTree = ""; }; 014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerModelProtocol.swift; sourceTree = ""; }; @@ -1142,6 +1144,7 @@ D29DF11021E6805F003B2FB9 /* Categories */ = { isa = PBXGroup; children = ( + 013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */, D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */, D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */, D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */, @@ -1801,6 +1804,7 @@ 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, + 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D2E2A9A323E096B1000B42E6 /* DisableableModelProtocol.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index 497b0c86..97f31ad2 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -17,23 +17,7 @@ import Foundation public var imageFormat: String? public var width: CGFloat? public var height: CGFloat? - public var contentMode: ContentMode? - - public enum ContentMode : String, Codable { - case scaleToFill - case scaleAspectFit // contents scaled to fit with fixed aspect. remainder is transparent - case scaleAspectFill // contents scaled to fill with fixed aspect. some portion of content may be clipped. - case redraw // redraw on bounds change (calls -setNeedsDisplay) - case center // contents remain same size. positioned adjusted. - case top - case bottom - case left - case right - case topLeft - case topRight - case bottomLeft - case bottomRight - } + public var contentMode: UIView.ContentMode? public init(image: String) { self.image = image diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index d46a5150..5e8cedc8 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -232,54 +232,10 @@ import UIKit imageView.animatedImage = nil loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage) } - setContentMode(imageModel) - } - func setContentMode(_ model: ImageViewModel?) { - switch model?.contentMode { - case .scaleToFill: - imageView.contentMode = .scaleToFill - break - case .scaleAspectFit: - imageView.contentMode = .scaleAspectFit - break - case .scaleAspectFill: - imageView.contentMode = .scaleAspectFill - break - case .redraw: - imageView.contentMode = .redraw - break - case .center: - imageView.contentMode = .center - break - case .top: - imageView.contentMode = .top - break - case .bottom: - imageView.contentMode = .bottom - break - case .left: - imageView.contentMode = .left - break - case .right: - imageView.contentMode = .right - break - case .topLeft: - imageView.contentMode = .topLeft - break - case .topRight: - imageView.contentMode = .topRight - break - case .bottomLeft: - imageView.contentMode = .bottomLeft - break - case .bottomRight: - imageView.contentMode = .bottomRight - break - default: - break + if let contentMode = imageModel.contentMode { + imageView.contentMode = contentMode } - } // MARK: - MVMCoreUIMoleculeViewProtocol functions diff --git a/MVMCoreUI/Categories/UIContentMode+Extension.swift b/MVMCoreUI/Categories/UIContentMode+Extension.swift new file mode 100644 index 00000000..19cf523b --- /dev/null +++ b/MVMCoreUI/Categories/UIContentMode+Extension.swift @@ -0,0 +1,98 @@ +// +// UIContentMode+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 2/17/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +enum ContentModeError: Error { + case notAContentMode +} + +extension UIView.ContentMode: RawRepresentable { + + init?(rawValue: String) { + switch rawValue { + case "scaleToFill": + self = .scaleToFill + case "scaleAspectFit": + self = .scaleAspectFit + case "scaleAspectFill": + self = .scaleAspectFill + case "redraw": + self = .redraw + case "center": + self = .center + case "top": + self = .top + case "bottom": + self = .bottom + case "left": + self = .left + case "right": + self = .right + case "topLeft": + self = .topLeft + case "topRight": + self = .topRight + case "bottomLeft": + self = .bottomLeft + case "bottomRight": + self = .bottomRight + default: + return nil + } + } + + var rawValueString: String { + switch self { + case .scaleToFill: + return "scaleToFill" + case .scaleAspectFit: + return "scaleAspectFit" + case .scaleAspectFill: + return "scaleAspectFill" + case .redraw: + return "redraw" + case .center: + return "center" + case .top: + return "top" + case .bottom: + return "bottom" + case .left: + return "left" + case .right: + return "right" + case .topLeft: + return "topLeft" + case .topRight: + return "topRight" + case .bottomLeft: + return "bottomLeft" + case .bottomRight: + return "bottomRight" + @unknown default: + return "" + } + } +} + +extension UIView.ContentMode: Codable { + public init(from decoder: Decoder) throws { + let typeContainer = try decoder.singleValueContainer() + let string = try typeContainer.decode(String.self) + guard let mode = UIView.ContentMode(rawValue: string) else { + throw ContentModeError.notAContentMode + } + self = mode + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(rawValueString) + } +} diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 4ddb1575..5d608003 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -21,7 +21,10 @@ public class TwoButtonViewModel: MoleculeModelProtocol { case secondaryButton } - init() { } + init(_ primaryButton: ButtonModel?, _ secondaryButton: ButtonModel?) { + self.primaryButton = primaryButton + self.secondaryButton = secondaryButton + } required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) From 3e14e395421d48ade87845b8d32842dd22e8684d Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 17:37:46 -0500 Subject: [PATCH 11/12] public --- .../HorizontalCombinationViews/TwoButtonViewModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 5d608003..057203e9 100644 --- a/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -21,7 +21,7 @@ public class TwoButtonViewModel: MoleculeModelProtocol { case secondaryButton } - init(_ primaryButton: ButtonModel?, _ secondaryButton: ButtonModel?) { + public init(_ primaryButton: ButtonModel?, _ secondaryButton: ButtonModel?) { self.primaryButton = primaryButton self.secondaryButton = secondaryButton } From 9211d6c86d7c771d1f79453b147d264ca0d3d98e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 17 Feb 2020 17:44:12 -0500 Subject: [PATCH 12/12] public --- MVMCoreUI/CustomPrimitives/Color.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/CustomPrimitives/Color.swift b/MVMCoreUI/CustomPrimitives/Color.swift index a34fbd45..165fa8ad 100644 --- a/MVMCoreUI/CustomPrimitives/Color.swift +++ b/MVMCoreUI/CustomPrimitives/Color.swift @@ -49,7 +49,7 @@ public final class Color: Codable { // MARK: - Class Initializers //-------------------------------------------------- - init(uiColor: UIColor) { + public init(uiColor: UIColor) { self.uiColor = uiColor hex = UIColor.hexString(for: uiColor) ?? "" determineRGBA()