diff --git a/CHANGELOG.md b/CHANGELOG.md index fd8141953..7ca362167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Change Log All notable changes to this project will be documented in this file. +## [Unreleased] + +## Added +- Implement disabling of the purchase button + - Added in Pull Request [#44](https://github.com/space-code/flare/pull/44). + #### 3.x Releases - `3.0.0` Release Candidates - [`3.0.0-rc.1`](#300-rc1) | [`3.0.0-rc.2`](#300-rc2) diff --git a/Mintfile b/Mintfile index e2cdefabc..3c6da00fa 100644 --- a/Mintfile +++ b/Mintfile @@ -1,2 +1,2 @@ -nicklockwood/SwiftFormat@0.52.7 -realm/SwiftLint@0.53.0 \ No newline at end of file +nicklockwood/SwiftFormat@0.54.0 +realm/SwiftLint@0.55.1 \ No newline at end of file diff --git a/Sources/FlareUI/Classes/Presentation/Components/Styles/PrimaryButtonStyle.swift b/Sources/FlareUI/Classes/Presentation/Components/Styles/PrimaryButtonStyle.swift index 2001bc60e..0ef43c691 100644 --- a/Sources/FlareUI/Classes/Presentation/Components/Styles/PrimaryButtonStyle.swift +++ b/Sources/FlareUI/Classes/Presentation/Components/Styles/PrimaryButtonStyle.swift @@ -14,8 +14,16 @@ import SwiftUI struct PrimaryButtonStyle: ButtonStyle { // MARK: Properties + private let disabled: Bool + @Environment(\.tintColor) private var tintColor + // MARK: Initialization + + init(disabled: Bool) { + self.disabled = disabled + } + // MARK: ButtonStyle func makeBody(configuration: Configuration) -> some View { @@ -24,7 +32,7 @@ struct PrimaryButtonStyle: ButtonStyle { .frame(height: 50.0) .frame(maxWidth: .infinity) .padding(.horizontal) - .background(tintColor) + .background(disabled ? Palette.systemGray : tintColor) .clipShape(RoundedRectangle(cornerSize: .init(width: 14, height: 14))) .opacity(configuration.isPressed ? 0.5 : 1.0) } @@ -38,6 +46,6 @@ struct PrimaryButtonStyle: ButtonStyle { @available(visionOS, unavailable) extension ButtonStyle where Self == PrimaryButtonStyle { static var primary: PrimaryButtonStyle { - PrimaryButtonStyle() + PrimaryButtonStyle(disabled: true) } } diff --git a/Sources/FlareUI/Classes/Presentation/Components/Styles/Subscription/SubscriptionStoreControlStyle/BorderedSubscriptionStoreControlStyle/BorderedSubscriptionStoreControlStyleView.swift b/Sources/FlareUI/Classes/Presentation/Components/Styles/Subscription/SubscriptionStoreControlStyle/BorderedSubscriptionStoreControlStyle/BorderedSubscriptionStoreControlStyleView.swift index 4a6095373..36e10bce2 100644 --- a/Sources/FlareUI/Classes/Presentation/Components/Styles/Subscription/SubscriptionStoreControlStyle/BorderedSubscriptionStoreControlStyle/BorderedSubscriptionStoreControlStyleView.swift +++ b/Sources/FlareUI/Classes/Presentation/Components/Styles/Subscription/SubscriptionStoreControlStyle/BorderedSubscriptionStoreControlStyle/BorderedSubscriptionStoreControlStyleView.swift @@ -34,7 +34,8 @@ struct BorderedSubscriptionStoreControlStyleView: View { }, label: { labelView(configuration) }) - .buttonStyle(PrimaryButtonStyle()) + .disabled(!configuration.isActive) + .buttonStyle(PrimaryButtonStyle(disabled: !configuration.isActive)) } // MARK: Private @@ -88,7 +89,7 @@ struct BorderedSubscriptionStoreControlStyleView: View { description: .init(Text("Name")), price: .init(Text("Name")), isSelected: true, - isActive: true, + isActive: false, action: {} ) ) diff --git a/Sources/FlareUI/Classes/Presentation/Components/Styles/Subscription/SubscriptionStoreControlStyle/CardButtonSubscriptionStoreControlStyle/CardButtonSubscriptionStoreControlView.swift b/Sources/FlareUI/Classes/Presentation/Components/Styles/Subscription/SubscriptionStoreControlStyle/CardButtonSubscriptionStoreControlStyle/CardButtonSubscriptionStoreControlView.swift index b3fe658de..c1fecc12c 100644 --- a/Sources/FlareUI/Classes/Presentation/Components/Styles/Subscription/SubscriptionStoreControlStyle/CardButtonSubscriptionStoreControlStyle/CardButtonSubscriptionStoreControlView.swift +++ b/Sources/FlareUI/Classes/Presentation/Components/Styles/Subscription/SubscriptionStoreControlStyle/CardButtonSubscriptionStoreControlStyle/CardButtonSubscriptionStoreControlView.swift @@ -15,7 +15,6 @@ import SwiftUI struct CardButtonSubscriptionStoreControlView: View { // MARK: Properties -// @Environment(\.isFocused) private var isFocused: Bool @Environment(\.tintColor) private var tintColor private let configuration: SubscriptionStoreControlStyleConfiguration @@ -31,7 +30,7 @@ struct CardButtonSubscriptionStoreControlView: View { var body: some View { ZStack { Rectangle() - .fill(tintColor) // isFocused ? tintColor.opacity(0.85) : tintColor) + .fill(tintColor) VStack(alignment: .leading) { VStack(alignment: .leading) {