From 02476e766d18eb3699dfe3570b1ee78e9f887870 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 24 Mar 2022 00:22:38 +0530 Subject: [PATCH 01/49] Updating button VDS component for 3.0 rebranding --- .../Atomic/Atoms/Buttons/PillButton.swift | 49 ++++++++++++++++--- MVMCoreUI/Styles/Styler.swift | 8 +-- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 5b8f75cb..edea692f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -128,6 +128,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { self.borderColor = borderColor } } + titleEdgeInsets = getContentEdgeInsets() } private func getInnerPadding() -> CGFloat { @@ -138,6 +139,24 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { PillButton.getHeight(for: buttonSize, size: size) } + private func getContentEdgeInsets() -> UIEdgeInsets { + var verticalPadding = 0.0 + var horizontalPadding = 0.0 + switch buttonSize { + case .standard: + verticalPadding = Padding.Three + horizontalPadding = Padding.Five + break + case .small: + verticalPadding = Padding.Two + horizontalPadding = Padding.Four + break + default: + break + } + return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) + } + public static func getHeight(for buttonSize: Styler.Button.Size?, size: CGFloat) -> CGFloat { switch buttonSize { @@ -146,7 +165,11 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { return MFSizeObject(standardSize: tinyHeight, standardiPadPortraitSize: 34, iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? tinyHeight - + case .small: + let smallHeight = Styler.Button.Size.small.getHeight() + return MFSizeObject(standardSize: smallHeight, + standardiPadPortraitSize: 34, + iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? smallHeight default: let standardHeight = Styler.Button.Size.standard.getHeight() return MFSizeObject(standardSize: standardHeight, @@ -162,8 +185,14 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { return MFSizeObject(standardSize: 49, standardiPadPortraitSize: 90, iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 49 - - default: return 151 + case .small: + return MFSizeObject(standardSize: 1, + standardiPadPortraitSize: 2, + iPadProLandscapeSize: 3)?.getValueBased(onSize: size) ?? 1 + case .standard: + return MFSizeObject(standardSize: 76, + standardiPadPortraitSize: 90, + iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 76 } } @@ -172,9 +201,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { let size = super.intrinsicContentSize let width = size.width + (2 * getInnerPadding()) return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) + } else if buttonSize == .small { + let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) + return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) } else { - let width = Padding.Component.gutterForApplicationWidth + (2.0 * Padding.Component.columnFor(size: MVMCoreUISplitViewController.getApplicationViewWidth())) - return CGSize(width: min(292, width), height: getHeight()) + let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) + return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) } } @@ -218,9 +250,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { switch buttonSize { case .tiny: titleLabel?.font = MFFonts.mfFont75Bd(11 * (intrinsicContentSize.height / Styler.Button.Size.tiny.getHeight())) - - default: - titleLabel?.font = MFFonts.mfFont75Bd(13 * (intrinsicContentSize.height / Styler.Button.Size.standard.getHeight())) + case .small: + titleLabel?.font = Styler.Font.BoldBodySmall.getFont() + case .standard: + titleLabel?.font = Styler.Font.BoldBodyLarge.getFont() } layer.cornerRadius = getInnerPadding() diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 77402295..c8fe444e 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -178,16 +178,18 @@ open class Styler { case primary case secondary } - + ///MVA 3.0 - Button sizes are standard(default size), small, Tiny. Tiny button has been depricated as of Rebranding 3.0. public enum Size: String, Codable { case standard + case small case tiny func getHeight() -> CGFloat { switch self { case .standard: - return 42 - + return 44 + case .small: + return 32 case .tiny: return 20 } From 121c290f3b4beddbcde1d5db7d2131929304c42f Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 24 Mar 2022 13:35:49 +0530 Subject: [PATCH 02/49] updating title edge insets for button as per VDS --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index edea692f..e7d0aacc 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -128,7 +128,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { self.borderColor = borderColor } } - titleEdgeInsets = getContentEdgeInsets() } private func getInnerPadding() -> CGFloat { @@ -257,6 +256,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } layer.cornerRadius = getInnerPadding() + titleEdgeInsets = getContentEdgeInsets() } open override func setupView() { From 137b467a1e41096669f00d710bb6eb9033c22f3a Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 5 Apr 2022 14:20:22 +0530 Subject: [PATCH 03/49] 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 04/49] 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 e0a93cc71f228e317bde1dca8fb9ec47116568a3 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 11 Apr 2022 00:18:55 +0530 Subject: [PATCH 05/49] Adding width attribute to button, to set custom button size. --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 7 +++++ .../Atomic/Atoms/Buttons/PillButton.swift | 27 +++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 3b72d37c..8b3da748 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -23,6 +23,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var title: String public var action: ActionModelProtocol public var enabled: Bool = true + public var width: CGFloat? public var style: Styler.Button.Style? { didSet { guard let style = style else { return } @@ -183,6 +184,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat case disabledFillColor case disabledTextColor case disabledBorderColor + case width } //-------------------------------------------------- @@ -242,6 +244,10 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if let disabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledBorderColor) { self.disabledBorderColor = disabledBorderColor } + + if let width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) { + self.width = width + } } open func encode(to encoder: Encoder) throws { @@ -263,5 +269,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat try container.encodeIfPresent(style, forKey: .style) try container.encodeIfPresent(size, forKey: .size) try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encodeIfPresent(width, forKey: .width) } } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index e7d0aacc..4722e3fc 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -138,7 +138,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { PillButton.getHeight(for: buttonSize, size: size) } - private func getContentEdgeInsets() -> UIEdgeInsets { + private func getTitleEdgeInsets() -> UIEdgeInsets { var verticalPadding = 0.0 var horizontalPadding = 0.0 switch buttonSize { @@ -196,16 +196,21 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } open override var intrinsicContentSize: CGSize { - if buttonSize == .tiny { - let size = super.intrinsicContentSize - let width = size.width + (2 * getInnerPadding()) - return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) - } else if buttonSize == .small { - let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) - return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) + + if let buttonWidth = buttonModel?.width { + return CGSize(width: buttonWidth, height: getHeight()) } else { - let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) - return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) + if buttonSize == .tiny { + let size = super.intrinsicContentSize + let width = size.width + (2 * getInnerPadding()) + return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) + } else if buttonSize == .small { + let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) + return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) + } else { + let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) + return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) + } } } @@ -256,7 +261,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } layer.cornerRadius = getInnerPadding() - titleEdgeInsets = getContentEdgeInsets() + titleEdgeInsets = getTitleEdgeInsets() } open override func setupView() { From b2a25f840a46f46a90f26a2ca537f01f7b7b5e02 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 11 Apr 2022 01:49:50 +0530 Subject: [PATCH 06/49] Adding pill button's inverted state logic --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 56 ++++++++++++------- .../Atomic/Atoms/Buttons/PillButton.swift | 2 +- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 8b3da748..30b5b496 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -7,6 +7,7 @@ // import UIKit +import VDSColorTokens public typealias FacadeElements = (fill: UIColor?, text: UIColor?, border: UIColor?) @@ -17,7 +18,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat //-------------------------------------------------- //Making static property as class property so that subclasses can override getter function of the property open class var identifier: String { "button" } - public var backgroundColor: Color? public var accessibilityIdentifier: String? public var accessibilityText: String? public var title: String @@ -58,6 +58,22 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var disabledTextColor_inverted: Color? public var disabledBorderColor_inverted: Color? + private var _backgroundColor: Color? + public var backgroundColor: Color? { + get { + if let backgroundColor = _backgroundColor { return backgroundColor } + if inverted { + if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOndark) } + return Color(uiColor: VDSColor.elementsPrimaryOndark) + } + if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOnlight) } + return Color(uiColor: VDSColor.elementsPrimaryOnlight) + } + set { + _backgroundColor = newValue + } + } + //-------------------------------------------------- // MARK: - Methods //-------------------------------------------------- @@ -117,38 +133,39 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat func setPrimaryFacade() { if enabledFillColor == nil && enabledTextColor == nil { - enabledFillColor = Color(uiColor: .mvmBlack) - enabledTextColor = Color(uiColor: .mvmWhite) + enabledFillColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) } if disabledFillColor == nil && disabledTextColor == nil { - disabledFillColor = Color(uiColor: .mvmCoolGray6) - disabledTextColor = Color(uiColor: .mvmWhite) + disabledFillColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + disabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) } - enabledFillColor_inverted = Color(uiColor: .mvmWhite) - enabledTextColor_inverted = Color(uiColor: .mvmBlack) - disabledFillColor_inverted = Color(uiColor: .mvmCoolGray6) - disabledTextColor_inverted = Color(uiColor: .mvmBlack) + enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) + enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + disabledFillColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) + disabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) } /// Defines the default appearance for the Secondary style. func setSecondaryFacade() { if enabledTextColor == nil && enabledBorderColor == nil { - enabledTextColor = Color(uiColor: .mvmBlack) - enabledBorderColor = Color(uiColor: .mvmBlack) + enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) } if disabledTextColor == nil && disabledBorderColor == nil { - disabledTextColor = Color(uiColor: .mvmCoolGray6) - disabledBorderColor = Color(uiColor: .mvmCoolGray6) + disabledTextColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + disabledBorderColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) } - enabledTextColor_inverted = Color(uiColor: .mvmWhite) - enabledBorderColor_inverted = Color(uiColor: .mvmWhite) - disabledTextColor_inverted = Color(uiColor: .mvmCoolGray6) - disabledBorderColor_inverted = Color(uiColor: .mvmCoolGray6) + enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) + enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) + disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) } public func setFacade(by style: Styler.Button.Style) { @@ -194,7 +211,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) title = try typeContainer.decode(String.self, forKey: .title) @@ -245,6 +261,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat self.disabledBorderColor = disabledBorderColor } + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + if let width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) { self.width = width } @@ -257,7 +275,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat try container.encode(enabled, forKey: .enabled) try container.encode(inverted, forKey: .inverted) try container.encodeModel(action, forKey: .action) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(_backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(enabledFillColor, forKey: .fillColor) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 4722e3fc..cd62c8d0 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -81,7 +81,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmBlack disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmCoolGray6 backgroundColor = .clear - layer.borderWidth = 1 + layer.borderWidth = buttonModel?.inverted ?? false ? 0 : 1 borderColor = isEnabled ? buttonModel?.enabledColors.border ?? .mvmBlack : buttonModel?.disabledColors.border ?? .mvmCoolGray6 } From a8d0c12db8b9cc08d6f05f3efc708b1fbef1683f Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Tue, 12 Apr 2022 17:24:06 +0530 Subject: [PATCH 07/49] 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 08/49] 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 b972bdba5b2c4e7ff08617d3309507c37cc1476e Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 13 Apr 2022 00:26:35 +0530 Subject: [PATCH 09/49] Setting button width with constraint --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 5 +-- .../Atomic/Atoms/Buttons/PillButton.swift | 37 ++++++++----------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 30b5b496..abb2038c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -262,10 +262,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - - if let width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) { - self.width = width - } + self.width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) } open func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index cd62c8d0..e86d8a7b 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -30,6 +30,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { didSet { buttonModel?.size = buttonSize } } + //-------------------------------------------------- + // MARK: - Constraints + //-------------------------------------------------- + + public var widthConstraint: NSLayoutConstraint? + //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -138,7 +144,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { PillButton.getHeight(for: buttonSize, size: size) } - private func getTitleEdgeInsets() -> UIEdgeInsets { + private func getContentEdgeInsets() -> UIEdgeInsets { var verticalPadding = 0.0 var horizontalPadding = 0.0 switch buttonSize { @@ -195,25 +201,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } } - open override var intrinsicContentSize: CGSize { - - if let buttonWidth = buttonModel?.width { - return CGSize(width: buttonWidth, height: getHeight()) - } else { - if buttonSize == .tiny { - let size = super.intrinsicContentSize - let width = size.width + (2 * getInnerPadding()) - return CGSize(width: max(width, getMinimumWidth()), height: getHeight()) - } else if buttonSize == .small { - let width = (2 * Padding.Four) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) - return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) - } else { - let width = (2 * Padding.Five) + (titleLabel?.attributedText?.boundingRect(with: CGSize(width: 1000, height: 1000), options: [.usesLineFragmentOrigin, .usesFontLeading], context: nil).size.width ?? 0) - return CGSize(width: max(ceil(width), getMinimumWidth()), height: getHeight()) - } - } - } - //-------------------------------------------------- // MARK: - MVMCoreViewProtocol //-------------------------------------------------- @@ -261,7 +248,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } layer.cornerRadius = getInnerPadding() - titleEdgeInsets = getTitleEdgeInsets() + contentEdgeInsets = getContentEdgeInsets() + + if let contraint = buttonModel?.width { + widthConstraint = widthAnchor.constraint(equalToConstant: contraint) + widthConstraint?.isActive = true + } } open override func setupView() { @@ -272,6 +264,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { titleLabel?.textAlignment = .center contentHorizontalAlignment = .center stylePrimary() + + widthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: getMinimumWidth()) + widthConstraint?.isActive = true } //-------------------------------------------------- From 27289f1ac8d29b23118cb283c4ba2a6d56acccda Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 13 Apr 2022 01:48:30 +0530 Subject: [PATCH 10/49] Font and padding changes to tiny button --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 2 +- MVMCoreUI/Styles/Styler.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index e86d8a7b..14c57bfd 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -240,7 +240,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { switch buttonSize { case .tiny: - titleLabel?.font = MFFonts.mfFont75Bd(11 * (intrinsicContentSize.height / Styler.Button.Size.tiny.getHeight())) + titleLabel?.font = Styler.Font.BoldMicro.getFont() case .small: titleLabel?.font = Styler.Font.BoldBodySmall.getFont() case .standard: diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 00c946b6..addde766 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -191,7 +191,7 @@ open class Styler { case .small: return 32 case .tiny: - return 20 + return 26 } } } From 31827b08162545192eec4382db35575260ff61e9 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Thu, 21 Apr 2022 02:14:37 +0530 Subject: [PATCH 11/49] 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 064533950e3646a2e2ddd64324a8624be3bb57f0 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 21 Apr 2022 19:36:39 +0530 Subject: [PATCH 12/49] VDS button component changes --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 2 +- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 14 ++++++-------- MVMCoreUI/Styles/Styler.swift | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index abb2038c..71cd8eb7 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -262,7 +262,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - self.width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) + width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) } open func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 14c57bfd..ab94d26f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDSColorTokens open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { //-------------------------------------------------- @@ -78,17 +78,17 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmWhite disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmWhite layer.borderWidth = 0 - backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? .mvmBlack : buttonModel?.disabledColors.fill ?? .mvmCoolGray6 + backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmBlack - disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmCoolGray6 + enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor + disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor backgroundColor = .clear layer.borderWidth = buttonModel?.inverted ?? false ? 0 : 1 - borderColor = isEnabled ? buttonModel?.enabledColors.border ?? .mvmBlack : buttonModel?.disabledColors.border ?? .mvmCoolGray6 + borderColor = isEnabled ? buttonModel?.enabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor } /// Styles the button based on the model style @@ -236,8 +236,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { super.updateView(size) self.size = size - invalidateIntrinsicContentSize() - switch buttonSize { case .tiny: titleLabel?.font = Styler.Font.BoldMicro.getFont() @@ -250,7 +248,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width { + if let contraint = buttonModel?.width, contraint != widthConstraint?.constant { widthConstraint = widthAnchor.constraint(equalToConstant: contraint) widthConstraint?.isActive = true } diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index addde766..00c946b6 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -191,7 +191,7 @@ open class Styler { case .small: return 32 case .tiny: - return 26 + return 20 } } } From 8f234259b0119921d22ba94884a01d6430af0534 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 25 Apr 2022 23:16:43 +0530 Subject: [PATCH 13/49] Changes to add button width constraints --- .../Atomic/Atoms/Buttons/PillButton.swift | 45 +++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index ab94d26f..b738205e 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -35,6 +35,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { //-------------------------------------------------- public var widthConstraint: NSLayoutConstraint? + public var minimumWidthConstraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Initializers @@ -75,8 +76,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// The primary styling for a button. Should be used for main buttons public func stylePrimary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmWhite - disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmWhite + enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsSecondaryOnlight).uiColor + disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsSecondaryOnlight).uiColor layer.borderWidth = 0 backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor } @@ -137,13 +138,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } private func getInnerPadding() -> CGFloat { - getHeight() / 2.0 + buttonSize.getHeight() / 2.0 } - - private func getHeight() -> CGFloat { - PillButton.getHeight(for: buttonSize, size: size) - } - + private func getContentEdgeInsets() -> UIEdgeInsets { var verticalPadding = 0.0 var horizontalPadding = 0.0 @@ -161,28 +158,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) } - - public static func getHeight(for buttonSize: Styler.Button.Size?, size: CGFloat) -> CGFloat { - switch buttonSize { - case .tiny: - let tinyHeight = Styler.Button.Size.tiny.getHeight() - return MFSizeObject(standardSize: tinyHeight, - standardiPadPortraitSize: 34, - iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? tinyHeight - case .small: - let smallHeight = Styler.Button.Size.small.getHeight() - return MFSizeObject(standardSize: smallHeight, - standardiPadPortraitSize: 34, - iPadProLandscapeSize: 38)?.getValueBased(onSize: size) ?? smallHeight - default: - let standardHeight = Styler.Button.Size.standard.getHeight() - return MFSizeObject(standardSize: standardHeight, - standardiPadPortraitSize: 46, - iPadProLandscapeSize: 50)?.getValueBased(onSize: size) ?? standardHeight - } - } - private func getMinimumWidth() -> CGFloat { switch buttonSize { @@ -229,7 +205,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - PillButton.getHeight(for: (model as? ButtonModel)?.size, size: MVMCoreUIUtility.getWidth()) + return (model as? ButtonModel)?.size?.getHeight() } open override func updateView(_ size: CGFloat) { @@ -248,9 +224,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width, contraint != widthConstraint?.constant { + if let contraint = buttonModel?.width, widthConstraint == nil { widthConstraint = widthAnchor.constraint(equalToConstant: contraint) widthConstraint?.isActive = true + minimumWidthConstraint?.isActive = false } } @@ -263,8 +240,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { contentHorizontalAlignment = .center stylePrimary() - widthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: getMinimumWidth()) - widthConstraint?.isActive = true + widthConstraint?.isActive = false + + minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: getMinimumWidth()) + minimumWidthConstraint?.isActive = true } //-------------------------------------------------- From a53548522dcf4e923c092e8bbf7145a4d157b8af Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Mon, 25 Apr 2022 23:32:09 +0530 Subject: [PATCH 14/49] secondary button background color --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 71cd8eb7..f16afc7f 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -66,7 +66,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOndark) } return Color(uiColor: VDSColor.elementsPrimaryOndark) } - if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOnlight) } + if style == .secondary { return Color(uiColor: UIColor.clear) } return Color(uiColor: VDSColor.elementsPrimaryOnlight) } set { @@ -162,7 +162,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledFillColor_inverted = Color(uiColor: UIColor.clear) enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) From db7bc5be2ba0e7fa58ca4a0366a2db33c64ee4b5 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 29 Apr 2022 23:01:44 +0530 Subject: [PATCH 15/49] minor changes to button component --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 8 ++--- .../Atomic/Atoms/Buttons/PillButton.swift | 36 +++++-------------- MVMCoreUI/Styles/Styler.swift | 11 ++++++ 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index f16afc7f..92cde87c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -63,11 +63,9 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat get { if let backgroundColor = _backgroundColor { return backgroundColor } if inverted { - if style == .secondary { return Color(uiColor: VDSColor.elementsSecondaryOndark) } - return Color(uiColor: VDSColor.elementsPrimaryOndark) + return enabled ? enabledFillColor_inverted : disabledFillColor_inverted } - if style == .secondary { return Color(uiColor: UIColor.clear) } - return Color(uiColor: VDSColor.elementsPrimaryOnlight) + return enabled ? enabledFillColor : disabledFillColor } set { _backgroundColor = newValue @@ -163,7 +161,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) enabledFillColor_inverted = Color(uiColor: UIColor.clear) - enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) } diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index b738205e..de955378 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -76,20 +76,20 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// The primary styling for a button. Should be used for main buttons public func stylePrimary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsSecondaryOnlight).uiColor - disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsSecondaryOnlight).uiColor + enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor + disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor layer.borderWidth = 0 - backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor + backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor - disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor + disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor backgroundColor = .clear layer.borderWidth = buttonModel?.inverted ?? false ? 0 : 1 - borderColor = isEnabled ? buttonModel?.enabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor + borderColor = isEnabled ? buttonModel?.enabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.border ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor } /// Styles the button based on the model style @@ -153,29 +153,13 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { verticalPadding = Padding.Two horizontalPadding = Padding.Four break - default: + case .tiny: + verticalPadding = getInnerPadding() + horizontalPadding = getInnerPadding() break } return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) } - - private func getMinimumWidth() -> CGFloat { - - switch buttonSize { - case .tiny: - return MFSizeObject(standardSize: 49, - standardiPadPortraitSize: 90, - iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 49 - case .small: - return MFSizeObject(standardSize: 1, - standardiPadPortraitSize: 2, - iPadProLandscapeSize: 3)?.getValueBased(onSize: size) ?? 1 - case .standard: - return MFSizeObject(standardSize: 76, - standardiPadPortraitSize: 90, - iPadProLandscapeSize: 135)?.getValueBased(onSize: size) ?? 76 - } - } //-------------------------------------------------- // MARK: - MVMCoreViewProtocol @@ -240,9 +224,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { contentHorizontalAlignment = .center stylePrimary() - widthConstraint?.isActive = false - - minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: getMinimumWidth()) + minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) minimumWidthConstraint?.isActive = true } diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index 00c946b6..9cc487e8 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -194,6 +194,17 @@ open class Styler { return 20 } } + + func minimumWidth() -> CGFloat { + switch self { + case .standard: + return 76 + case .small: + return 0 + case .tiny: + return 49 + } + } } } From c2ac51c18cdd2fe3829cc79b0c5f15eccf0dbe6c Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 30 Apr 2022 00:00:57 +0530 Subject: [PATCH 16/49] Padding changes for button --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 3 ++- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 92cde87c..0eea3036 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -151,6 +151,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if enabledTextColor == nil && enabledBorderColor == nil { enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledFillColor = Color(uiColor: UIColor.clear) enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) } @@ -160,7 +161,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - enabledFillColor_inverted = Color(uiColor: UIColor.clear) + enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index de955378..b70f4ccb 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -154,8 +154,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { horizontalPadding = Padding.Four break case .tiny: - verticalPadding = getInnerPadding() - horizontalPadding = getInnerPadding() + verticalPadding = Padding.One + horizontalPadding = Padding.Two break } return UIEdgeInsets(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding) @@ -211,7 +211,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { if let contraint = buttonModel?.width, widthConstraint == nil { widthConstraint = widthAnchor.constraint(equalToConstant: contraint) widthConstraint?.isActive = true - minimumWidthConstraint?.isActive = false + } else { + minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) + minimumWidthConstraint?.isActive = true } } @@ -223,9 +225,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { titleLabel?.textAlignment = .center contentHorizontalAlignment = .center stylePrimary() - - minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) - minimumWidthConstraint?.isActive = true } //-------------------------------------------------- From 7fb91d9b1ec99d83181ae0952e2bcaab82a55b10 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 3 May 2022 01:02:25 +0530 Subject: [PATCH 17/49] Updating button default style --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 4 +-- .../Atomic/Atoms/Buttons/PillButton.swift | 25 ++++++------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 0eea3036..a6453dd5 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -24,7 +24,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var action: ActionModelProtocol public var enabled: Bool = true public var width: CGFloat? - public var style: Styler.Button.Style? { + public var style: Styler.Button.Style? = .primary { didSet { guard let style = style else { return } setFacade(by: style) @@ -161,7 +161,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat } enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) - enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledFillColor_inverted = Color(uiColor: UIColor.clear) enabledBorderColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) disabledTextColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) disabledBorderColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index b70f4ccb..7960fd99 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -76,31 +76,20 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// The primary styling for a button. Should be used for main buttons public func stylePrimary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor - disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOndark).uiColor - layer.borderWidth = 0 - backgroundColor = isEnabled ? buttonModel?.enabledColors.fill ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.fill ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor + buttonModel?.setPrimaryFacade() } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { - enabledTitleColor = buttonModel?.enabledColors.text ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor - disabledTitleColor = buttonModel?.disabledColors.text ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor - backgroundColor = .clear - layer.borderWidth = buttonModel?.inverted ?? false ? 0 : 1 - borderColor = isEnabled ? buttonModel?.enabledColors.border ?? Color(uiColor: VDSColor.elementsPrimaryOnlight).uiColor : buttonModel?.disabledColors.border ?? Color(uiColor: VDSColor.interactiveDisabledOnlight).uiColor + buttonModel?.setSecondaryFacade() } /// Styles the button based on the model style private func style() { - switch buttonModel?.style { - case .secondary: - styleSecondary() - - default: - stylePrimary() + if buttonModel?.style == .primary { + layer.borderWidth = 0 } if let titleColor = buttonModel?.enabledColors.text { @@ -170,6 +159,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { super.set(with: model, delegateObject, additionalData) guard let model = model as? ButtonModel else { return } + + style() setTitle(model.title, for: .normal) if let accessibilityText = model.accessibilityText { accessibilityLabel = accessibilityText @@ -208,10 +199,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width, widthConstraint == nil { + if let contraint = buttonModel?.width, (widthConstraint == nil || widthConstraint?.constant != contraint) { widthConstraint = widthAnchor.constraint(equalToConstant: contraint) widthConstraint?.isActive = true - } else { + } else if minimumWidthConstraint == nil { minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) minimumWidthConstraint?.isActive = true } From c276b09d7433fb3103e9c606a3337f8beb1e0948 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 2 May 2022 17:39:03 -0400 Subject: [PATCH 18/49] reorganizing defaults --- .../Protocols/MoleculeDelegateProtocol.swift | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift index 1d0a3f61..f2f01b6c 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeDelegateProtocol.swift @@ -23,4 +23,33 @@ public protocol MoleculeDelegateProtocol: AnyObject { extension MoleculeDelegateProtocol { public func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { } + + public func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? { + let moduleJSON: [AnyHashable: Any]? = getModuleWithName(moleculeName) + guard let moduleJSON = moduleJSON as? [String: Any], + let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), + let modelType = ModelRegistry.getType(for: moleculeName, with: MoleculeModelProtocol.self) + else { return nil } + + do { + return try modelType.decode(jsonDict: moduleJSON as [String : Any]) as? MoleculeModelProtocol + } catch { + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") + } + + return nil + } +} + +extension MoleculeDelegateProtocol where Self: TemplateProtocol { + public func getRootMolecules() -> [MoleculeModelProtocol] { + templateModel?.rootMolecules ?? [] + } +} + +extension MoleculeDelegateProtocol where Self: MVMCoreViewControllerProtocol { + public func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? { + guard let name = name else { return nil } + return loadObject??.modulesJSON?.optionalDictionaryForKey(name) + } } From 35f1cc5c178a0827fdc2c817984351204c547997 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 2 May 2022 17:43:18 -0400 Subject: [PATCH 19/49] template protocol update --- .../Atomic/Protocols/TemplateProtocol.swift | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 3d1bea9c..06660715 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -8,43 +8,46 @@ import Foundation -public protocol TemplateProtocol: AnyObject { +public protocol TemplateProtocol: AnyObject, PageProtocol { associatedtype TemplateModel: TemplateModelProtocol var templateModel: TemplateModel? { get set } func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> TemplateModel } -public extension TemplateProtocol where Self: ViewController { +public extension TemplateProtocol { + // Utilize existing underlying property + var templateModel: TemplateModel? { + get { + pageModel as? TemplateModel + } + set { + var mutableSelf = self + mutableSelf.pageModel = newValue + } + } + + /// Helper function to do common parsing logic. func parseTemplate(json: [AnyHashable: Any]?) throws { guard let pageJSON = json else { return } + let delegateObject = (self as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject let data = try JSONSerialization.data(withJSONObject: pageJSON) let decoder = JSONDecoder() - try decoder.add(delegateObject: delegateObjectIVar) + if let delegateObject = delegateObject { + // Add the delegate to access mid parsing if applicable. + try decoder.add(delegateObject: delegateObject) + } templateModel = try decodeTemplate(using: decoder, from: data) - model = templateModel as? MVMControllerModelProtocol - guard let model = model else { return } - traverseAndAddRequiredBehaviors() - var behaviorHandler = self - behaviorHandler.createBehaviors(for: model, delegateObject: delegateObjectIVar) + + // Add additional required behaviors if applicable. + guard var behaviorHandlerModel = templateModel as? TemplateModelProtocol & PageBehaviorHandlerModelProtocol, + var behaviorHandler = self as? PageBehaviorHandlerProtocol else { return } + behaviorHandlerModel.traverseAndAddRequiredBehaviors() + behaviorHandler.createBehaviors(for: behaviorHandlerModel, delegateObject: delegateObject) } func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> TemplateModel { try decoder.decode(TemplateModel.self, from: data) } - - /// Traverses all models and adds any required behavior models. - func traverseAndAddRequiredBehaviors() { - guard var model = model else { return } - let behaviorModels: [PageBehaviorModelProtocol] = model.reduceDepthFirstTraverse(options: .childFirst, depth: 0, initialResult: []) { (accumulator, molecule, depth) in - if let behaviorRequirer = molecule as? PageBehaviorProtocolRequirer { - return accumulator + behaviorRequirer.getRequiredBehaviors() - } - return accumulator - } - for behavior in behaviorModels { - model.add(behavior: behavior) - } - } } From 27f7c223400873b45ad71f7369ab90f6aff38fa8 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 2 May 2022 17:47:25 -0400 Subject: [PATCH 20/49] Change conflicting name TemplateModel to BaseTemplateModel --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++---- .../{TemplateModel.swift => BaseTemplateModel.swift} | 4 ++-- MVMCoreUI/Atomic/Templates/CollectionTemplate.swift | 1 - MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 4 +--- MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift | 1 - MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift | 2 +- MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift | 5 ----- 7 files changed, 8 insertions(+), 17 deletions(-) rename MVMCoreUI/Atomic/Templates/{TemplateModel.swift => BaseTemplateModel.swift} (96%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0e5dacbb..aa280b9a 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -345,7 +345,7 @@ D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */; }; D22479962316AF6E003FCCF9 /* HeadlineBodyLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479952316AF6D003FCCF9 /* HeadlineBodyLink.swift */; }; D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */; }; - D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; + D22D8393241C27B100D3DF69 /* BaseTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* BaseTemplateModel.swift */; }; D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */; }; D23118B325124E18001C8440 /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = D23118B225124E18001C8440 /* Notification.swift */; }; D2351C7A24A4D433007DF0BC /* ListRightVariableToggleAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2351C7924A4D433007DF0BC /* ListRightVariableToggleAllTextAndLinksModel.swift */; }; @@ -930,7 +930,7 @@ D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutConstraintExtension.swift; sourceTree = ""; }; D22479952316AF6D003FCCF9 /* HeadlineBodyLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyLink.swift; sourceTree = ""; }; D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccordionMoleculeTableViewCell.swift; sourceTree = ""; }; - D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; + D22D8392241C27B100D3DF69 /* BaseTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTemplateModel.swift; sourceTree = ""; }; D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+Extension.swift"; sourceTree = ""; }; D23118B225124E18001C8440 /* Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = ""; }; D2351C7924A4D433007DF0BC /* ListRightVariableToggleAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableToggleAllTextAndLinksModel.swift; sourceTree = ""; }; @@ -1969,7 +1969,7 @@ D29DF0DF21E418B2003B2FB9 /* Templates */ = { isa = PBXGroup; children = ( - D22D8392241C27B100D3DF69 /* TemplateModel.swift */, + D22D8392241C27B100D3DF69 /* BaseTemplateModel.swift */, D2092356244FA1EF0044AD09 /* ThreeLayerModelBase.swift */, 014AA72823C5059B006F3E93 /* StackPageTemplateModel.swift */, D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */, @@ -3057,7 +3057,7 @@ D23EA7FE247EBBB700D60C34 /* NavigationLabelButtonModel.swift in Sources */, D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */, 012A88F123985E0100FE3DA1 /* Color.swift in Sources */, - D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */, + D22D8393241C27B100D3DF69 /* BaseTemplateModel.swift in Sources */, 012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */, EAA0CFB1275E823A00D65EB0 /* HideFormFieldEffectModel.swift in Sources */, D23A8FFB26123189007E14CE /* PageBehaviorModelProtocol.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Templates/TemplateModel.swift b/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift similarity index 96% rename from MVMCoreUI/Atomic/Templates/TemplateModel.swift rename to MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift index 27cb3183..21024474 100644 --- a/MVMCoreUI/Atomic/Templates/TemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/BaseTemplateModel.swift @@ -1,5 +1,5 @@ // -// TemplateModel.swift +// BaseTemplateModel.swift // MVMCoreUI // // Created by Scott Pfeil on 3/13/20. @@ -9,7 +9,7 @@ import Foundation -@objcMembers open class TemplateModel: MVMControllerModelProtocol, TabPageModelProtocol { +@objcMembers open class BaseTemplateModel: MVMControllerModelProtocol, TabPageModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift index f3bd5d83..b1128d8e 100644 --- a/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/CollectionTemplate.swift @@ -13,7 +13,6 @@ //-------------------------------------------------- public typealias TemplateModel = CollectionTemplateModel - public var templateModel: CollectionTemplateModel? public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (CollectionItemModelProtocol & MoleculeModelProtocol))]? diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index fa404172..d797038d 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -19,9 +19,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol public var moleculesInfo: [MoleculeInfo]? var observer: NSKeyValueObservation? - - public var templateModel: ListPageTemplateModel? - + //-------------------------------------------------- // MARK: - Computed Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift index 046469a8..61b247fb 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeStackTemplate.swift @@ -15,7 +15,6 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { //-------------------------------------------------- var observer: NSKeyValueObservation? - public var templateModel: StackPageTemplateModel? //-------------------------------------------------- // MARK: - Lifecycle diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift index 06d813ef..9f130089 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerModelBase.swift @@ -7,7 +7,7 @@ // -@objcMembers open class ThreeLayerModelBase: TemplateModel, ThreeLayerTemplateModelProtocol { +@objcMembers open class ThreeLayerModelBase: BaseTemplateModel, ThreeLayerTemplateModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift index 502b269f..4d1a4a66 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerTemplate.swift @@ -9,11 +9,6 @@ import UIKit @objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - public var templateModel: TemplateModel? //-------------------------------------------------- // MARK: - Lifecycle From d1239eda74a60f53a70f5b174b6fe7e7f7ebc5fd Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 2 May 2022 17:50:00 -0400 Subject: [PATCH 21/49] move functions to default --- .../BaseControllers/ViewController.swift | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index d7e947db..26ab983f 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -484,26 +484,6 @@ import UIKit model?.rootMolecules ?? [] } - open func getModuleWithName(_ name: String?) -> [AnyHashable: Any]? { - guard let name = name else { return nil } - return loadObject?.modulesJSON?.optionalDictionaryForKey(name) - } - - open func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? { - guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moleculeName), - let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), - let modelType = ModelRegistry.getType(for: moleculeName, with: MoleculeModelProtocol.self) - else { return nil } - - do { - return try modelType.decode(jsonDict: moduleJSON) as? MoleculeModelProtocol - } catch { - MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") - } - - return nil - } - // Needed otherwise when subclassed, the extension gets called. open func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) { } @@ -618,12 +598,4 @@ import UIKit selectedField = nil } } - - //-------------------------------------------------- - // MARK: - Behavior Execution - //-------------------------------------------------- - - public func executeBehaviors(_ behaviorBlock: (_ behavior: T) -> Void) { - behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) } - } } From 48388343ef06794a1b9a494135d7d1c0f7d1bc41 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 2 May 2022 17:51:08 -0400 Subject: [PATCH 22/49] Move function for scoping purposes --- .../PageBehaviorHandlerModelProtocol.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerModelProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerModelProtocol.swift index d9b8da9f..bb752694 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerModelProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerModelProtocol.swift @@ -23,3 +23,19 @@ public extension PageBehaviorHandlerModelProtocol { self.behaviors = newBehaviors } } + +public extension PageBehaviorHandlerModelProtocol where Self: MoleculeTreeTraversalProtocol { + + /// Traverses all models and adds any required behavior models. + mutating func traverseAndAddRequiredBehaviors() { + let behaviorModels: [PageBehaviorModelProtocol] = reduceDepthFirstTraverse(options: .childFirst, depth: 0, initialResult: []) { (accumulator, molecule, depth) in + if let behaviorRequirer = molecule as? PageBehaviorProtocolRequirer { + return accumulator + behaviorRequirer.getRequiredBehaviors() + } + return accumulator + } + for behavior in behaviorModels { + add(behavior: behavior) + } + } +} From 6762082b7c24e248b5c2922bde7d8fd4e0f27715 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 2 May 2022 17:52:15 -0400 Subject: [PATCH 23/49] move function behavior for scoping --- .../Behaviors/Protocols/PageBehaviorHandlerProtocol.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift index eb244cbf..cdabba87 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift @@ -34,4 +34,9 @@ public extension PageBehaviorHandlerProtocol { } self.behaviors = behaviors.count > 0 ? behaviors : nil } + + /// Executes all behaviors of type. + public func executeBehaviors(_ behaviorBlock: (_ behavior: T) -> Void) { + behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) } + } } From 677c352b9eae42227b3722b08477d868ba4b9014 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 2 May 2022 17:54:37 -0400 Subject: [PATCH 24/49] convenience functions --- .../Behaviors/Protocols/PageBehaviorHandlerProtocol.swift | 2 +- MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift index cdabba87..79f3364f 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorHandlerProtocol.swift @@ -36,7 +36,7 @@ public extension PageBehaviorHandlerProtocol { } /// Executes all behaviors of type. - public func executeBehaviors(_ behaviorBlock: (_ behavior: T) -> Void) { + func executeBehaviors(_ behaviorBlock: (_ behavior: T) -> Void) { behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) } } } diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 3f14f3cc..76bc7f84 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -50,8 +50,11 @@ public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol { } public extension MVMCoreUIDelegateObject { + var behaviorModelDelegate: PageBehaviorHandlerModelProtocol? { + (moleculeDelegate as? PageProtocol)?.pageModel as? PageBehaviorHandlerModelProtocol + } weak var behaviorTemplateDelegate: (PageBehaviorHandlerProtocol & NSObjectProtocol)? { - (moleculeDelegate as? PageProtocol)?.pageModel as? (PageBehaviorHandlerProtocol & NSObjectProtocol) + moleculeDelegate as? (PageBehaviorHandlerProtocol & NSObjectProtocol) } } From 5f6e987da81168f7a41c01f3bfba89c79e5bcb49 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Tue, 3 May 2022 23:26:38 +0530 Subject: [PATCH 25/49] modifying button border changes --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 7960fd99..84600397 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -43,6 +43,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { @objc public convenience init(asPrimaryButton isPrimary: Bool, makeTiny istiny: Bool) { self.init() + model = ButtonModel.init(with: "", action: ActionOpenPageModel(pageType: "noop")) buttonSize = istiny ? .tiny : .standard isPrimary ? stylePrimary() : styleSecondary() } @@ -90,6 +91,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { if buttonModel?.style == .primary { layer.borderWidth = 0 + } else if buttonModel?.style == .secondary { + layer.borderWidth = 1 } if let titleColor = buttonModel?.enabledColors.text { @@ -111,7 +114,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } if let borderColor = buttonModel?.enabledColors.border { - layer.borderWidth = 1 self.borderColor = borderColor } } else { @@ -120,7 +122,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { } if let borderColor = buttonModel?.disabledColors.border { - layer.borderWidth = 1 self.borderColor = borderColor } } @@ -160,7 +161,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { guard let model = model as? ButtonModel else { return } - style() setTitle(model.title, for: .normal) if let accessibilityText = model.accessibilityText { accessibilityLabel = accessibilityText From b6226616d8ebe465b19d324721c021e57b113a95 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 5 May 2022 12:33:13 -0400 Subject: [PATCH 26/49] Remove tab bar logic from base controllers and move to the manager. --- .../BaseControllers/ViewController.swift | 43 ------------------- .../MVMCoreUISplitViewController.h | 3 ++ .../MVMCoreUISplitViewController.m | 9 +++- 3 files changed, 11 insertions(+), 44 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 26ab983f..772742b4 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -43,9 +43,6 @@ import UIKit public var selectedField: UIView? - // Stores the previous tab bar index. - public var tabBarIndex: Int? - /// Checks if the screen width has changed open func screenSizeChanged() -> Bool { !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1) @@ -244,12 +241,6 @@ import UIKit view.backgroundColor = backgroundColor.uiColor } - // Update splitview properties - if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { - MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0) - updateTabBar() - } - // Notify the manager of new data manager?.newDataReceived?(in: self) } @@ -267,34 +258,6 @@ import UIKit return model?.navigationBar } - //-------------------------------------------------- - // MARK: - TabBar - //-------------------------------------------------- - - open func updateTabBar() { - guard MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() == self else { return } - MVMCoreUISplitViewController.main()?.tabBar?.delegateObject = delegateObjectIVar - - if let index = (model as? TabPageModelProtocol)?.tabBarIndex { - MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index) - } else if let index = loadObject?.requestParameters?.actionMap?["tabBarIndex"] as? Int { - MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index) - } else if let index = self.tabBarIndex { - MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index) - } else if let index = MVMCoreUISplitViewController.main()?.tabBar?.currentTabIndex() { - // Store current tab index for cases like back button. - self.tabBarIndex = index - } - - if let hidden = (model as? TabPageModelProtocol)?.tabBarHidden { - MVMCoreUISplitViewController.main()?.updateTabBarShowing(!hidden) - } else if let hidden = loadObject?.requestParameters?.actionMap?["tabBarHidden"] as? Bool { - MVMCoreUISplitViewController.main()?.updateTabBarShowing(!hidden) - } else { - MVMCoreUISplitViewController.main()?.updateTabBarShowing(true) - } - } - //-------------------------------------------------- // MARK: - View Lifecycle //-------------------------------------------------- @@ -349,12 +312,6 @@ import UIKit } open func pageShown() { - // Update split view properties if this is the current detail controller. - if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() { - MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0) - updateTabBar() - } - // Track. MVMCoreUISession.sharedGlobal()?.currentPageType = pageType MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index db5e9cd9..d0530cc9 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -55,6 +55,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { /// Reference to the tabbar. @property (nullable, weak, nonatomic) UIView *tabBar; +/// Tab bar index history. +@property (nonnull, strong, nonatomic) NSMutableArray *tabBarIndices; + // Convenience getter + (nullable instancetype)mainSplitViewController; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 5c337072..e005763b 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -93,13 +93,20 @@ CGFloat const PanelAnimationDuration = 0.2; } - (nullable instancetype)initWithLeftPanel:(nullable UIViewController *)leftPanel rightPanel:(nullable UIViewController *)rightPanel { - if (self = [super init]) { + if (self = [self init]) { self.globalLeftPanel = leftPanel; self.globalRightPanel = rightPanel; } return self; } +- (nullable instancetype)init { + if (self = [super init]) { + self.tabBarIndices = [NSMutableArray array]; + } + return self; +} + #pragma mark - Main Subclassables - (MFNumberOfDrawers)numberOfDrawersShouldShow:(NSNumber *)forWidth { From f2fd2c8d493dfe03766a0157d7e27aa44a77900e Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 5 May 2022 12:38:32 -0400 Subject: [PATCH 27/49] comments and new functions for setting --- ...MCoreUISplitViewController+Extension.swift | 63 ++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 12935302..3c6c878b 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -12,6 +12,64 @@ import UIKit // Navigation bar update functions public extension MVMCoreUISplitViewController { + /// Updates the state for various controls (navigation, tab, progress) for the controller. + func updateState(with viewController: UIViewController) { + guard let navigationController = navigationController, + navigationController.isDisplayed(viewController: viewController) else { return } + updateNavigationBarFor(viewController: viewController) + updateProgressBar(for: viewController) + updateTabBar(for: viewController) + } + + // MARK: - Progress Bar + /// Updates the progress bar based on the page json for the view controller. + func updateProgressBar(for viewController: UIViewController) { + guard let viewController = viewController as? MVMCoreViewControllerProtocol else { return } + var progress: Float = 0.0 + if let progressString = viewController.loadObject??.pageJSON?.optionalStringForKey(KeyProgressPercent), + let floatValue = Float(progressString) { + progress = floatValue/100 + } + setBottomProgressBarProgress(progress) + } + + // MARK: - Tab Bar + /// Updates the tab bar based on the page json for the view controller. + func updateTabBar(for viewController: UIViewController) { + let mvmViewController = viewController as? MVMCoreViewControllerProtocol + tabBar?.delegateObject = mvmViewController?.delegateObject?() as? MVMCoreUIDelegateObject + + let navigationIndex = (MVMCoreNavigationHandler.shared()?.getViewControllers(for: navigationController)?.count ?? 1) - 1 + + // Set the highlighted index. In terms of priority, Page > Action > Previous. + if let index = ((viewController as? PageProtocol)?.pageModel as? TabPageModelProtocol)?.tabBarIndex { + tabBar?.highlightTab(at: index) + } else if let index = mvmViewController?.loadObject??.requestParameters?.actionMap?["tabBarIndex"] as? Int { + tabBar?.highlightTab(at: index) + } else if navigationIndex < tabBarIndices.count { + let index = (tabBarIndices[navigationIndex] as! NSNumber).intValue + tabBar?.highlightTab(at: index) + } + + // Store current tab index, so we can switch back when going back in hierarchy. + if tabBarIndices.count > 0 { + tabBarIndices.removeObjects(in: NSRange(location: navigationIndex, length: tabBarIndices.count - navigationIndex)) + } + if let currentIndex = tabBar?.currentTabIndex() { + tabBarIndices.add(NSNumber(integerLiteral: currentIndex)) + } + + // Show/Hide. In terms of priority, Page > Action > Always Show. + if let hidden = ((viewController as? PageProtocol)?.pageModel as? TabPageModelProtocol)?.tabBarHidden { + updateTabBarShowing(!hidden) + } else if let hidden = mvmViewController?.loadObject??.requestParameters?.actionMap?["tabBarHidden"] as? Bool { + updateTabBarShowing(!hidden) + } else { + updateTabBarShowing(true) + } + } + + // MARK: - Navigation Bar /// Convenience function. Sets the navigation and split view properties for the view controller. Panel access is determined if view controller is a detail view protocol. func setNavigationBar(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol) { guard navigationController == self.navigationController, @@ -122,6 +180,7 @@ public extension MVMCoreUISplitViewController { setStatusBarForCurrentViewController() } + // MARK: - Status Bar /// Returns the bar style for the background color. Light if on a dark background, otherwise default. func getStatusBarStyle(for backgroundColor: UIColor?) -> UIStatusBarStyle { var greyScale: CGFloat = 0 @@ -155,10 +214,10 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { public func willDisplay(_ viewController: UIViewController) { setupPanels() - updateNavigationBarFor(viewController: viewController) + updateState(with: viewController) } public func newDataReceived(in viewController: UIViewController) { - updateNavigationBarFor(viewController: viewController) + updateState(with: viewController) } } From 2a1db08ab77c77441d93434f8ad889fc29b7e074 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 6 May 2022 15:51:53 +0530 Subject: [PATCH 28/49] setting button style and constraints. --- .../Atomic/Atoms/Buttons/PillButton.swift | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 84600397..10fb4b72 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -34,8 +34,13 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { // MARK: - Constraints //-------------------------------------------------- - public var widthConstraint: NSLayoutConstraint? - public var minimumWidthConstraint: NSLayoutConstraint? + public var widthConstraint: NSLayoutConstraint { + return widthAnchor.constraint(equalToConstant: 0) + } + + public var minimumWidthConstraint: NSLayoutConstraint { + return widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) + } //-------------------------------------------------- // MARK: - Initializers @@ -78,12 +83,14 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { public func stylePrimary() { buttonModel?.setPrimaryFacade() + style() } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { buttonModel?.setSecondaryFacade() + style() } /// Styles the button based on the model style @@ -199,12 +206,13 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width, (widthConstraint == nil || widthConstraint?.constant != contraint) { - widthConstraint = widthAnchor.constraint(equalToConstant: contraint) - widthConstraint?.isActive = true - } else if minimumWidthConstraint == nil { - minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) - minimumWidthConstraint?.isActive = true + if let contraint = buttonModel?.width, widthConstraint.constant != contraint { + widthConstraint.constant = contraint + widthConstraint.isActive = true + minimumWidthConstraint.isActive = false + } else if !minimumWidthConstraint.isActive { + minimumWidthConstraint.isActive = true + widthConstraint.isActive = false } } From 45a1532f68fa384695dfac0e12cfd1e9c7bc48c5 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 6 May 2022 22:13:56 +0530 Subject: [PATCH 29/49] updates to button width constraint --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 10fb4b72..ab46e476 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -211,6 +211,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { widthConstraint.isActive = true minimumWidthConstraint.isActive = false } else if !minimumWidthConstraint.isActive { + minimumWidthConstraint.constant = buttonSize.minimumWidth() minimumWidthConstraint.isActive = true widthConstraint.isActive = false } From 89bc6c72ab3453f9566a47aa7945ebf25967396b Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 7 May 2022 01:46:41 +0530 Subject: [PATCH 30/49] Updating default button style --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index a6453dd5..d180c884 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -85,6 +85,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action + setFacade(by: style ?? .primary) } public init(secondaryButtonWith title: String, action: ActionModelProtocol) { @@ -218,6 +219,8 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style) { self.style = style setFacade(by: style) + } else { + setFacade(by: .primary) } if let size = try typeContainer.decodeIfPresent(Styler.Button.Size.self, forKey: .size) { From adb337f8650a3af954112851d9bdb4b011573854 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 7 May 2022 23:46:56 +0530 Subject: [PATCH 31/49] Updating button constraints --- .../Atomic/Atoms/Buttons/PillButton.swift | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index ab46e476..39bb8b24 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -34,13 +34,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { // MARK: - Constraints //-------------------------------------------------- - public var widthConstraint: NSLayoutConstraint { - return widthAnchor.constraint(equalToConstant: 0) - } - - public var minimumWidthConstraint: NSLayoutConstraint { - return widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) - } + public var widthConstraint: NSLayoutConstraint? + public var minimumWidthConstraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Initializers @@ -206,14 +201,24 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { layer.cornerRadius = getInnerPadding() contentEdgeInsets = getContentEdgeInsets() - if let contraint = buttonModel?.width, widthConstraint.constant != contraint { - widthConstraint.constant = contraint - widthConstraint.isActive = true - minimumWidthConstraint.isActive = false - } else if !minimumWidthConstraint.isActive { - minimumWidthConstraint.constant = buttonSize.minimumWidth() - minimumWidthConstraint.isActive = true - widthConstraint.isActive = false + if let contraint = buttonModel?.width { + + if widthConstraint == nil { + widthConstraint = widthAnchor.constraint(equalToConstant: contraint) + } else if widthConstraint?.constant != contraint { + widthConstraint?.constant = contraint + } + widthConstraint?.isActive = true + minimumWidthConstraint?.isActive = false + } else { + + if minimumWidthConstraint == nil { + minimumWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: buttonSize.minimumWidth()) + } else { + minimumWidthConstraint?.constant = buttonSize.minimumWidth() + } + minimumWidthConstraint?.isActive = true + widthConstraint?.isActive = false } } From d3cac3f36db4171e69bce96e954379f81ff2a628 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Mon, 9 May 2022 14:29:59 +0530 Subject: [PATCH 32/49] 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) } } From f589a5249eaadbdd5cbcd7e07eca7917cd90a8ed Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 9 May 2022 12:57:14 -0400 Subject: [PATCH 33/49] Button fixes for other containers --- .../Atomic/Atoms/Buttons/ButtonModel.swift | 36 ++++++----------- .../Atomic/Atoms/Buttons/PillButton.swift | 40 ++++++++----------- .../TopAlert/MVMCoreUITopAlertMainView.m | 1 - 3 files changed, 30 insertions(+), 47 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index d180c884..fae40f0c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -24,7 +24,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var action: ActionModelProtocol public var enabled: Bool = true public var width: CGFloat? - public var style: Styler.Button.Style? = .primary { + public var style: Styler.Button.Style? { didSet { guard let style = style else { return } setFacade(by: style) @@ -85,19 +85,21 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public init(with title: String, action: ActionModelProtocol) { self.title = title self.action = action - setFacade(by: style ?? .primary) + setFacade(by: .primary) } public init(secondaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .secondary + setFacade(by: .secondary) } public init(primaryButtonWith title: String, action: ActionModelProtocol) { self.title = title self.action = action style = .primary + setFacade(by: .primary) } //-------------------------------------------------- @@ -130,16 +132,10 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat /// Defines the default appearance for the primary style. func setPrimaryFacade() { - - if enabledFillColor == nil && enabledTextColor == nil { - enabledFillColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) - } - - if disabledFillColor == nil && disabledTextColor == nil { - disabledFillColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - disabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) - } + enabledFillColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) + disabledFillColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + disabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOndark) enabledFillColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOnlight) @@ -149,17 +145,11 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat /// Defines the default appearance for the Secondary style. func setSecondaryFacade() { - - if enabledTextColor == nil && enabledBorderColor == nil { - enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - enabledFillColor = Color(uiColor: UIColor.clear) - enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) - } - - if disabledTextColor == nil && disabledBorderColor == nil { - disabledTextColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - disabledBorderColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) - } + enabledTextColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + enabledFillColor = Color(uiColor: UIColor.clear) + enabledBorderColor = Color(uiColor: VDSColor.elementsPrimaryOnlight) + disabledTextColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) + disabledBorderColor = Color(uiColor: VDSColor.interactiveDisabledOnlight) enabledTextColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark) enabledFillColor_inverted = Color(uiColor: UIColor.clear) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 39bb8b24..6b47f112 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -23,7 +23,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// Need to re-style on set. open override var isEnabled: Bool { - didSet { style() } + didSet { style(with: buttonModel) } } open var buttonSize: Styler.Button.Size = .standard { @@ -42,10 +42,10 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { //-------------------------------------------------- @objc public convenience init(asPrimaryButton isPrimary: Bool, makeTiny istiny: Bool) { - self.init() - model = ButtonModel.init(with: "", action: ActionOpenPageModel(pageType: "noop")) - buttonSize = istiny ? .tiny : .standard - isPrimary ? stylePrimary() : styleSecondary() + let model = ButtonModel(with: "", action: ActionNoopModel()) + model.style = isPrimary ? .primary : .secondary + model.size = istiny ? .tiny : .standard + self.init(model: model, nil, nil) } //-------------------------------------------------- @@ -76,32 +76,26 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { /// The primary styling for a button. Should be used for main buttons public func stylePrimary() { - - buttonModel?.setPrimaryFacade() - style() + let buttonModel = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) + style(with: buttonModel) } /// The secondary styling for a button. Should be used for secondary buttons public func styleSecondary() { - - buttonModel?.setSecondaryFacade() - style() + let buttonModel = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) + style(with: buttonModel) } /// Styles the button based on the model style - private func style() { + private func style(with model: ButtonModel?) { - if buttonModel?.style == .primary { - layer.borderWidth = 0 - } else if buttonModel?.style == .secondary { - layer.borderWidth = 1 - } + layer.borderWidth = model?.style == .secondary ? 1 : 0 - if let titleColor = buttonModel?.enabledColors.text { + if let titleColor = model?.enabledColors.text { enabledTitleColor = titleColor } - if let disabledTitleColor = buttonModel?.disabledColors.text { + if let disabledTitleColor = model?.disabledColors.text { self.disabledTitleColor = disabledTitleColor } @@ -111,19 +105,19 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { #endif if isEnabled { - if let fillColor = buttonModel?.enabledColors.fill { + if let fillColor = model?.enabledColors.fill { backgroundColor = fillColor } - if let borderColor = buttonModel?.enabledColors.border { + if let borderColor = model?.enabledColors.border { self.borderColor = borderColor } } else { - if let fillColor = buttonModel?.disabledColors.fill { + if let fillColor = model?.disabledColors.fill { backgroundColor = fillColor } - if let borderColor = buttonModel?.disabledColors.border { + if let borderColor = model?.disabledColors.border { self.borderColor = borderColor } } diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m index fa96630f..d2a009c9 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m @@ -204,7 +204,6 @@ // Sets up to use a button action. Always uses the top view controller PillButton *button = [[PillButton alloc] initAsPrimaryButton:false makeTiny:true]; - [button styleSecondary]; [button setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; [button setContentHuggingPriority:800 forAxis:UILayoutConstraintAxisHorizontal]; From a59560e37bee5760f54de542432aa5ef8302fd06 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 10 May 2022 12:11:32 -0500 Subject: [PATCH 34/49] updated models for use of Decoder Context Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 5 +++++ .../TwoButtonViewModel.swift | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 3b72d37c..5bff2a39 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -198,6 +198,11 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat title = try typeContainer.decode(String.self, forKey: .title) action = try typeContainer.decodeModel(codingKey: .action) + if let style = decoder.context?.value(forKey: CodingKeys.style.stringValue) as? Styler.Button.Style{ + self.style = style + setFacade(by: style) + } + if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style) { self.style = style setFacade(by: style) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 4d843e6a..718cfc30 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -50,13 +50,17 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - primaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .primaryButton) - if primaryButton?.style == nil { - primaryButton?.style = .primary + + //set context value for 'primary' style to be set for the primaryButton in case the + //property is not returned in the JSON and once decoded, this value is removed from the context + try decoder.setContext(value: Styler.Button.Style.primary, for: "style") { + self.primaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .primaryButton) } - secondaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .secondaryButton) - if secondaryButton?.style == nil { - secondaryButton?.style = .secondary + + //set context value for 'secondary' style to be set for the primaryButton in case the + //property is not returned in the JSON and once decoded, this value is removed from the context + try decoder.setContext(value: Styler.Button.Style.secondary, for: "style") { + self.secondaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .secondaryButton) } } From 33100758b8af9f26951b25c9f2b1e7456abce747 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 10 May 2022 12:11:48 -0500 Subject: [PATCH 35/49] udpated constructors for JSONDecoder Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift | 6 +----- MVMCoreUI/TopAlert/TopNotificationModel.swift | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 06660715..4fdff197 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -33,11 +33,7 @@ public extension TemplateProtocol { guard let pageJSON = json else { return } let delegateObject = (self as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject let data = try JSONSerialization.data(withJSONObject: pageJSON) - let decoder = JSONDecoder() - if let delegateObject = delegateObject { - // Add the delegate to access mid parsing if applicable. - try decoder.add(delegateObject: delegateObject) - } + let decoder = try JSONDecoder.create(delegateObject: delegateObjectIVar) templateModel = try decodeTemplate(using: decoder, from: data) // Add additional required behaviors if applicable. diff --git a/MVMCoreUI/TopAlert/TopNotificationModel.swift b/MVMCoreUI/TopAlert/TopNotificationModel.swift index 7c07c980..7d19bfcf 100644 --- a/MVMCoreUI/TopAlert/TopNotificationModel.swift +++ b/MVMCoreUI/TopAlert/TopNotificationModel.swift @@ -69,10 +69,7 @@ open class TopNotificationModel: Codable { /// Decodes the top alert json to a model. public static func decode(json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) throws -> Self { let data = try JSONSerialization.data(withJSONObject: json) - let decoder = JSONDecoder() - if let delegateObject = delegateObject { - try decoder.add(delegateObject: delegateObject) - } + let decoder = try JSONDecoder.create(delegateObject: delegateObject) return try decoder.decode(self, from: data) } From c5281fa39070b50f53266bac6d621ec12f15a1cf Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 10 May 2022 12:14:13 -0500 Subject: [PATCH 36/49] fixed bug Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 4fdff197..91acdb77 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -33,7 +33,7 @@ public extension TemplateProtocol { guard let pageJSON = json else { return } let delegateObject = (self as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject let data = try JSONSerialization.data(withJSONObject: pageJSON) - let decoder = try JSONDecoder.create(delegateObject: delegateObjectIVar) + let decoder = try JSONDecoder.create(delegateObject: delegateObject) templateModel = try decodeTemplate(using: decoder, from: data) // Add additional required behaviors if applicable. From 42c203e77366c25f2612707206aa89c5f3e46f3a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 10 May 2022 12:16:47 -0500 Subject: [PATCH 37/49] removed try Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift | 2 +- MVMCoreUI/TopAlert/TopNotificationModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 91acdb77..0df77ff1 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -33,7 +33,7 @@ public extension TemplateProtocol { guard let pageJSON = json else { return } let delegateObject = (self as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject let data = try JSONSerialization.data(withJSONObject: pageJSON) - let decoder = try JSONDecoder.create(delegateObject: delegateObject) + let decoder = JSONDecoder.create(delegateObject: delegateObject) templateModel = try decodeTemplate(using: decoder, from: data) // Add additional required behaviors if applicable. diff --git a/MVMCoreUI/TopAlert/TopNotificationModel.swift b/MVMCoreUI/TopAlert/TopNotificationModel.swift index 7d19bfcf..8e885e22 100644 --- a/MVMCoreUI/TopAlert/TopNotificationModel.swift +++ b/MVMCoreUI/TopAlert/TopNotificationModel.swift @@ -69,7 +69,7 @@ open class TopNotificationModel: Codable { /// Decodes the top alert json to a model. public static func decode(json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) throws -> Self { let data = try JSONSerialization.data(withJSONObject: json) - let decoder = try JSONDecoder.create(delegateObject: delegateObject) + let decoder = JSONDecoder.create(delegateObject: delegateObject) return try decoder.decode(self, from: data) } From d879b8c71f4bde21db47c45bfd682f5c8e5382bd Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 10 May 2022 14:50:27 -0500 Subject: [PATCH 38/49] refactored create(with: Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift | 2 +- MVMCoreUI/TopAlert/TopNotificationModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 0df77ff1..082f2da3 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -33,7 +33,7 @@ public extension TemplateProtocol { guard let pageJSON = json else { return } let delegateObject = (self as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject let data = try JSONSerialization.data(withJSONObject: pageJSON) - let decoder = JSONDecoder.create(delegateObject: delegateObject) + let decoder = JSONDecoder.create(with: delegateObject) templateModel = try decodeTemplate(using: decoder, from: data) // Add additional required behaviors if applicable. diff --git a/MVMCoreUI/TopAlert/TopNotificationModel.swift b/MVMCoreUI/TopAlert/TopNotificationModel.swift index 8e885e22..75300a3f 100644 --- a/MVMCoreUI/TopAlert/TopNotificationModel.swift +++ b/MVMCoreUI/TopAlert/TopNotificationModel.swift @@ -69,7 +69,7 @@ open class TopNotificationModel: Codable { /// Decodes the top alert json to a model. public static func decode(json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) throws -> Self { let data = try JSONSerialization.data(withJSONObject: json) - let decoder = JSONDecoder.create(delegateObject: delegateObject) + let decoder = JSONDecoder.create(with: delegateObject) return try decoder.decode(self, from: data) } From a0fd19ea7aace29cfb74e5441efe028b994f2854 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Wed, 11 May 2022 21:11:34 +0530 Subject: [PATCH 39/49] Removing font scaling for Pillbutton --- MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 6b47f112..e578fa51 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -185,11 +185,11 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol { switch buttonSize { case .tiny: - titleLabel?.font = Styler.Font.BoldMicro.getFont() + titleLabel?.font = Styler.Font.BoldMicro.getFont(false) case .small: - titleLabel?.font = Styler.Font.BoldBodySmall.getFont() + titleLabel?.font = Styler.Font.BoldBodySmall.getFont(false) case .standard: - titleLabel?.font = Styler.Font.BoldBodyLarge.getFont() + titleLabel?.font = Styler.Font.BoldBodyLarge.getFont(false) } layer.cornerRadius = getInnerPadding() From eaf4bbe116653b6b8c6e8c4c6b1097e92abb0b9b Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 19 May 2022 13:21:27 -0400 Subject: [PATCH 40/49] background color, bridge mf view controller new data, optional delegate --- MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift | 2 +- MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift index ee4d9587..a3be96f5 100644 --- a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift +++ b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift @@ -75,7 +75,7 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo self.delegate = delegateObject } - public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) { + public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) { guard let list = delegate?.moleculeListDelegate else { return } for case let model as (MoleculeModelProtocol & ListItemModelProtocol & AddMolecules) in rootMolecules { if let moleculesToAdd = model.getRecursiveMoleculesToAdd(), diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 76bc7f84..eadd5e4e 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -19,7 +19,7 @@ public protocol PageBehaviorProtocol: ModelHandlerProtocol { public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol { - func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject) + func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) } public protocol PageVisibilityBehavior: PageBehaviorProtocol { From 6ad5ebbf92d7c2d4c6d6d8e955af1ab3bf6509ac Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 19 May 2022 17:41:35 -0400 Subject: [PATCH 41/49] 3.0 font updates --- .../Atomic/Molecules/HorizontalCombinationViews/TabBar.swift | 4 ++-- .../UINavigationController+Extension.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index e7096069..527ed054 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -58,11 +58,11 @@ import VDSColorTokens /// Sets the item colors. private func set(tabItemAppearance: UITabBarItemAppearance, model: TabBarModel) { tabItemAppearance.normal.iconColor = model.unSelectedColor.uiColor - tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(10)] + tabItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.unSelectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXBold(10)] tabItemAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) tabItemAppearance.selected.iconColor = model.selectedColor.uiColor - tabItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.selectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXRegular(10)] + tabItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: model.selectedColor.uiColor, NSAttributedString.Key.font: MFFonts.mfFontTXBold(10)] tabItemAppearance.selected.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3) } diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index ea5003f4..b88e11ba 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -66,7 +66,7 @@ public extension UINavigationController { /// Convenience function for setting the navigation bar ui func setNavigationBarUI(with model: NavigationItemModelProtocol) { let navigationBar = navigationBar - let font = MFStyler.fontBoldBodySmall(false) + let font = MFStyler.fontRegularBodyLarge(false) let backgroundColor = model.backgroundColor?.uiColor let tint = model.tintColor.uiColor navigationBar.tintColor = tint From 4dc5ee5e6aa631a21b82c1979e89d1f411c70c6b Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 19 May 2022 17:59:42 -0400 Subject: [PATCH 42/49] bold --- .../NavigationController/UINavigationController+Extension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index b88e11ba..e1c7f6a3 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -66,7 +66,7 @@ public extension UINavigationController { /// Convenience function for setting the navigation bar ui func setNavigationBarUI(with model: NavigationItemModelProtocol) { let navigationBar = navigationBar - let font = MFStyler.fontRegularBodyLarge(false) + let font = MFStyler.fontBoldBodyLarge(false) let backgroundColor = model.backgroundColor?.uiColor let tint = model.tintColor.uiColor navigationBar.tintColor = tint From 19ef7a3a26aa337ea9e17f3b695703079cefb6a8 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 27 May 2022 00:18:18 +0530 Subject: [PATCH 43/49] Fix for CXTDT-288387, removing line molecule from Tab --- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 6 ------ MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift | 1 - 2 files changed, 7 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 4e424549..e78ccf19 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -28,7 +28,6 @@ import VDSColorTokens let bottomScrollView = UIScrollView(frame: .zero) let bottomContentView = View() - let bottomLine = Line() let selectionLine = View() var selectionLineLeftConstraint: NSLayoutConstraint? var selectionLineWidthConstraint: NSLayoutConstraint? @@ -68,7 +67,6 @@ import VDSColorTokens open override func setupView() { super.setupView() backgroundColor = VDSColor.backgroundPrimaryLight - addSubview(bottomLine) setupCollectionView() setupSelectionLine() setupConstraints() @@ -116,10 +114,6 @@ import VDSColorTokens selectionLineWidthConstraint = selectionLine.widthAnchor.constraint(equalToConstant: minimumItemWidth) selectionLineWidthConstraint?.isActive = true NSLayoutConstraint.constraintPinSubview(toSuperview: bottomContentView) - - //bottom line - bottomLine.topAnchor.constraint(equalTo: bottomScrollView.bottomAnchor).isActive = true; - NSLayoutConstraint.constraintPinSubview(bottomLine, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true) } //------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index d3b91b11..5fe9c530 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -22,7 +22,6 @@ import UIKit tabs.paddingBeforeFirstTab = false tabs.translatesAutoresizingMaskIntoConstraints = false tabs.delegate = self - tabs.bottomLine.setStyle(.none) contentView.addSubview(tabs) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: tabs, useMargins: true).values)) From eeb6573e727eae09b6a6df3eefef6d5901c021ad Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 27 May 2022 12:13:06 +0530 Subject: [PATCH 44/49] Reverting - line changes in Tab component & Removing line item in Subnavigation controller --- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 7 +++++++ MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift | 1 + MVMCoreUI/Managers/SubNav/SubNavManagerController.swift | 6 +----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index e78ccf19..f6f834ca 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -28,6 +28,7 @@ import VDSColorTokens let bottomScrollView = UIScrollView(frame: .zero) let bottomContentView = View() + let bottomLine = Line() let selectionLine = View() var selectionLineLeftConstraint: NSLayoutConstraint? var selectionLineWidthConstraint: NSLayoutConstraint? @@ -67,6 +68,8 @@ import VDSColorTokens open override func setupView() { super.setupView() backgroundColor = VDSColor.backgroundPrimaryLight + bottomLine.setStyle(.secondary) + addSubview(bottomLine) setupCollectionView() setupSelectionLine() setupConstraints() @@ -114,6 +117,10 @@ import VDSColorTokens selectionLineWidthConstraint = selectionLine.widthAnchor.constraint(equalToConstant: minimumItemWidth) selectionLineWidthConstraint?.isActive = true NSLayoutConstraint.constraintPinSubview(toSuperview: bottomContentView) + + //bottom line + bottomLine.topAnchor.constraint(equalTo: bottomScrollView.bottomAnchor).isActive = true; + NSLayoutConstraint.constraintPinSubview(bottomLine, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true) } //------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index 5fe9c530..0ecb230f 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -22,6 +22,7 @@ import UIKit tabs.paddingBeforeFirstTab = false tabs.translatesAutoresizingMaskIntoConstraints = false tabs.delegate = self + tabs.bottomLine.setStyle(.secondary) contentView.addSubview(tabs) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: tabs, useMargins: true).values)) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index b3a142ba..f5c4023a 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -19,7 +19,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Used to layout the ui. public lazy var stackView: UIStackView = { - let stackView = UIStackView(arrangedSubviews: [tabs, line, subNavigationController.view]) + let stackView = UIStackView(arrangedSubviews: [tabs, subNavigationController.view]) stackView.translatesAutoresizingMaskIntoConstraints = false stackView.isAccessibilityElement = false stackView.axis = .vertical @@ -33,10 +33,6 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, return tabs }() - public lazy var line: Line = { - return Line(model: LineModel(type: .secondary), delegateObjectIVar, nil) - }() - public lazy var subNavigationController: UINavigationController = { let subNavigationController = SubNavManagerNavigationController(rootViewController: viewController) subNavigationController.view.translatesAutoresizingMaskIntoConstraints = false From 4cf9f6128203313d5566633eb0f4a32eeb39b6cd Mon Sep 17 00:00:00 2001 From: Naresh Reddy Maram Reddy Date: Fri, 27 May 2022 12:17:46 +0530 Subject: [PATCH 45/49] Removed preferredControlTintColor & preferredBarTintColor for SFSafariViewControllers to use default. --- MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index fb7fe919..9425547c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -125,8 +125,6 @@ - (void)openURLInSafariWebView:(nonnull NSURL *)url { SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; - safariViewController.preferredBarTintColor = [UIColor whiteColor]; - safariViewController.preferredControlTintColor = [UIColor blackColor]; [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; } From 7fbac6b8dcef2edc7427044534503c4dc8118f41 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 27 May 2022 20:25:47 +0530 Subject: [PATCH 46/49] Changes to set the line style after initialization --- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 3 +++ .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index d4c4d26d..e36c8d23 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -49,16 +49,19 @@ import UIKit public init() { super.init(frame: .zero) model = LineModel(type: .secondary) + setStyle(.secondary) } public override init(frame: CGRect) { super.init(frame: frame) model = LineModel(type: .secondary) + setStyle(.secondary) } public required init?(coder: NSCoder) { super.init(coder: coder) model = LineModel(type: .secondary) + setStyle(.secondary) } public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index f6f834ca..4e424549 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -68,7 +68,6 @@ import VDSColorTokens open override func setupView() { super.setupView() backgroundColor = VDSColor.backgroundPrimaryLight - bottomLine.setStyle(.secondary) addSubview(bottomLine) setupCollectionView() setupSelectionLine() From 3e8f464aac5322b805712e7a779809654c43f25b Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 27 May 2022 21:10:41 +0530 Subject: [PATCH 47/49] Reverting line changes in TabTableCell --- MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index 0ecb230f..d3b91b11 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -22,7 +22,7 @@ import UIKit tabs.paddingBeforeFirstTab = false tabs.translatesAutoresizingMaskIntoConstraints = false tabs.delegate = self - tabs.bottomLine.setStyle(.secondary) + tabs.bottomLine.setStyle(.none) contentView.addSubview(tabs) NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: tabs, useMargins: true).values)) From cb75955bb4501c727537dd23fa41438606236cd8 Mon Sep 17 00:00:00 2001 From: vasavk Date: Mon, 30 May 2022 16:21:09 +0530 Subject: [PATCH 48/49] VDS FormControls --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6bfc7ba0..e51e8336 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -126,6 +126,7 @@ 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB423FF18D2004C5109 /* Arrow.swift */; }; 0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */; }; 0AF60F0926B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF60F0826B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift */; }; + 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */; }; 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */; }; 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258726899B0B00DEBB08 /* ImageButton.swift */; }; 279B1569242BBC2F00921D6C /* ActionModelAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */; }; @@ -714,6 +715,7 @@ 0AE98BB423FF18D2004C5109 /* Arrow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arrow.swift; sourceTree = ""; }; 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrowModel.swift; sourceTree = ""; }; 0AF60F0826B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIUtility+Extension.swift"; sourceTree = ""; }; + 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButtonModel.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift; sourceTree = SOURCE_ROOT; }; 1D6D258726899B0B00DEBB08 /* ImageButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageButton.swift; path = MVMCoreUI/Atomic/Atoms/Buttons/ImageButton.swift; sourceTree = SOURCE_ROOT; }; 279B1568242BBC2F00921D6C /* ActionModelAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelAdapter.swift; sourceTree = ""; }; @@ -1189,6 +1191,7 @@ D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */, AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */, + 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2019,6 +2022,7 @@ D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { isa = PBXGroup; children = ( + 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */, AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */, D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */, 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */, From 4645e0de976a86eb9d610331d4419fb76a306572 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 9 Jun 2022 18:17:29 -0400 Subject: [PATCH 49/49] default the title offset for all inits --- .../Molecules/NavigationBar/NavigationItemModel.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 523f6ea1..64b61480 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -61,7 +61,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open var additionalLeftButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var additionalRightButtons: [(NavigationButtonModelProtocol & MoleculeModelProtocol)]? open var titleView: MoleculeModelProtocol? - open var titleOffset: UIOffset? + open var titleOffset: UIOffset? = UIOffset(horizontal: -CGFloat.greatestFiniteMagnitude, vertical: 0) //-------------------------------------------------- // MARK: - Initializer @@ -114,7 +114,9 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc additionalRightButtons = try typeContainer.decodeModelsIfPresent(codingKey: .additionalRightButtons) titleView = try typeContainer.decodeModelIfPresent(codingKey: .titleView) style = try typeContainer.decodeIfPresent(NavigationItemStyle.self, forKey: .style) - titleOffset = try typeContainer.decodeIfPresent(UIOffset.self, forKey: .titleOffset) ?? UIOffset(horizontal: -CGFloat.greatestFiniteMagnitude, vertical: 0) + if let titleOffset = try typeContainer.decodeIfPresent(UIOffset.self, forKey: .titleOffset) { + self.titleOffset = titleOffset + } line?.inverted = style == .dark }