VDS button component changes
This commit is contained in:
parent
27289f1ac8
commit
064533950e
@ -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 {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ open class Styler {
|
||||
case .small:
|
||||
return 32
|
||||
case .tiny:
|
||||
return 26
|
||||
return 20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user