diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 03743382..281a0672 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -128,6 +128,8 @@ 94F217B723E0BF6100A47C06 /* PrimaryButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */; }; 94FB966223D797DA003D482B /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94FB966023D797DA003D482B /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94FB966323D797DA003D482B /* MFTextButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FB966123D797DA003D482B /* MFTextButton.m */; }; + AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */; }; + AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; @@ -451,6 +453,8 @@ 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PrimaryButtonView.m; sourceTree = ""; }; 94FB966023D797DA003D482B /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = ""; }; 94FB966123D797DA003D482B /* MFTextButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextButton.m; sourceTree = ""; }; + AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePayments.swift; sourceTree = ""; }; + AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariablePaymentsModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; @@ -782,6 +786,15 @@ name = "Recovered References"; sourceTree = ""; }; + AA4FC2A323F4F69600E251DB /* RightVariable */ = { + isa = PBXGroup; + children = ( + AA11A42023F15D7000D7962F /* ListRightVariablePaymentsModel.swift */, + AA11A41E23F15D3100D7962F /* ListRightVariablePayments.swift */, + ); + path = RightVariable; + sourceTree = ""; + }; D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( @@ -963,6 +976,7 @@ D22B38EA23F4E08B00490EF6 /* List */ = { isa = PBXGroup; children = ( + AA4FC2A323F4F69600E251DB /* RightVariable */, D22B38EB23F4E0AE00490EF6 /* LeftVariable */, ); path = List; @@ -1616,6 +1630,7 @@ DBC4391922442197001AB423 /* DashLine.swift in Sources */, 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */, D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */, + AA11A41F23F15D3100D7962F /* ListRightVariablePayments.swift in Sources */, D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */, 0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */, 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */, @@ -1677,6 +1692,7 @@ D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, + AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, 012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */, D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atoms/Views/ImageViewModel.swift index d23289bf..0f585119 100644 --- a/MVMCoreUI/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atoms/Views/ImageViewModel.swift @@ -19,8 +19,21 @@ import Foundation public var width: CGFloat? public var height: CGFloat? public var contentMode: UIView.ContentMode? - + public var localBundle: Bundle? + public init(image: String) { self.image = image } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case image + case accessibilityText + case fallbackImage + case imageFormat + case width + case height + case contentMode + } } diff --git a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift index 156e187d..0079d1a6 100644 --- a/MVMCoreUI/Atoms/Views/MFLoadImageView.swift +++ b/MVMCoreUI/Atoms/Views/MFLoadImageView.swift @@ -233,7 +233,7 @@ import UIKit if shouldLoadImage(withName: imageModel.image, width: width, height: height) { imageView.image = nil imageView.animatedImage = nil - loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage) + loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage, localBundle: imageModel.localBundle) } if let contentMode = imageModel.contentMode { @@ -276,7 +276,7 @@ import UIKit } // MARK: - load functions - public func loadImage(withName imageName: String?, format: String? = nil, width: NSNumber? = nil, height: NSNumber? = nil, customFallbackImage: String? = nil, allowServerParameters: Bool = false, completionHandler: MVMCoreGetImageBlock? = nil) { + public func loadImage(withName imageName: String?, format: String? = nil, width: NSNumber? = nil, height: NSNumber? = nil, customFallbackImage: String? = nil, allowServerParameters: Bool = false, localBundle: Bundle? = nil, completionHandler: MVMCoreGetImageBlock? = nil) { let completionBlock = completionHandler ?? defaultCompletionBlock() MVMCoreDispatchUtility.performBlock(onMainThread: { [unowned self] in @@ -308,7 +308,7 @@ import UIKit // Gifs aren't supported by default and need special handling MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, completionHandler: finishedLoadingBlock) } else { - MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, completionHandler: finishedLoadingBlock) + MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock) } }) } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift new file mode 100644 index 00000000..2bfbc321 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePayments.swift @@ -0,0 +1,69 @@ +// +// ListRightVariablePayments.swift +// MVMCoreUI +// +// Created by Lekshmi S on 10/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers public class ListRightVariablePayments: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + + let leftLabel = Label.commonLabelB1(true) + let rightImage = MFLoadImageView(pinnedEdges: .all) + let stack = Stack(frame: .zero) + + //----------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + stack.updateView(size) + } + + override open func setupView() { + super.setupView() + guard leftLabel.superview == nil else { + return + } + stack.translatesAutoresizingMaskIntoConstraints = false + stack.stackItems = [StackItem(andContain: leftLabel),StackItem(andContain: rightImage)] + contentView.addSubview(stack) + containerHelper.constrainView(stack) + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + override open func reset() { + super.reset() + stack.reset() + } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? ListRightVariablePaymentsModel else { return } + leftLabel.setWithModel(model.leftLabel, delegateObject, additionalData) + rightImage.setWithModel(model.image, delegateObject, additionalData) + + // Create a stack model to use for the internal stack and set the alignment of label and image + let leftLabel = StackItemModel() + leftLabel.horizontalAlignment = .leading + let rightImage = StackItemModel() + rightImage.horizontalAlignment = .fill + let stackModel = StackModel(molecules: [leftLabel,rightImage]) + stackModel.axis = .horizontal + stack.model = stackModel + stack.restack() + } + + public override class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 65 + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift new file mode 100644 index 00000000..a8c6ff80 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariablePaymentsModel.swift @@ -0,0 +1,52 @@ +// +// ListRightVariablePaymentsModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 10/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListRightVariablePaymentsModel: ListItemModel, MoleculeModelProtocol { + + public static var identifier: String = "listRVImg" + public var image: ImageViewModel + public var leftLabel: LabelModel + + public init(image: ImageViewModel, leftLabel: LabelModel) { + self.leftLabel = leftLabel + self.image = image + super.init() + } + + static func createPayPalImage() -> ImageViewModel { + let image = ImageViewModel(image: "imageName_PayPal_logo") + image.localBundle = MVMCoreUIUtility.bundleForMVMCoreUI() + image.width = 70.0 + image.height = 18.0 + image.contentMode = .scaleAspectFit + return image + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case image + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image) ?? ListRightVariablePaymentsModel.createPayPalImage() + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(image, forKey: .image) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index a04f964a..ac7375d7 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -72,6 +72,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) // List items MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/Contents.json b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/Contents.json new file mode 100644 index 00000000..b4c381b8 --- /dev/null +++ b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "paypal_horiz_logo.jpeg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "paypal_horiz_logo@2x.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "paypal_horiz_logo@3x.jpeg", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo.jpeg b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo.jpeg new file mode 100644 index 00000000..95113ebf Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo.jpeg differ diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@2x.jpeg b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@2x.jpeg new file mode 100644 index 00000000..5f733990 Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@2x.jpeg differ diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@3x.jpeg b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@3x.jpeg new file mode 100644 index 00000000..cbd78652 Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Media.xcassets/imageName_PayPal_logo.imageset/paypal_horiz_logo@3x.jpeg differ