Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LATCH-1000: fix Button disabled state #310

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
borderColor: .buttonPrimaryBackgroundInverse
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,
textColor: .textButtonSecondary.opacity(opacity),
backgroundColor: .clear,
borderColor: .buttonSecondaryBorder
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,
textColor: .textButtonSecondaryInverse.opacity(opacity),
backgroundColor: .clear,
borderColor: .buttonSecondaryBorderInverse
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,
borderColor: .buttonDangerBackground
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,
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,
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,
textColor: .textLinkSnackbar.opacity(opacity),
backgroundColor: .clear,
borderColor: .clear
),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.