From 064533950e3646a2e2ddd64324a8624be3bb57f0 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 21 Apr 2022 19:36:39 +0530 Subject: [PATCH] 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 } } }