diff --git a/ElementX/Sources/Letro/Extensions/CompoundExtensions.swift b/ElementX/Sources/Letro/Extensions/CompoundExtensions.swift index e70db352a..45c788768 100644 --- a/ElementX/Sources/Letro/Extensions/CompoundExtensions.swift +++ b/ElementX/Sources/Letro/Extensions/CompoundExtensions.swift @@ -20,26 +20,42 @@ enum CompoundExtensions { extension CompoundColors { @MainActor func applyLetroOverrides() { + override(\.gradientActionStop1, with: .letroGradient1) + override(\.gradientActionStop2, with: .letroGradient2) + override(\.gradientActionStop3, with: .letroGradient3) + override(\.gradientActionStop4, with: .letroGradient5) override(\.gradientSubtleStop1, with: .letroGradient1.opacity(0.33)) override(\.gradientSubtleStop2, with: .letroGradient2.opacity(0.22)) override(\.gradientSubtleStop3, with: .letroGradient3.opacity(0.11)) override(\.gradientSubtleStop4, with: .letroGradient4.opacity(0.07)) override(\.gradientSubtleStop5, with: .letroGradient5.opacity(0.04)) + override(\.bgActionPrimaryRest, with: .letroPrimary) + override(\.bgActionPrimaryPressed, with: .letroGradient1) + override(\.bgActionPrimaryDisabled, with: .letroGray.opacity(0.4)) override(\.iconAccentTertiary, with: .letroPrimary) override(\.bgAccentRest, with: .letroPrimary) + override(\.textActionPrimary, with: .letroPrimary) } } extension CompoundUIColors { @MainActor func applyLetroOverrides() { + override(\.gradientActionStop1, with: .letroGradient1) + override(\.gradientActionStop2, with: .letroGradient2) + override(\.gradientActionStop3, with: .letroGradient3) + override(\.gradientActionStop4, with: .letroGradient5) override(\.gradientSubtleStop1, with: .letroGradient1.withAlphaComponent(0.33)) override(\.gradientSubtleStop2, with: .letroGradient2.withAlphaComponent(0.22)) override(\.gradientSubtleStop3, with: .letroGradient3.withAlphaComponent(0.11)) override(\.gradientSubtleStop4, with: .letroGradient4.withAlphaComponent(0.07)) override(\.gradientSubtleStop5, with: .letroGradient5.withAlphaComponent(0.04)) + override(\.bgActionPrimaryRest, with: .letroPrimary) + override(\.bgActionPrimaryPressed, with: .letroGradient1) + override(\.bgActionPrimaryDisabled, with: .letroGray.withAlphaComponent(0.4)) override(\.iconAccentTertiary, with: .letroPrimary) override(\.bgAccentRest, with: .letroPrimary) + override(\.textActionPrimary, with: .letroPrimary) } } diff --git a/compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift b/compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift index 680cb3645..d3dd229c5 100644 --- a/compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift +++ b/compound-ios/Sources/Compound/BaseStyles/CompoundButtonStyle.swift @@ -138,7 +138,7 @@ public struct CompoundButtonStyle: ButtonStyle { Capsule().strokeBorder(strokeColor(configuration: configuration)) } case .primary: - Capsule().fill(fillColor(configuration: configuration)) + makePrimaryBackground(configuration: configuration) case .secondary: Capsule().strokeBorder(strokeColor(configuration: configuration)) case .tertiary: @@ -148,6 +148,20 @@ public struct CompoundButtonStyle: ButtonStyle { } } + // Letro: custom action buttons + @ViewBuilder + private func makePrimaryBackground(configuration: Self.Configuration) -> some View { + if !isEnabled || configuration.role == .destructive { + Capsule().fill(fillColor(configuration: configuration)) + } else { + Capsule() + .fill(LinearGradient(gradient: .compound.action, + startPoint: .bottomLeading, + endPoint: .topTrailing)) + .opacity(configuration.isPressed ? pressedOpacity : 1) + } + } + private var contentShape: AnyShape { switch kind { case .super, .primary, .secondary, .tertiary: