bringing borderwidth in.

This commit is contained in:
Kevin G Christiano 2020-04-30 15:48:30 -04:00
parent 2f6fa19233
commit cbcb1c37c0
2 changed files with 40 additions and 21 deletions

View File

@ -57,7 +57,8 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
enabledFillColor_inverted: Color(uiColor: .mvmWhite),
enabledTextColor_inverted: Color(uiColor: .mvmBlack),
disabledFillColor_inverted: Color(uiColor: .mvmCoolGray6),
disabledTextColor_inverted: Color(uiColor: .mvmBlack))
disabledTextColor_inverted: Color(uiColor: .mvmBlack),
borderWidth: 0)
private var secondaryFacade = Facade(enabledFillColor: Color(uiColor: .mvmWhite),
enabledTextColor: Color(uiColor: .mvmBlack),
@ -70,7 +71,8 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
enabledBorderColor_inverted: Color(uiColor: .mvmWhite),
disabledFillColor_inverted: Color(uiColor: .mvmWhite),
disabledTextColor_inverted: Color(uiColor: .mvmCoolGray6),
disabledBorderColor_inverted: Color(uiColor: .mvmCoolGray6))
disabledBorderColor_inverted: Color(uiColor: .mvmCoolGray6),
borderWidth: 1)
//--------------------------------------------------
// MARK: - Methods

View File

@ -31,6 +31,28 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
case standard = 42
}
//--------------------------------------------------
// MARK: - Computed Properties
//--------------------------------------------------
public var enabledTitleColor: UIColor? {
get { return titleColor(for: .normal) }
set { setTitleColor(newValue, for: .normal) }
}
public var disabledTitleColor: UIColor? {
get { return titleColor(for: .disabled) }
set { setTitleColor(newValue, for: .disabled) }
}
public var borderColor: UIColor? {
get {
guard let currentColor = layer.borderColor else { return nil }
return UIColor(cgColor: currentColor)
}
set { layer.borderColor = newValue?.cgColor}
}
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
@ -39,9 +61,9 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
public func stylePrimary() {
buttonModel?.style = .primary
setTitleColor(buttonModel?.facade?.enabled.text ?? .mvmWhite, for: .normal)
setTitleColor(buttonModel?.facade?.disabled.text ?? .mvmWhite, for: .disabled)
layer.borderWidth = 0
enabledTitleColor = buttonModel?.facade?.enabled.text ?? .mvmWhite
disabledTitleColor = buttonModel?.facade?.disabled.text ?? .mvmWhite
layer.borderWidth = buttonModel?.facade?.getBorderWidth() ?? 0
backgroundColor = isEnabled ? buttonModel?.facade?.enabled.fill ?? .mvmBlack : buttonModel?.facade?.enabled.fill ?? .mvmCoolGray6
}
@ -49,16 +71,11 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
public func styleSecondary() {
buttonModel?.style = .secondary
setTitleColor(buttonModel?.facade?.enabled.text ?? .mvmBlack, for: .normal)
setTitleColor(buttonModel?.facade?.disabled.text ?? .mvmCoolGray6, for: .disabled)
enabledTitleColor = buttonModel?.facade?.enabled.text ?? .mvmBlack
disabledTitleColor = buttonModel?.facade?.disabled.text ?? .mvmCoolGray6
backgroundColor = .clear
layer.borderWidth = 1
if isEnabled {
layer.borderColor = buttonModel?.facade?.enabled.border?.cgColor ?? UIColor.mvmBlack.cgColor
} else {
layer.borderColor = buttonModel?.facade?.enabled.border?.cgColor ?? UIColor.mvmCoolGray6.cgColor
}
layer.borderWidth = buttonModel?.facade?.getBorderWidth() ?? 1
borderColor = isEnabled ? buttonModel?.facade?.enabled.border ?? .mvmBlack : buttonModel?.facade?.enabled.border ?? .mvmCoolGray6
}
/// Styles the button based on the model style
@ -73,11 +90,11 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
}
if let titleColor = buttonModel?.facade?.enabled.text {
setTitleColor(titleColor, for: .normal)
enabledTitleColor = titleColor
}
if let disabledTitleColor = buttonModel?.facade?.disabled.text {
setTitleColor(disabledTitleColor, for: .disabled)
self.disabledTitleColor = disabledTitleColor
}
if isEnabled {
@ -86,17 +103,17 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
}
if let borderColor = buttonModel?.facade?.enabled.border {
layer.borderWidth = 1
layer.borderColor = borderColor.cgColor
layer.borderWidth = buttonModel?.facade?.getBorderWidth() ?? 1
self.borderColor = borderColor
}
} else {
if let fillColor = buttonModel?.facade?.disabled.fill {
backgroundColor = fillColor
}
if let borderColor = buttonModel?.facade?.disabledBorderColor {
layer.borderWidth = 1
layer.borderColor = borderColor.cgColor
if let borderColor = buttonModel?.facade?.disabled.border {
layer.borderWidth = buttonModel?.facade?.getBorderWidth() ?? 1
self.borderColor = borderColor
}
}
}