commit 9101f27a720efa9d9f4a51e9851316962bcc7a91
parent d729e1b8b2e5c99dadca4cca930cea7a84f53bc0
Author: Marc Stibane <marc@taler.net>
Date: Mon, 12 Jun 2023 19:09:11 +0200
Cleaned up buttons
Diffstat:
5 files changed, 17 insertions(+), 76 deletions(-)
diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift
@@ -93,59 +93,6 @@ struct ReloadButton : View {
}
}
-struct BigBlueButton: View {
- let title: String
- var font: Font?
- let disabled: Bool
- let action: () -> Void
- var body: some View {
- Button(action: action) {
- let colors: [Color] = disabled ? [Color.gray, Color.blue]
- : [Color.red, Color.blue]
- let back = LinearGradient(gradient: Gradient(colors: colors),
- startPoint: .leading, endPoint: .trailing)
- Text(title)
- .frame(minWidth: 50, maxWidth: 500)
- .padding()
- .foregroundColor(.white)
- .background(disabled ? .gray : .blue) // back
- .cornerRadius(20)
- .font(font ?? .title)
- }
- .disabled(disabled)
- }
-}
-struct BorderedButton: View {
- let title: String
- var font: Font?
- let action: () -> Void
-
- var body: some View {
- Button(action: action) {
- Text(title)
- .frame(minWidth: 50, maxWidth: 500)
- .padding()
- .font(font ?? .title)
- }
- .buttonStyle(.bordered)
- }
-}
-struct ProminentButton: View {
- let title: String
- var font: Font?
- let action: () -> Void
-
- var body: some View {
- Button(action: action) {
- Text(title)
- .frame(minWidth: 50, maxWidth: 500)
- .padding()
- .font(font ?? .title)
- }
- .buttonStyle(.borderedProminent)
- }
-}
-
struct TalerButtonStyle: ButtonStyle {
@Environment(\.isEnabled) private var isEnabled: Bool
func disabled() -> Bool { !isEnabled }
@@ -233,19 +180,6 @@ struct TalerButtonStyle: ButtonStyle {
}
-
-struct GrowingButton: ButtonStyle {
- func makeBody(configuration: Configuration) -> some View {
- configuration.label
- .padding()
- .background(.blue)
- .foregroundColor(.white)
- .clipShape(Capsule())
- .scaleEffect(configuration.isPressed ? 1.2 : 1)
- .animation(.easeOut(duration: 0.2), value: configuration.isPressed)
- }
-}
-
struct Buttons_Previews: PreviewProvider {
static var previews: some View {
VStack {
@@ -256,15 +190,18 @@ struct Buttons_Previews: PreviewProvider {
PlusButton() {}
.padding()
HStack {
- ReloadButton(disabled: false) {}
+ ReloadButton(disabled: false) {
+ AudioServicesPlaySystemSound(1000)
+ }
.padding()
ReloadButton(disabled: true) {}
.padding()
}
- BigBlueButton(title: "DisabledButton", disabled: true) { AudioServicesPlaySystemSound(1015) }
- .padding()
- BigBlueButton(title: "BigBlueButton", disabled: false) { AudioServicesPlaySystemSound(1000) }
- .padding()
+ Button(String(localized: "Accept"), action: {
+ AudioServicesPlaySystemSound(1015)
+ })
+ .buttonStyle(TalerButtonStyle(type: .prominent))
+ .padding(.horizontal)
}
}
}
@@ -285,7 +222,7 @@ struct ContentView: View {
animate = false
// Because .opacity is animated, we need to switch it
// back so the button shows.
- DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
animate = true
}
}
diff --git a/TalerWallet1/Views/Payment/PaymentAcceptView.swift b/TalerWallet1/Views/Payment/PaymentAcceptView.swift
@@ -58,7 +58,8 @@ struct PaymentAcceptView: View {
baseURL: detailsForAmount.contractTerms.exchanges.first?.url)
// TODO: payment: popup with all possible exchanges, check fees
.safeAreaInset(edge: .bottom) {
- ProminentButton(title: "Accept", action: acceptAction)
+ Button(String(localized: "Accept"), action: acceptAction)
+ .buttonStyle(TalerButtonStyle(type: .prominent))
.padding(.horizontal)
}
}
diff --git a/TalerWallet1/Views/Transactions/ThreeAmounts.swift b/TalerWallet1/Views/Transactions/ThreeAmounts.swift
@@ -100,7 +100,8 @@ struct ThreeAmounts_Previews: PreviewProvider {
List {
ThreeAmounts(common: common, topTitle: "Withdrawal", baseURL: DEMOEXCHANGE, large: 1==1)
.safeAreaInset(edge: .bottom) {
- ProminentButton(title: "Accept", action: {})
+ Button(String(localized: "Accept"), action: {})
+ .buttonStyle(TalerButtonStyle(type: .prominent))
.padding(.horizontal)
}
}
diff --git a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptView.swift b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptView.swift
@@ -47,7 +47,8 @@ struct WithdrawAcceptView: View {
large: false, pending: false, incoming: true,
baseURL: baseURL)
.safeAreaInset(edge: .bottom) {
- ProminentButton(title: String(localized: "Accept"), action: acceptAction)
+ Button(String(localized: "Accept"), action: acceptAction)
+ .buttonStyle(TalerButtonStyle(type: .prominent))
.padding(.horizontal)
}
case .waitingForWithdrAck, .receivedWithdrAck:
diff --git a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawTOSView.swift b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawTOSView.swift
@@ -77,7 +77,8 @@ extension WithdrawTOSView {
List (components, id: \.self) { term in
Text(term)
}.safeAreaInset(edge: .bottom) {
- ProminentButton(title: String(localized: "Accept"), action: acceptAction)
+ Button(String(localized: "Accept"), action: acceptAction)
+ .buttonStyle(TalerButtonStyle(type: .prominent))
.padding(.horizontal)
}
.listStyle(myListStyle.style)