more changes for inverted
This commit is contained in:
parent
9e9984a8c5
commit
e4911a8cce
@ -35,7 +35,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
|
|||||||
}
|
}
|
||||||
public var size: Styler.Button.Size? = .standard
|
public var size: Styler.Button.Size? = .standard
|
||||||
public var groupName: String = ""
|
public var groupName: String = ""
|
||||||
public var isInverted: Bool = false
|
public var inverted: Bool = false
|
||||||
|
|
||||||
public lazy var enabledColors: FacadeElements = (fill: enabled_fillColor(),
|
public lazy var enabledColors: FacadeElements = (fill: enabled_fillColor(),
|
||||||
text: enabled_textColor(),
|
text: enabled_textColor(),
|
||||||
@ -97,29 +97,29 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public func enabled_fillColor() -> UIColor? {
|
public func enabled_fillColor() -> UIColor? {
|
||||||
return (isInverted ? enabledFillColor_inverted : enabledFillColor)?.uiColor
|
return (inverted ? enabledFillColor_inverted : enabledFillColor)?.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public func enabled_textColor() -> UIColor? {
|
public func enabled_textColor() -> UIColor? {
|
||||||
return (isInverted ? enabledTextColor_inverted : enabledTextColor)?.uiColor
|
return (inverted ? enabledTextColor_inverted : enabledTextColor)?.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public func enabled_borderColor() -> UIColor? {
|
public func enabled_borderColor() -> UIColor? {
|
||||||
return (isInverted ? enabledBorderColor_inverted : enabledBorderColor)?.uiColor
|
return (inverted ? enabledBorderColor_inverted : enabledBorderColor)?.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public func disabled_fillColor() -> UIColor? {
|
public func disabled_fillColor() -> UIColor? {
|
||||||
return (isInverted ? disabledFillColor_inverted : disabledFillColor)?.uiColor
|
return (inverted ? disabledFillColor_inverted : disabledFillColor)?.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public func disabled_textColor() -> UIColor? {
|
public func disabled_textColor() -> UIColor? {
|
||||||
return (isInverted ? disabledTextColor_inverted : disabledTextColor)?.uiColor
|
return (inverted ? disabledTextColor_inverted : disabledTextColor)?.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
public func disabled_borderColor() -> UIColor? {
|
public func disabled_borderColor() -> UIColor? {
|
||||||
return (isInverted ? disabledBorderColor_inverted : disabledBorderColor)?.uiColor
|
return (inverted ? disabledBorderColor_inverted : disabledBorderColor)?.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Defines the default appearance for the primary style.
|
/// Defines the default appearance for the primary style.
|
||||||
@ -134,6 +134,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
|
|||||||
disabledFillColor = Color(uiColor: .mvmCoolGray6)
|
disabledFillColor = Color(uiColor: .mvmCoolGray6)
|
||||||
disabledTextColor = Color(uiColor: .mvmWhite)
|
disabledTextColor = Color(uiColor: .mvmWhite)
|
||||||
}
|
}
|
||||||
|
|
||||||
enabledFillColor_inverted = Color(uiColor: .mvmWhite)
|
enabledFillColor_inverted = Color(uiColor: .mvmWhite)
|
||||||
enabledTextColor_inverted = Color(uiColor: .mvmBlack)
|
enabledTextColor_inverted = Color(uiColor: .mvmBlack)
|
||||||
disabledFillColor_inverted = Color(uiColor: .mvmCoolGray6)
|
disabledFillColor_inverted = Color(uiColor: .mvmCoolGray6)
|
||||||
@ -152,6 +153,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
|
|||||||
disabledTextColor = Color(uiColor: .mvmCoolGray6)
|
disabledTextColor = Color(uiColor: .mvmCoolGray6)
|
||||||
disabledBorderColor = Color(uiColor: .mvmCoolGray6)
|
disabledBorderColor = Color(uiColor: .mvmCoolGray6)
|
||||||
}
|
}
|
||||||
|
|
||||||
enabledTextColor_inverted = Color(uiColor: .mvmWhite)
|
enabledTextColor_inverted = Color(uiColor: .mvmWhite)
|
||||||
enabledBorderColor_inverted = Color(uiColor: .mvmWhite)
|
enabledBorderColor_inverted = Color(uiColor: .mvmWhite)
|
||||||
disabledTextColor_inverted = Color(uiColor: .mvmCoolGray6)
|
disabledTextColor_inverted = Color(uiColor: .mvmCoolGray6)
|
||||||
@ -203,20 +205,37 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
|
|||||||
self.enabled = enabled
|
self.enabled = enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
if let isInverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) {
|
if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) {
|
||||||
self.isInverted = isInverted
|
self.inverted = inverted
|
||||||
}
|
}
|
||||||
|
|
||||||
if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) {
|
if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) {
|
||||||
self.groupName = groupName
|
self.groupName = groupName
|
||||||
}
|
}
|
||||||
|
|
||||||
enabledFillColor = try typeContainer.decodeIfPresent(Color.self, forKey: .fillColor)
|
if let enabledFillColor = try typeContainer.decodeIfPresent(Color.self, forKey: .fillColor) {
|
||||||
enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor)
|
self.enabledFillColor = enabledFillColor
|
||||||
enabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor)
|
}
|
||||||
disabledFillColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledFillColor)
|
|
||||||
disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor)
|
if let enabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) {
|
||||||
disabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledBorderColor)
|
self.enabledTextColor = enabledTextColor
|
||||||
|
}
|
||||||
|
|
||||||
|
if let enabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) {
|
||||||
|
self.enabledBorderColor = enabledBorderColor
|
||||||
|
}
|
||||||
|
|
||||||
|
if let disabledFillColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledFillColor) {
|
||||||
|
self.disabledFillColor = disabledFillColor
|
||||||
|
}
|
||||||
|
|
||||||
|
if let disabledTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledTextColor) {
|
||||||
|
self.disabledTextColor = disabledTextColor
|
||||||
|
}
|
||||||
|
|
||||||
|
if let disabledBorderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledBorderColor) {
|
||||||
|
self.disabledBorderColor = disabledBorderColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -224,7 +243,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
|
|||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encode(title, forKey: .title)
|
try container.encode(title, forKey: .title)
|
||||||
try container.encode(enabled, forKey: .enabled)
|
try container.encode(enabled, forKey: .enabled)
|
||||||
try container.encode(isInverted, forKey: .inverted)
|
try container.encode(inverted, forKey: .inverted)
|
||||||
try container.encodeModel(action, forKey: .action)
|
try container.encodeModel(action, forKey: .action)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(enabledFillColor, forKey: .fillColor)
|
try container.encodeIfPresent(enabledFillColor, forKey: .fillColor)
|
||||||
|
|||||||
@ -45,7 +45,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
guard let currentColor = layer.borderColor else { return nil }
|
guard let currentColor = layer.borderColor else { return nil }
|
||||||
return UIColor(cgColor: currentColor)
|
return UIColor(cgColor: currentColor)
|
||||||
}
|
}
|
||||||
set { layer.borderColor = newValue?.cgColor}
|
set { layer.borderColor = newValue?.cgColor }
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -55,7 +55,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
/// The primary styling for a button. Should be used for main buttons
|
/// The primary styling for a button. Should be used for main buttons
|
||||||
public func stylePrimary() {
|
public func stylePrimary() {
|
||||||
|
|
||||||
buttonModel?.style = .primary
|
|
||||||
enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmWhite
|
enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmWhite
|
||||||
disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmWhite
|
disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmWhite
|
||||||
layer.borderWidth = 0
|
layer.borderWidth = 0
|
||||||
@ -65,7 +64,6 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
/// The secondary styling for a button. Should be used for secondary buttons
|
/// The secondary styling for a button. Should be used for secondary buttons
|
||||||
public func styleSecondary() {
|
public func styleSecondary() {
|
||||||
|
|
||||||
buttonModel?.style = .secondary
|
|
||||||
enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmBlack
|
enabledTitleColor = buttonModel?.enabledColors.text ?? .mvmBlack
|
||||||
disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmCoolGray6
|
disabledTitleColor = buttonModel?.disabledColors.text ?? .mvmCoolGray6
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
@ -114,7 +112,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func getInnerPadding() -> CGFloat {
|
private func getInnerPadding() -> CGFloat {
|
||||||
return getHeight() / 2
|
return getHeight() / 2.0
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getHeight() -> CGFloat {
|
private func getHeight() -> CGFloat {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user