Merge branch 'develop' into feature/rightVariable_payments_list

# Conflicts:
#	MVMCoreUI/Atoms/Views/ImageViewModel.swift
This commit is contained in:
Lekshmi S 2020-02-18 08:29:39 +05:30
commit 391cd9ae2c
18 changed files with 298 additions and 39 deletions

View File

@ -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 */; };
@ -361,6 +362,7 @@
012A88F023985E0100FE3DA1 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = "<group>"; };
012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = "<group>"; };
013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIContentMode+Extension.swift"; sourceTree = "<group>"; };
014AA72123C501E2006F3E93 /* MoleculeContainerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeContainerModel.swift; sourceTree = "<group>"; };
014AA72223C501E2006F3E93 /* ContainerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerModel.swift; sourceTree = "<group>"; };
014AA72323C501E2006F3E93 /* ContainerModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerModelProtocol.swift; sourceTree = "<group>"; };
@ -1156,6 +1158,7 @@
D29DF11021E6805F003B2FB9 /* Categories */ = {
isa = PBXGroup;
children = (
013F801823FB4A8E00AD8013 /* UIContentMode+Extension.swift */,
D29DF11121E6805F003B2FB9 /* UIColor+MFConvenience.h */,
D29DF11321E6805F003B2FB9 /* UIColor+MFConvenience.m */,
D29DF11221E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h */,
@ -1817,6 +1820,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 */,

View File

@ -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
@ -46,6 +45,12 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
self.action = action
style = .secondary
}
init(primaryButtonWith title: String, action: ActionModelProtocol) {
self.title = title
self.action = action
style = .primary
}
private enum CodingKeys: String, CodingKey {
case moleculeName
@ -67,7 +72,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)

View File

@ -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"

View File

@ -11,14 +11,14 @@ import Foundation
@objcMembers public class ImageViewModel: MoleculeModelProtocol {
public static var identifier: String = "image"
public var backgroundColor: Color?
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: UIView.ContentMode?
public init(image: String) {
self.image = image
}

View File

@ -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
//--------------------------------------------------

View File

@ -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?
@ -45,10 +43,13 @@ 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)
text = try typeContainer.decode(String.self, forKey: .text)
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
textColor = try typeContainer.decodeIfPresent(String.self, forKey: .textColor)

View File

@ -232,6 +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)
}
if let contentMode = imageModel.contentMode {
imageView.contentMode = contentMode
}
}
// MARK: - MVMCoreUIMoleculeViewProtocol functions

View File

@ -91,7 +91,7 @@ public typealias ButtonAction = (Button) -> ()
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)

View File

@ -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

View File

@ -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;

View File

@ -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];
}

View File

@ -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)
}
}

View File

@ -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()

View File

@ -21,6 +21,11 @@ public class TwoButtonViewModel: MoleculeModelProtocol {
case secondaryButton
}
public 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)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)

View File

@ -25,7 +25,7 @@ import Foundation
public override init(with moleculeModel: MoleculeModelProtocol) {
super.init(with: moleculeModel)
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing)

View File

@ -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?

View File

@ -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]]
@"threeLayer" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]]
} mutableCopy];
});
return viewControllerMapping;

View File

@ -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];
}