From 137b467a1e41096669f00d710bb6eb9033c22f3a Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 5 Apr 2022 14:20:22 +0530 Subject: [PATCH 1/6] made changes to textlink as per core specs. --- .../Atomic/Atoms/Buttons/Link/Link.swift | 7 ++++--- .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 17 +++++++++++++++- MVMCoreUI/Categories/UIColor+Extension.swift | 8 ++++++++ .../Categories/colors.xcassets/Contents.json | 6 +++--- .../gray44.colorset/Contents.json | 20 +++++++++++++++++++ .../gray65.colorset/Contents.json | 20 +++++++++++++++++++ 6 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json create mode 100644 MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 8e528deb..553b36d2 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -28,8 +28,8 @@ import UIKit // x should be according to the text, not the button let x = textRect.origin.x - // Line is 1 point below the text - let y = textRect.origin.y + textRect.size.height + 1 + // Line is 0 point below the text + let y = textRect.origin.y + textRect.size.height + 0 context.move(to: CGPoint(x: x, y: y)) context.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) @@ -56,6 +56,7 @@ import UIKit } setTitleColor((model.inverted ? model.enabledColor_inverted : model.enabledColor).uiColor, for: .normal) setTitleColor((model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled) + setTitleColor((model.inverted ? model.activeColor_inverted : model.activeColor).uiColor, for: .highlighted) isEnabled = model.enabled set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } @@ -82,7 +83,7 @@ extension Link { backgroundColor = .clear contentMode = .redraw setTitleColor(.mvmBlack, for: .normal) - setTitleColor(.mvmCoolGray6, for: .disabled) + setTitleColor(.mvmCoolGray3, for: .disabled) titleLabel?.numberOfLines = 1 titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 955601ac..adfce57c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -24,8 +24,11 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var enabled = true public var enabledColor = Color(uiColor: .mvmBlack) public var enabledColor_inverted = Color(uiColor: .mvmWhite) - public var disabledColor = Color(uiColor: .mvmCoolGray6) + public var disabledColor = Color(uiColor: .mvmCoolGray3) public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) + public var activeColor = Color(uiColor: .mvmGray44) + public var activeColor_inverted = Color(uiColor: .mvmGray65) + public var inverted = false //-------------------------------------------------- @@ -53,6 +56,8 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode case enabledColor_inverted case disabledColor case disabledColor_inverted + case activeColor + case activeColor_inverted case inverted } @@ -92,6 +97,14 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode if let disabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor_inverted) { self.disabledColor_inverted = disabledColor_inverted } + + if let activeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor) { + self.activeColor = activeColor + } + + if let activeColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor_inverted) { + self.activeColor_inverted = activeColor_inverted + } } public func encode(to encoder: Encoder) throws { @@ -107,5 +120,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode try container.encode(enabledColor_inverted, forKey: .enabledColor_inverted) try container.encode(disabledColor, forKey: .disabledColor) try container.encode(disabledColor_inverted, forKey: .disabledColor_inverted) + try container.encode(activeColor, forKey: .activeColor) + try container.encode(activeColor_inverted, forKey: .activeColor_inverted) } } diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 78363630..4bc84c87 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -52,6 +52,8 @@ extension UIColor { "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), "coolGray10": (.mvmCoolGray10, "#333333"), + "gray44": (.mvmGray44, "#6F7171"), + "gray65": (.mvmGray65, "#A7A7A7"), "upGold1": (.vzupGold1, "#F9D542"), "upGold2": (.vzupGold2, "#F4CA53"), "upGold3": (.vzupGold3, "#CC9B2D")] @@ -197,6 +199,12 @@ extension UIColor { /// HEX: #333333 public static let mvmCoolGray10 = UIColor.assetColor(named: "coolGray10") + /// HEX: #6F7171 + public static let mvmGray44 = UIColor.assetColor(named: "gray44") + + /// HEX: #A7A7A7 + public static let mvmGray65 = UIColor.assetColor(named: "gray65") + //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- diff --git a/MVMCoreUI/Categories/colors.xcassets/Contents.json b/MVMCoreUI/Categories/colors.xcassets/Contents.json index da4a164c..73c00596 100644 --- a/MVMCoreUI/Categories/colors.xcassets/Contents.json +++ b/MVMCoreUI/Categories/colors.xcassets/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json new file mode 100644 index 00000000..296ef27c --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x71", + "green" : "0x71", + "red" : "0x6F" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json new file mode 100644 index 00000000..aefc9ce0 --- /dev/null +++ b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xA7", + "green" : "0xA7", + "red" : "0xA7" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} From b88a006c00641626b46d7febf06d69bddba1ee53 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 5 Apr 2022 20:40:10 +0530 Subject: [PATCH 2/6] removed unnecessary value of y --- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 553b36d2..54751274 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -29,7 +29,7 @@ import UIKit let x = textRect.origin.x // Line is 0 point below the text - let y = textRect.origin.y + textRect.size.height + 0 + let y = textRect.origin.y + textRect.size.height context.move(to: CGPoint(x: x, y: y)) context.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) From a8d0c12db8b9cc08d6f05f3efc708b1fbef1683f Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 12 Apr 2022 17:24:06 +0530 Subject: [PATCH 3/6] using colors from the VDS colors library. --- .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 6 +++--- MVMCoreUI/Categories/UIColor+Extension.swift | 8 -------- .../gray44.colorset/Contents.json | 20 ------------------- .../gray65.colorset/Contents.json | 20 ------------------- 4 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json delete mode 100644 MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index adfce57c..3647ad10 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDSColorTokens open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- @@ -26,8 +26,8 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var enabledColor_inverted = Color(uiColor: .mvmWhite) public var disabledColor = Color(uiColor: .mvmCoolGray3) public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) - public var activeColor = Color(uiColor: .mvmGray44) - public var activeColor_inverted = Color(uiColor: .mvmGray65) + public var activeColor = Color(uiColor: VDSColor.paletteGray44) + public var activeColor_inverted = Color(uiColor: VDSColor.paletteGray65) public var inverted = false diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 4bc84c87..78363630 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -52,8 +52,6 @@ extension UIColor { "coolGray3": (.mvmCoolGray3, "#D8DADA"), "coolGray6": (.mvmCoolGray6, "#747676"), "coolGray10": (.mvmCoolGray10, "#333333"), - "gray44": (.mvmGray44, "#6F7171"), - "gray65": (.mvmGray65, "#A7A7A7"), "upGold1": (.vzupGold1, "#F9D542"), "upGold2": (.vzupGold2, "#F4CA53"), "upGold3": (.vzupGold3, "#CC9B2D")] @@ -199,12 +197,6 @@ extension UIColor { /// HEX: #333333 public static let mvmCoolGray10 = UIColor.assetColor(named: "coolGray10") - /// HEX: #6F7171 - public static let mvmGray44 = UIColor.assetColor(named: "gray44") - - /// HEX: #A7A7A7 - public static let mvmGray65 = UIColor.assetColor(named: "gray65") - //-------------------------------------------------- // MARK: - VZ UP Brand //-------------------------------------------------- diff --git a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json deleted file mode 100644 index 296ef27c..00000000 --- a/MVMCoreUI/Categories/colors.xcassets/gray44.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x71", - "green" : "0x71", - "red" : "0x6F" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json b/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json deleted file mode 100644 index aefc9ce0..00000000 --- a/MVMCoreUI/Categories/colors.xcassets/gray65.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xA7", - "green" : "0xA7", - "red" : "0xA7" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} From 790a3c69bc5bd314f6d7c2024d9db1ca5cb94003 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 12 Apr 2022 20:47:52 +0530 Subject: [PATCH 4/6] using VDSColor for disabled link --- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 4 ++-- MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 54751274..718fdd93 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDSColorTokens @objcMembers open class Link: Button { //-------------------------------------------------- @@ -83,7 +83,7 @@ extension Link { backgroundColor = .clear contentMode = .redraw setTitleColor(.mvmBlack, for: .normal) - setTitleColor(.mvmCoolGray3, for: .disabled) + setTitleColor(VDSColor.paletteGray85, for: .disabled) titleLabel?.numberOfLines = 1 titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 3647ad10..999b9e75 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -24,7 +24,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var enabled = true public var enabledColor = Color(uiColor: .mvmBlack) public var enabledColor_inverted = Color(uiColor: .mvmWhite) - public var disabledColor = Color(uiColor: .mvmCoolGray3) + public var disabledColor = Color(uiColor: VDSColor.paletteGray85) public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) public var activeColor = Color(uiColor: VDSColor.paletteGray44) public var activeColor_inverted = Color(uiColor: VDSColor.paletteGray65) From 31827b08162545192eec4382db35575260ff61e9 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Thu, 21 Apr 2022 02:14:37 +0530 Subject: [PATCH 5/6] moving to VDSColors for all colors. --- MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift | 5 +++-- MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 718fdd93..b180d50f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -82,8 +82,9 @@ extension Link { super.setupView() backgroundColor = .clear contentMode = .redraw - setTitleColor(.mvmBlack, for: .normal) - setTitleColor(VDSColor.paletteGray85, for: .disabled) + setTitleColor(VDSColor.elementsPrimaryOnlight, for: .normal) + setTitleColor(VDSColor.interactiveDisabledOnlight, for: .disabled) + setTitleColor(VDSColor.interactiveActiveOnlight, for: .highlighted) titleLabel?.numberOfLines = 1 titleLabel?.lineBreakMode = .byTruncatingTail titleLabel?.textAlignment = .left diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 999b9e75..83b1fc7c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -22,12 +22,12 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var accessibilityText: String? public var action: ActionModelProtocol public var enabled = true - public var enabledColor = Color(uiColor: .mvmBlack) - public var enabledColor_inverted = Color(uiColor: .mvmWhite) - public var disabledColor = Color(uiColor: VDSColor.paletteGray85) - public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10) - public var activeColor = Color(uiColor: VDSColor.paletteGray44) - public var activeColor_inverted = Color(uiColor: VDSColor.paletteGray65) + public var enabledColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + public var enabledColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) + public var disabledColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + public var disabledColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) + public var activeColor = Color(uiColor: VDSColor.interactiveActiveOnlight) + public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark) public var inverted = false From d3cac3f36db4171e69bce96e954379f81ff2a628 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Mon, 9 May 2022 14:29:59 +0530 Subject: [PATCH 6/6] set font size as per spec --- .../Atomic/Atoms/Buttons/Link/Link.swift | 10 ++------ .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index b180d50f..4f4a8b34 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -38,7 +38,7 @@ import VDSColorTokens open override var intrinsicContentSize: CGSize { guard let size = titleLabel?.intrinsicContentSize else { return super.intrinsicContentSize } - return CGSize(width: size.width, height: size.height + 2) + return CGSize(width: size.width, height: size.height + 1) } //-------------------------------------------------- @@ -58,6 +58,7 @@ import VDSColorTokens setTitleColor((model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled) setTitleColor((model.inverted ? model.activeColor_inverted : model.activeColor).uiColor, for: .highlighted) isEnabled = model.enabled + titleLabel?.font = model.getFont(model.size) set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } @@ -69,13 +70,6 @@ extension Link { open override func updateView(_ size: CGFloat) { super.updateView(size) - - var width = size - if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) { - width = MVMCoreUIUtility.getWidth() - } - - titleLabel?.font = MFStyler.fontB2(forWidth: width) } open override func setupView() { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 83b1fc7c..af507860 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -30,6 +30,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark) public var inverted = false + public var size:linkFontSize = linkFontSize.small //-------------------------------------------------- // MARK: - Initializer @@ -59,8 +60,27 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode case activeColor case activeColor_inverted case inverted + case size } + public enum linkFontSize: String, Codable { + case small + case large + } + + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + + func getFont(_ type: linkFontSize) -> UIFont { + switch type { + case .small: + return MFStyler.fontRegularBodySmall() + case .large: + return MFStyler.fontRegularBodyLarge() + } + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- @@ -105,6 +125,9 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode if let activeColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor_inverted) { self.activeColor_inverted = activeColor_inverted } + if let size = try typeContainer.decodeIfPresent(linkFontSize.self, forKey: .size) { + self.size = size + } } public func encode(to encoder: Encoder) throws { @@ -122,5 +145,6 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode try container.encode(disabledColor_inverted, forKey: .disabledColor_inverted) try container.encode(activeColor, forKey: .activeColor) try container.encode(activeColor_inverted, forKey: .activeColor_inverted) + try container.encodeIfPresent(size, forKey: .size) } }