Skip to content

Commit

Permalink
Implement Disabling of the Purchase Button (#44)
Browse files Browse the repository at this point in the history
* Implement disabling of the purchase button

Fix

* Update `CHANGELOG.md`
  • Loading branch information
ns-vasilev authored Jun 15, 2024
1 parent b86beca commit 217de3b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
4 changes: 2 additions & 2 deletions Mintfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nicklockwood/SwiftFormat@0.52.7
realm/SwiftLint@0.53.0
nicklockwood/SwiftFormat@0.54.0
realm/SwiftLint@0.55.1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand All @@ -38,6 +46,6 @@ struct PrimaryButtonStyle: ButtonStyle {
@available(visionOS, unavailable)
extension ButtonStyle where Self == PrimaryButtonStyle {
static var primary: PrimaryButtonStyle {
PrimaryButtonStyle()
PrimaryButtonStyle(disabled: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ struct BorderedSubscriptionStoreControlStyleView: View {
}, label: {
labelView(configuration)
})
.buttonStyle(PrimaryButtonStyle())
.disabled(!configuration.isActive)
.buttonStyle(PrimaryButtonStyle(disabled: !configuration.isActive))
}

// MARK: Private
Expand Down Expand Up @@ -88,7 +89,7 @@ struct BorderedSubscriptionStoreControlStyleView: View {
description: .init(Text("Name")),
price: .init(Text("Name")),
isSelected: true,
isActive: true,
isActive: false,
action: {}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 217de3b

Please sign in to comment.