commit c7e7be7e11dcc98cbcf2995b99182e175f03caf2
parent 894c387f762968efb3b6022ae276b87e7142061a
Author: Marc Stibane <marc@taler.net>
Date: Fri, 13 Sep 2024 09:39:17 +0200
cleanup, debug
Diffstat:
7 files changed, 19 insertions(+), 76 deletions(-)
diff --git a/TalerWallet1/Views/Actions/ActionsSheet.swift b/TalerWallet1/Views/Actions/ActionsSheet.swift
@@ -8,6 +8,10 @@
import SwiftUI
import taler_swift
+/// This view shows the action sheet
+/// optional: [Spend KUDOS]
+/// [Send] [Request]
+/// [Withdraw] [Deposit]
struct ActionsSheet: View {
let stack: CallStack
@Binding var balances: [Balance]
@@ -60,17 +64,12 @@ struct ActionsSheet: View {
SendRequestV(stack: stack.push(),
balances: $balances,
-// currencyInfo: $currencyInfo,
-// amountAvailable: balance.available,
amountToTransfer: $amountToTransfer, // does still have the wrong currency
summary: $summary,
cameraAction: cameraAction)
DepositWithdrawV(stack: stack.push(),
balances: $balances,
-// currencyInfo: $currencyInfo,
-// scopeInfo: balance.scopeInfo,
-// amountAvailable: balance.available,
amountToTransfer: $amountToTransfer) // does still have the wrong currency
.padding(.bottom, 12)
}
diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmount.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmount.swift
@@ -14,7 +14,7 @@ struct SendAmount: View {
private let symLog = SymLogV(0)
let stack: CallStack
let balances: [Balance]
- @Binding var selectedBalance: Balance?
+ @Binding var selectedBalance: Balance? // selected balance when the action button is tapped in Transactions
@Binding var amountToTransfer: Amount
@Binding var summary: String
let scopeInfo: ScopeInfo
@@ -264,7 +264,7 @@ fileprivate struct Preview_Content: View {
@State private var amountToPreview = Amount(currency: DEMOCURRENCY, cent: 510)
@State private var summary: String = ""
@State private var currencyInfoL: CurrencyInfo = CurrencyInfo.zero(DEMOCURRENCY)
- @State private var selectedBalance: Balance? = nil
+ @State private var noBalance: Balance? = nil
private func checkCameraAvailable() -> Void {
// Open Camera when QR-Button was tapped
@@ -289,7 +289,7 @@ fileprivate struct Preview_Content: View {
flags: [])
SendAmount(stack: CallStack("Preview"),
balances: [balance],
- selectedBalance: $selectedBalance,
+ selectedBalance: $noBalance,
amountToTransfer: $amountToPreview,
summary: $summary,
scopeInfo: currencyInfo.scope,
diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -51,7 +51,7 @@ struct BalancesListView: View {
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear
#endif
- Group { // necessary for .backslide transition (bug in SwiftUI)
+ Group {
let count = balances.count
if balances.isEmpty {
WalletEmptyView(stack: stack.push("isEmpty"))
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -12,13 +12,9 @@ import SymLog
/// This view shows a currency section
/// Currency Name
/// "Balance" $balance // leads to completed Transactions (.done)
-/// [Send $currency] [Request $currency]
/// optional: Pending Incoming
/// optional: Pending Outgoing
-/// optional: [Spend KUDOS]
-/// [Withdraw $currency] [Deposit $currency]
/// optional?: Suspended / Aborting / Aborted / Expired
-
struct BalancesSectionView {
private let symLog = SymLogV(0)
let stack: CallStack
@@ -49,7 +45,6 @@ struct BalancesSectionView {
@State private var currencyInfo = CurrencyInfo.zero(UNKNOWN)
@State private var currencyName: String = UNKNOWN
@State private var currencySymbol: String = UNKNOWN
-// @State private var buttonSelected: Int? = nil
private static func className() -> String {"\(self)"}
@@ -127,31 +122,12 @@ extension BalancesSectionView: View {
BalanceCellV(stack: stack.push("BalanceCell"),
currencyInfo: $currencyInfo,
amount: balance.available,
-// sizeCategory: sizeCategory,
-// rowAction: { buttonSelected = 3 }, // trigger TransactionList NavigationLink
+// sizeCategory: sizeCategory,
+// rowAction: { buttonSelected = 3 }, // trigger TransactionList NavigationLink
balanceDest: balanceDest)
// .listRowSeparator(.hidden)
// .border(.red)
-// SendRequestV(stack: stack.push(),
-// currencyInfo: $currencyInfo,
-// amountAvailable: balance.available,
-// amountToTransfer: $amountToTransfer,
-// summary: $summary,
-// cameraAction: cameraAction)
-// .listRowSeparator(.hidden)
-
-// BalancesNavigationLinksV(symLog: symLog,
-// stack: stack.push("Section"),
-// currencyInfo: currencyInfo,
-// balance: balance,
-// amountToTransfer: $amountToTransfer, // does still have the wrong currency
-// summary: $summary,
-// completedTransactions: $completedTransactions,
-// reloadAllAction: reloadCompleted,
-// reloadOneAction: reloadOneAction,
-// cameraAction: cameraAction)
-
if pendingTransactions.count > 0 {
BalancesPendingRowV(//symLog: symLog,
stack: stack.push(),
@@ -163,38 +139,6 @@ extension BalancesSectionView: View {
reloadOneAction: reloadOneAction)
.padding(.leading, ICONLEADING)
}
-// let showSpendingButton = DEMOCURRENCY == currency && !balance.available.isZero
-// if showSpendingButton {
-// if !minimalistic && showSpendingHint {
-// Text("You can spend these \(currencyName) in the Demo shop, or send them to another wallet.")
-// .talerFont(.body)
-// .multilineTextAlignment(.leading)
-// .listRowSeparator(.hidden)
-// }
-// let title = String(localized: "LinkTitle_DEMOSHOP", defaultValue: "Spend demo money")
-// let action = {
-// showSpendingHint = false
-// UIApplication.shared.open(URL(string:DEMOSHOP)!, options: [:])
-// }
-// Button(action: action) {
-// HStack {
-// ButtonIconBadge(type: .payment, foreColor: .accentColor, done: false)
-// Spacer()
-// Text(title)
-// Spacer()
-// }
-// }
-// .buttonStyle(TalerButtonStyle(type: .bordered, narrow: false, aligned: .center))
-// .accessibilityHint(String(localized: "Will go to the demo shop website."))
-// .listRowSeparator(.hidden)
-// }
-
-// DepositWithdrawV(stack: stack.push(),
-// currencyInfo: $currencyInfo,
-// scopeInfo: balance.scopeInfo,
-// amountAvailable: balance.available,
-// amountToTransfer: $amountToTransfer) // does still have the wrong currency
-
} header: {
BarGraphHeader(stack: stack.push(),
scopeInfo: scopeInfo,
diff --git a/TalerWallet1/Views/HelperViews/AmountInputV.swift b/TalerWallet1/Views/HelperViews/AmountInputV.swift
@@ -28,7 +28,7 @@ struct ComputeFeeResult {
numCoins: -1)
}
}
-
+// MARK: -
struct AmountInputV: View {
private let symLog = SymLogV(0)
let stack: CallStack
@@ -123,11 +123,11 @@ struct AmountInputV: View {
if let result: ComputeFeeResult = await computeFee(amountToTransfer) {
symLog.log("computeFee() finished")
feeStr = result.feeStr
-// insufficient = result.insufficient
+// insufficient = result.insufficient // TODO: insufficient
feeAmount = result.feeAmount
numCoins = result.numCoins
} else {
- symLog.log("computeFee() failed")
+ symLog.log("computeFee() failed ❗️") // \(error)")
}
}
}
diff --git a/TalerWallet1/Views/HelperViews/SubjectInputV.swift b/TalerWallet1/Views/HelperViews/SubjectInputV.swift
@@ -15,7 +15,7 @@ struct SubjectInputV<TargetView: View>: View {
@Binding var currencyInfo: CurrencyInfo
// the scanned URL
let url: URL?
- let amountAvailable: Amount? // TODO: GetMaxPeerPushAmount
+ let amountAvailable: Amount? // TODO: getMaxDepositAmountM, getMaxPeerPushDebitAmountM
@Binding var amountToTransfer: Amount
let amountLabel: String
@Binding var summary: String
diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
@@ -83,10 +83,10 @@ struct AccountPicker: View {
let accountDetails: [WithdrawalExchangeAccountDetails]
let action: (Int) -> Void
- @State private var selectedAccount = 0
+ @State private var selected = 0
var body: some View {
- Picker(title, selection: $selectedAccount) {
+ Picker(title, selection: $selected) {
ForEach(0..<accountDetails.count, id: \.self) { index in
let detail = accountDetails[index]
if let amount = detail.transferAmount {
@@ -105,10 +105,10 @@ struct AccountPicker: View {
.talerFont(.title3)
.pickerStyle(.menu)
.onAppear() {
- withAnimation { selectedAccount = value }
+ withAnimation { selected = value }
}
- .onChange(of: selectedAccount) { selected in
- action(selected)
+ .onChange(of: selected) { newValue in
+ action(newValue)
}
}
}