[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 10/25: Use System Alert for iOS16+
From: |
gnunet |
Subject: |
[taler-taler-ios] 10/25: Use System Alert for iOS16+ |
Date: |
Mon, 06 Nov 2023 20:40:17 +0100 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit b6214e9ec70019e6db30d825a4e51b0898f256b1
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sat Nov 4 08:00:59 2023 +0100
Use System Alert for iOS16+
---
TalerWallet1/Views/Exchange/ExchangeListView.swift | 106 ++++++++++++---------
TalerWallet1/Views/HelperViews/Buttons.swift | 3 +-
2 files changed, 65 insertions(+), 44 deletions(-)
diff --git a/TalerWallet1/Views/Exchange/ExchangeListView.swift
b/TalerWallet1/Views/Exchange/ExchangeListView.swift
index 47c74c8..a809168 100644
--- a/TalerWallet1/Views/Exchange/ExchangeListView.swift
+++ b/TalerWallet1/Views/Exchange/ExchangeListView.swift
@@ -16,46 +16,81 @@ struct ExchangeListView: View {
#else // GNU Taler
var hamburgerAction: () -> Void
#endif
-
@EnvironmentObject private var model: WalletModel
+ @State var showAlert: Bool = false
+ @State var newExchange: String = TESTEXCHANGE
- @State private var exchanges: [Exchange] = []
-
- // source of truth for the value the user enters in currencyField for
exchange withdrawals
- @State private var centsToTransfer: UInt64 = 0 // TODO: different
values for different currencies?
-
- func reloadExchanges() async -> Void {
- exchanges = await model.listExchangesM()
- }
-
- func addExchange(_ exUrl: String) -> Void {
+ func addExchange(_ exchange: String) -> Void {
Task { // runs on MainActor
- symLog.log("adding: \(exUrl)")
+ symLog.log("adding: \(exchange)")
do {
- try await model.addExchange(url: exUrl)
- symLog.log("added: \(exUrl)")
+ try await model.addExchange(url: exchange)
+ symLog.log("added: \(exchange)")
} catch { // TODO: error handling - couldn't add exchangeURL
symLog.log("error: \(error)")
}
}
}
- @State var showAlert: Bool = false
- @State var newExchange: String = TESTEXCHANGE
-
var body: some View {
-#if DEBUG
- let _ = Self._printChanges()
- let _ = symLog.vlog() // just to get the # to compare it with
.onAppear & onDisappear
-#endif
- let plusAction: () -> Void = {
-// withAnimation { showAlert = true }
- showAlert = true
- }
#if TABBAR // Taler Wallet
let hamburger: HamburgerButton? = nil
#else // GNU Taler
- let hamburger: HamburgerButton = HamburgerButton(action:
hamburgerAction)
+ let hamburger = HamburgerButton(action: hamburgerAction)
+#endif
+ let accessibilityLabelStr = String(localized: "Add Exchange", comment:
"accessibilityLabel for the + button")
+ let plusButton = PlusButton(accessibilityLabelStr:
accessibilityLabelStr) {
+ showAlert = true
+ }
+ let addTitleStr = String(localized: "Add Exchange", comment: "title of
the addExchange alert")
+ let addButtonStr = String(localized: "Add", comment: "button in the
addExchange alert")
+ if #available(iOS 16.0, *) {
+ ExchangeListCommonV(symLog: symLog, stack: stack.push())
+ .navigationTitle(navTitle)
+ .navigationBarItems(leading: hamburger, trailing: plusButton)
+ .alert(addTitleStr, isPresented: $showAlert) {
+ TextField("Exchange address", text: $newExchange)
+ Button(addButtonStr) {
+ addExchange(newExchange)
+ }.buttonStyle(.borderedProminent)
+ Button("Cancel", role: .cancel) { }
+ } message: {
+ Text("Please enter the exchange URL")
+ }
+ } else { // iOS 15 cannot have a textfield in an alert, so we must
+ ExchangeListCommonV(symLog: symLog, stack: stack.push())
+ .navigationTitle(navTitle)
+ .navigationBarItems(leading: hamburger, trailing: plusButton)
+ .textFieldAlert(isPresented: $showAlert,
+ title: addTitleStr,
+ doneText: addButtonStr,
+ text: $newExchange) { text in
+ addExchange(text)
+ }
+ }
+ }
+}
+
+struct ExchangeListCommonV: View {
+ let symLog: SymLogV?
+ let stack: CallStack
+// @Binding var balances: [Balance]
+
+ @EnvironmentObject private var model: WalletModel
+
+ @State private var exchanges: [Exchange] = []
+
+ // source of truth for the value the user enters in currencyField for
exchange withdrawals
+ @State private var centsToTransfer: UInt64 = 0 // TODO: different
values for different currencies?
+
+ func reloadExchanges() async -> Void {
+ exchanges = await model.listExchangesM()
+ }
+
+ var body: some View {
+#if DEBUG
+ let _ = Self._printChanges()
+ let _ = symLog?.vlog() // just to get the # to compare it with
.onAppear & onDisappear
#endif
//Text("Exchanges...")
Content(symLog: symLog,
@@ -64,10 +99,6 @@ struct ExchangeListView: View {
exchanges: $exchanges,
centsToTransfer: $centsToTransfer,
reloadExchanges: reloadExchanges)
- .navigationTitle(navTitle)
- .navigationBarItems(leading: hamburger,
- trailing: PlusButton(action: plusAction)
- .accessibilityLabel("Add Exchange"))
.overlay {
if exchanges.isEmpty {
Text("No Exchanges yet...")
@@ -75,24 +106,13 @@ struct ExchangeListView: View {
}
}
.task {
- symLog.log(".task")
+ symLog?.log(".task")
await reloadExchanges()
}
- .textFieldAlert(isPresented: $showAlert, title: "Add Exchange",
- doneText: "Add", text: $newExchange, action:
addExchange)
}
}
// MARK: -
-//struct ExchangeAmount: Identifiable {
-// let exchange: Exchange
-// let amountAvailable: Amount
-//
-// var id: String { // needed for Identifiable
-// exchange.exchangeBaseUrl
-// }
-//}
-// MARK: -
-extension ExchangeListView {
+extension ExchangeListCommonV {
struct Content: View {
let symLog: SymLogV?
let stack: CallStack
diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift
b/TalerWallet1/Views/HelperViews/Buttons.swift
index c40b542..f221ac6 100644
--- a/TalerWallet1/Views/HelperViews/Buttons.swift
+++ b/TalerWallet1/Views/HelperViews/Buttons.swift
@@ -41,6 +41,7 @@ struct QRButton : View {
}
struct PlusButton : View {
+ let accessibilityLabelStr: String
let action: () -> Void
var body: some View {
@@ -48,7 +49,7 @@ struct PlusButton : View {
Image(systemName: "plus")
}
.accessibilityFont(.title)
- .accessibilityLabel("Add...")
+ .accessibilityLabel(accessibilityLabelStr)
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 16/25: ManualDetailsV, minimal, (continued)
- [taler-taler-ios] 16/25: ManualDetailsV, minimal, gnunet, 2023/11/06
- [taler-taler-ios] 03/25: Purpose->Subject, cleanup, gnunet, 2023/11/06
- [taler-taler-ios] 06/25: L10N, gnunet, 2023/11/06
- [taler-taler-ios] 02/25: until Xcode 15.1 is final, gnunet, 2023/11/06
- [taler-taler-ios] 21/25: Accessibility, gnunet, 2023/11/06
- [taler-taler-ios] 04/25: No l10n for Debug, gnunet, 2023/11/06
- [taler-taler-ios] 13/25: Accessibility, gnunet, 2023/11/06
- [taler-taler-ios] 24/25: Accessibility: Contrast, gnunet, 2023/11/06
- [taler-taler-ios] 18/25: Default for Sound & Haptics ON, gnunet, 2023/11/06
- [taler-taler-ios] 23/25: L10N, EMPTYSTRING, gnunet, 2023/11/06
- [taler-taler-ios] 10/25: Use System Alert for iOS16+,
gnunet <=
- [taler-taler-ios] 14/25: Blue Logo, gnunet, 2023/11/06
- [taler-taler-ios] 25/25: Bump version to 0.9.3 (24), gnunet, 2023/11/06
- [taler-taler-ios] 15/25: cleanup sortedTransactions, gnunet, 2023/11/06
- [taler-taler-ios] 07/25: IncompleteRowV, gnunet, 2023/11/06
- [taler-taler-ios] 09/25: Logger, gnunet, 2023/11/06
- [taler-taler-ios] 19/25: SendDone: Prevent double execution, gnunet, 2023/11/06
- [taler-taler-ios] 20/25: Debugging, gnunet, 2023/11/06
- [taler-taler-ios] 12/25: KYC - wip, gnunet, 2023/11/06
- [taler-taler-ios] 08/25: Accessibility, gnunet, 2023/11/06
- [taler-taler-ios] 17/25: ThreeAmountsV cleanup, gnunet, 2023/11/06