Skip to content

Commit

Permalink
LATCH-1000 Use constants for opacity values
Browse files Browse the repository at this point in the history
  • Loading branch information
jaranaz committed Oct 13, 2023
1 parent 1c53613 commit 700bd4c
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions Sources/MisticaSwiftUI/Components/Button/MisticaButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ public struct MisticaButtonStyle: ButtonStyle {

// MARK: Styles

private var _opacity = 0.5
private var _opacityWithBackground = 0.1

public extension ButtonStyle where Self == MisticaButtonStyle {
static var opacity: CGFloat {
get { _opacity }
set { _opacity = newValue }
}

static var opacityWithBackground: CGFloat {
get { _opacityWithBackground }
set { _opacityWithBackground = newValue }
}

static func misticaPrimary(
small: Bool = false,
bleedingAlignment: ButtonBleedingAlignment = .none
Expand All @@ -43,8 +56,8 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
),
.disabled: MisticaButton.StateStyle(
textColor: .textButtonPrimary,
backgroundColor: .buttonPrimaryBackground.opacity(0.5),
borderColor: .buttonPrimaryBackground.opacity(0.1)
backgroundColor: .buttonPrimaryBackground.opacity(opacity),
borderColor: .buttonPrimaryBackground.opacity(opacityWithBackground)
),
.loading: MisticaButton.StateStyle(
textColor: .textButtonPrimary,
Expand Down Expand Up @@ -78,8 +91,8 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
),
.disabled: MisticaButton.StateStyle(
textColor: .textButtonPrimaryInverse,
backgroundColor: .buttonPrimaryBackgroundInverse.opacity(0.5),
borderColor: .buttonPrimaryBackgroundInverse.opacity(0.1)
backgroundColor: .buttonPrimaryBackgroundInverse.opacity(opacity),
borderColor: .buttonPrimaryBackgroundInverse.opacity(opacityWithBackground)
),
.loading: MisticaButton.StateStyle(
textColor: .textButtonPrimaryInverse,
Expand Down Expand Up @@ -112,9 +125,9 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
borderColor: .buttonSecondaryBackgroundSelected
),
.disabled: MisticaButton.StateStyle(
textColor: .textButtonSecondary.opacity(0.5),
textColor: .textButtonSecondary.opacity(opacity),
backgroundColor: .clear,
borderColor: .buttonSecondaryBorder.opacity(0.5)
borderColor: .buttonSecondaryBorder.opacity(opacity)
),
.loading: MisticaButton.StateStyle(
textColor: .textButtonSecondary,
Expand Down Expand Up @@ -147,9 +160,9 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
borderColor: .buttonSecondaryBorderInverseSelected
),
.disabled: MisticaButton.StateStyle(
textColor: .textButtonSecondaryInverse.opacity(0.5),
textColor: .textButtonSecondaryInverse.opacity(opacity),
backgroundColor: .clear,
borderColor: .buttonSecondaryBorderInverse.opacity(0.5)
borderColor: .buttonSecondaryBorderInverse.opacity(opacity)
),
.loading: MisticaButton.StateStyle(
textColor: .textButtonSecondaryInverse,
Expand Down Expand Up @@ -183,8 +196,8 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
),
.disabled: MisticaButton.StateStyle(
textColor: .textButtonPrimary,
backgroundColor: .buttonDangerBackground.opacity(0.5),
borderColor: .buttonDangerBackground.opacity(0.1)
backgroundColor: .buttonDangerBackground.opacity(opacity),
borderColor: .buttonDangerBackground.opacity(opacityWithBackground)
),
.loading: MisticaButton.StateStyle(
textColor: .textButtonPrimary,
Expand Down Expand Up @@ -219,7 +232,7 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
borderColor: .clear
),
.disabled: MisticaButton.StateStyle(
textColor: .textLink.opacity(0.5),
textColor: .textLink.opacity(opacity),
backgroundColor: .clear,
borderColor: .clear
),
Expand Down Expand Up @@ -256,7 +269,7 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
borderColor: .clear
),
.disabled: MisticaButton.StateStyle(
textColor: .textButtonSecondaryInverse.opacity(0.5),
textColor: .textButtonSecondaryInverse.opacity(opacity),
backgroundColor: .clear,
borderColor: .clear
),
Expand Down Expand Up @@ -292,7 +305,7 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
borderColor: .clear
),
.disabled: MisticaButton.StateStyle(
textColor: .textLinkSnackbar.opacity(0.5),
textColor: .textLinkSnackbar.opacity(opacity),
backgroundColor: .clear,
borderColor: .clear
),
Expand Down

0 comments on commit 700bd4c

Please sign in to comment.