commit 89101c451342348e7c1579c114458d76c952c02d
parent e2a3f82b4f4a6ea7516e4a69edd5650243040c29
Author: Marc Stibane <marc@taler.net>
Date: Sun, 13 Apr 2025 13:41:29 +0200
useAvailable
Diffstat:
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
@@ -111,7 +111,7 @@ struct SendAmountV: View {
scope: balance?.scopeInfo,
amount: $amountToTransfer,
available: $amountAvailable,
-// useAvailable: true, // cannot send more than we have
+ useAvailable: true, // cannot send more than we have
fwdButtonTapped: $buttonSelected)
.environmentObject(NamespaceWrapper(namespace)) // keep OIMviews apart
}
diff --git a/TalerWallet1/Views/OIM/OIMView.swift b/TalerWallet1/Views/OIM/OIMView.swift
@@ -149,6 +149,7 @@ struct OIMEditView: View {
let scope: ScopeInfo?
@Binding var amount: Amount
@Binding var available: Amount
+ let useAvailable : Bool // if false then we're requesting money and don't use available
// let decimal: Int // 0 for ¥,HUF; 2 for $,€,£; 3 for ﷼,₯ (arabic)
@Binding var fwdButtonTapped: Bool
@@ -162,6 +163,18 @@ struct OIMEditView: View {
@State private var flying: UInt64 = 0
@State private var shake = false
+ var isAvailable: UInt64 {
+ if useAvailable {
+ let have = intValue(available)
+ let want = intValue(amount)
+ if have > want {
+ return have - want
+ }
+ return 0
+ }
+ return 999_999_999
+ }
+
var body: some View {
// let _ = Self._printChanges()
@@ -205,7 +218,9 @@ struct OIMEditView: View {
.environmentObject(cash)
.task {
amountVal = intValue(amount)
- availableVal = intValue(available) - intValue(amount)
+ availableVal = isAvailable
+ let result = currency.notesCoins(amountVal)
+ cash.update(result, currency: currency)
}
}
}