gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] branch master updated (49c8f03 -> 279a009)


From: gnunet
Subject: [taler-taler-ios] branch master updated (49c8f03 -> 279a009)
Date: Sun, 14 Jul 2024 10:25:42 +0200

This is an automated email from the git hooks/post-receive script.

marc-stibane pushed a change to branch master
in repository taler-ios.

    from 49c8f03  Spend button with icon
     new 33e19c2  Fix layout of tx list again
     new f9de329  Show negative amounts with "-"
     new 279a009  currency name in P2P buttons

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 TalerWallet1/Helper/CurrencySpecification.swift    | 26 +++++++++++++---------
 TalerWallet1/Views/Balances/BalanceRowView.swift   | 12 +++++-----
 .../Views/Balances/BalancesSectionView.swift       |  5 +++++
 TalerWallet1/Views/Balances/PendingRowView.swift   |  7 ++++--
 TalerWallet1/Views/Banking/DepositAmountV.swift    | 10 ++++-----
 TalerWallet1/Views/Banking/DepositIbanV.swift      |  9 +++++---
 TalerWallet1/Views/Banking/QuiteSomeCoins.swift    |  7 ++++--
 TalerWallet1/Views/HelperViews/AmountInputV.swift  |  2 +-
 TalerWallet1/Views/HelperViews/AmountRowV.swift    | 17 +++++++++-----
 TalerWallet1/Views/HelperViews/AmountV.swift       | 13 +++++++----
 TalerWallet1/Views/HelperViews/CurrencyField.swift |  5 ++++-
 .../Views/HelperViews/CurrencyInputView.swift      |  7 ++++--
 .../Views/HelperViews/QRCodeDetailView.swift       |  7 ++++--
 TalerWallet1/Views/HelperViews/SubjectInputV.swift |  4 ++--
 TalerWallet1/Views/Overview/OverviewRowV.swift     |  7 ++++--
 TalerWallet1/Views/Peer2peer/P2PSubjectV.swift     | 11 +++++----
 TalerWallet1/Views/Peer2peer/SendAmount.swift      |  6 ++---
 .../Views/Sheets/Payment/PaymentView.swift         |  4 ++--
 .../Views/Transactions/ManualDetailsV.swift        | 13 ++++++-----
 .../Views/Transactions/ThreeAmountsV.swift         | 17 +++++++++-----
 .../Views/Transactions/TransactionRowView.swift    |  7 +++---
 .../Views/Transactions/TransactionSummaryV.swift   |  2 ++
 22 files changed, 127 insertions(+), 71 deletions(-)

diff --git a/TalerWallet1/Helper/CurrencySpecification.swift 
b/TalerWallet1/Helper/CurrencySpecification.swift
index 4cb9867..79a9a2a 100644
--- a/TalerWallet1/Helper/CurrencySpecification.swift
+++ b/TalerWallet1/Helper/CurrencySpecification.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import Foundation
 import taler_swift
 
@@ -33,30 +36,30 @@ extension Locale {
 }
 
 extension Amount {
-    func formatted(_ currencyInfo: CurrencyInfo?, useISO: Bool = false) -> 
String {
+    func formatted(_ currencyInfo: CurrencyInfo?, isNegative: Bool, useISO: 
Bool = false) -> String {
         if let currencyInfo {
-            return currencyInfo.string(for: valueAsFloatTuple, useISO: useISO)
+            return currencyInfo.string(for: valueAsFloatTuple, isNegative: 
isNegative, useISO: useISO)
         } else {
             return valueStr
         }
     }
 
-    func formatted(useISO: Bool = false) -> String {
+    func formatted(isNegative: Bool, useISO: Bool = false) -> String {
         let controller = Controller.shared
         if let currencyInfo = controller.info(for: self.currencyStr) {
-            return self.formatted(currencyInfo, useISO: useISO)
+            return self.formatted(currencyInfo, isNegative: isNegative, 
useISO: useISO)
         }
         return self.readableDescription
     }
 
-    func formatted(specs: CurrencySpecification?, scope: ScopeInfo? = nil, 
useISO: Bool = false) -> String {
+    func formatted(specs: CurrencySpecification?, isNegative: Bool, scope: 
ScopeInfo? = nil, useISO: Bool = false) -> String {
         if let specs {
             let myScope = scope ?? ScopeInfo(type: .madeUp, currency: 
currencyStr)
             let formatter = CurrencyFormatter.formatter(scope: myScope, specs: 
specs)
             let currencyInfo = CurrencyInfo(scope: myScope, specs: specs, 
formatter: formatter)
-            return formatted(currencyInfo, useISO: useISO)
+            return formatted(currencyInfo, isNegative: isNegative, useISO: 
useISO)
         }
-        return formatted(useISO: useISO)
+        return formatted(isNegative: isNegative, useISO: useISO)
     }
 
     func inputDigits(_ currencyInfo: CurrencyInfo) -> UInt {
@@ -169,10 +172,10 @@ public struct CurrencyInfo {
     }
 
     // TODO: use valueAsDecimalTuple instead of valueAsFloatTuple
-    func string(for valueTuple: (Double, Double), useISO: Bool = false) -> 
String {
+    func string(for valueTuple: (Double, Double), isNegative: Bool, useISO: 
Bool = false) -> String {
         formatter.setUseISO(useISO)
         let (integer, fraction) = valueTuple
-        if let integerStr = formatter.string(for: integer) {
+        if let integerStr = formatter.string(for: isNegative ? -integer : 
integer) {
             let integerSpaced = integerStr.spaced
             if fraction == 0 {
                 return currencyString(integerSpaced, useISO: useISO)   // 
formatter already added trailing zeroes
@@ -220,7 +223,8 @@ public struct CurrencyInfo {
                 currencyName = altUnitName0
             }
         }
-        var madeUpStr = currencyName + " " + String(integer)
+        var madeUpStr = currencyName + (isNegative ? " -" + String(integer)
+                                                   : " " + String(integer))
 //        let homeCurrency = Locale.current.currency      //'currency' is only 
available in iOS 16 or newer
         madeUpStr += formatter.currencyDecimalSeparator ?? 
Locale.current.decimalSeparator ?? "."
         madeUpStr += String(String(fraction).dropFirst())       // remove the 
leading 0
diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift 
b/TalerWallet1/Views/Balances/BalanceRowView.swift
index 955f232..1c255b3 100644
--- a/TalerWallet1/Views/Balances/BalanceRowView.swift
+++ b/TalerWallet1/Views/Balances/BalanceRowView.swift
@@ -21,7 +21,7 @@ struct BalanceCell: View {
     /// Renders the Balance button. "Balance" leading, amountStr trailing. If 
it doesn't fit in one row then
     /// amount (trailing) goes underneath "Balance" (leading).
     var body: some View {
-        let amountV = AmountV(amount: amount, large: true)
+        let amountV = AmountV(amount: amount, isNegative: false, large: true)
             .foregroundColor(.primary)
         let hLayout = amountV
                         .frame(maxWidth: .infinity, alignment: .trailing)
@@ -64,6 +64,7 @@ struct BalanceCell: View {
 struct BalanceRowView: View {
     let stack: CallStack
     let amount: Amount
+    let currencyName: String
     let sendAction: () -> Void
     let recvAction: () -> Void
     let rowAction: () -> Void
@@ -75,15 +76,14 @@ struct BalanceRowView: View {
     @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
 
     var body: some View {
-        let currency = amount.currencyStr
         let sendTitle0 = String(localized: "SendButton_Short", defaultValue: 
"Send",
                                   comment: "Abbreviation of button `Send 
(currency)´")
-        let sendTitle1 = String(localized: "SendButton_Full", defaultValue: 
"Send\t\(currency)",
+        let sendTitle1 = String(localized: "SendButton_Full", defaultValue: 
"Send\t\(currencyName)",
                                   comment: "`Send (currency)´ in Balances - 
must have ONE \\t and ONE %@")
 
         let requestTitle0 = String(localized: "RequestButton_Short", 
defaultValue: "Request",
                                      comment: "Abbreviation of button `Request 
(currency)´")
-        let requestTitle1 = String(localized: "RequestButton_Full", 
defaultValue: "Request\t\(currency)",
+        let requestTitle1 = String(localized: "RequestButton_Full", 
defaultValue: "Request\t\(currencyName)",
                                      comment: "`Request (currency)´ in 
Balances - must have ONE \\t and ONE %@")
         VStack (alignment: .trailing, spacing: 6) {
             BalanceCell(amount: amount,
@@ -132,10 +132,10 @@ struct BalanceRowView_Previews: PreviewProvider {
 
         List {
             Section {
-                BalanceRowView(stack: CallStack("Preview"), amount: demo,
+                BalanceRowView(stack: CallStack("Preview"), amount: demo, 
currencyName: DEMOCURRENCY,
                           sendAction: {}, recvAction: {}, rowAction: {}, 
balanceDest: nil)
             }
-            BalanceRowView(stack: CallStack("Preview"), amount: test, 
+            BalanceRowView(stack: CallStack("Preview"), amount: test, 
currencyName: TESTCURRENCY, 
                       sendAction: {}, recvAction: {}, rowAction: {}, 
balanceDest: nil)
         }
     }
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift 
b/TalerWallet1/Views/Balances/BalancesSectionView.swift
index ed1bade..c24c752 100644
--- a/TalerWallet1/Views/Balances/BalancesSectionView.swift
+++ b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -244,6 +244,7 @@ fileprivate struct BalancesNavigationLinksView: View {
     let reloadOneAction: ((_ transactionId: String, _ viewHandles: Bool) async 
throws -> Transaction)
     let cameraAction: () -> Void
 
+    @EnvironmentObject private var controller: Controller
 //    @EnvironmentObject private var model: WalletModel
 
     @State private var buttonSelected: Int? = nil
@@ -266,6 +267,9 @@ fileprivate struct BalancesNavigationLinksView: View {
 
     var body: some View {
         let scopeInfo = balance.scopeInfo
+        let currency = scopeInfo.currency
+        let currencyInfo = controller.info(for: currency)
+        let currencyName = currencyInfo?.scope.currency ?? currency
         HStack(spacing: 0) {
             NavigationLink(destination: LazyView {
                 SendAmount(stack: stack.push(),
@@ -299,6 +303,7 @@ fileprivate struct BalancesNavigationLinksView: View {
 
             BalanceRowView(stack: stack.push(),
                           amount: balance.available,
+                    currencyName: currencyName,
                       sendAction: {
                             selectAndUpdate(1)      // trigger SendAmount 
NavigationLink
                    }, recvAction: {
diff --git a/TalerWallet1/Views/Balances/PendingRowView.swift 
b/TalerWallet1/Views/Balances/PendingRowView.swift
index 46e284f..07d07e1 100644
--- a/TalerWallet1/Views/Balances/PendingRowView.swift
+++ b/TalerWallet1/Views/Balances/PendingRowView.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 
@@ -33,7 +36,7 @@ struct PendingRowView: View {
         let outTitle = minimalistic ? outTitle0 : outTitle1
         let pendingTitle = incoming ? inTitle : outTitle
 
-        let amountText = AmountV(amount)
+        let amountText = AmountV(amount, isNegative: !incoming)
             .foregroundColor(pendingColor)
 
         // this is the default view for iOS 15
diff --git a/TalerWallet1/Views/Banking/DepositAmountV.swift 
b/TalerWallet1/Views/Banking/DepositAmountV.swift
index 42abc76..f4567bd 100644
--- a/TalerWallet1/Views/Banking/DepositAmountV.swift
+++ b/TalerWallet1/Views/Banking/DepositAmountV.swift
@@ -59,12 +59,12 @@ struct DepositAmountV: View {
     }
 
     private func buttonTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) 
-> String {
-        let amountWithCurrency = amount.formatted(currencyInfo, useISO: true)
+        let amountWithCurrency = amount.formatted(currencyInfo, isNegative: 
false, useISO: true)
         return String(localized: "Deposit \(amountWithCurrency)", comment: 
"amount with currency")
     }
 
     private func subjectTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) 
-> String {
-        let amountStr = amount.formatted(currencyInfo)
+        let amountStr = amount.formatted(currencyInfo, isNegative: false)
         return String(localized: "NavTitle_Deposit_AmountStr",
                       defaultValue: "Deposit", comment: "NavTitle: Deposit")
         //                   defaultValue: "Deposit \(amountStr)", comment: 
"NavTitle: Deposit 'amountStr'")
@@ -89,10 +89,10 @@ struct DepositAmountV: View {
             let navTitle = String(localized: "NavTitle_Deposit_Currency",
                                   defaultValue: "Deposit \(currencySymbol)",
                                   comment: "NavTitle: Deposit 
'currencySymbol'")
-            let available = amountAvailable?.formatted(currencyInfo) ?? "an 
unknown amount"
+            let available = amountAvailable?.formatted(currencyInfo, 
isNegative: false) ?? "an unknown amount"
             let _ = print("available: \(available)")
             let _ = symLog.log("currency: \(currency), available: 
\(available)")
-            let amountVoiceOver = amountToTransfer.formatted(currencyInfo)
+            let amountVoiceOver = amountToTransfer.formatted(currencyInfo, 
isNegative: false)
             let insufficientLabel = String(localized: "You don't have enough 
\(currency).")
             let insufficientLabel2 = String(localized: "but you only have 
\(available) to deposit.")
 
@@ -169,7 +169,7 @@ struct DepositAmountV: View {
                     } else if let paytoUri {
                         if let ppCheck = try? await 
model.prepareDepositM(paytoUri, amount: amountToTransfer) {
                             if let feeAmount = fee(ppCheck: ppCheck) {
-                                feeStr = feeAmount.formatted(currencyInfo)
+                                feeStr = feeAmount.formatted(currencyInfo, 
isNegative: false)
                                 let feeLabel = feeLabel(feeStr)
                                 announce("\(amountVoiceOver), \(feeLabel)")
                             } else {
diff --git a/TalerWallet1/Views/Banking/DepositIbanV.swift 
b/TalerWallet1/Views/Banking/DepositIbanV.swift
index b6eb21f..0e90530 100644
--- a/TalerWallet1/Views/Banking/DepositIbanV.swift
+++ b/TalerWallet1/Views/Banking/DepositIbanV.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 import SymLog
@@ -31,13 +34,13 @@ struct DepositIbanV: View {
     @FocusState private var isFocused: Bool
 
     private func buttonTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) 
-> String {
-        let amountWithCurrency = amount.formatted(currencyInfo, useISO: true)
+        let amountWithCurrency = amount.formatted(currencyInfo, isNegative: 
true, useISO: true)
         return String(localized: "Next", comment: "advance Deposit to Amount")
         return String(localized: "Deposit \(amountWithCurrency)", comment: 
"amount with currency")
     }
 
     private func subjectTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) 
-> String {
-        let amountStr = amount.formatted(currencyInfo)
+        let amountStr = amount.formatted(currencyInfo, isNegative: true)
         return String(localized: "NavTitle_Deposit_AmountStr",
                    defaultValue: "Deposit", comment: "NavTitle: Deposit")
 //                   defaultValue: "Deposit \(amountStr)", comment: "NavTitle: 
Deposit 'amountStr'")
diff --git a/TalerWallet1/Views/Banking/QuiteSomeCoins.swift 
b/TalerWallet1/Views/Banking/QuiteSomeCoins.swift
index 231d732..2c2c76b 100644
--- a/TalerWallet1/Views/Banking/QuiteSomeCoins.swift
+++ b/TalerWallet1/Views/Banking/QuiteSomeCoins.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 import SymLog
@@ -20,7 +23,7 @@ struct SomeCoins {
                 invalid ? String(localized: "Amount too small!")
               : tooMany ? String(localized: "Amount too big for a single 
withdrawal!")
            : fee.isZero ? String(localized: "No withdrawal fee")
-                        : String(localized: "- \(fee.formatted(currencyInfo)) 
fee")
+                        : String(localized: "- \(fee.formatted(currencyInfo, 
isNegative: false)) fee")
        } else {
            EMPTYSTRING
        }
diff --git a/TalerWallet1/Views/HelperViews/AmountInputV.swift 
b/TalerWallet1/Views/HelperViews/AmountInputV.swift
index d02f62b..00984b3 100644
--- a/TalerWallet1/Views/HelperViews/AmountInputV.swift
+++ b/TalerWallet1/Views/HelperViews/AmountInputV.swift
@@ -55,7 +55,7 @@ struct AmountInputV: View {
         let currency = amountToTransfer.currencyStr
         let currencyInfo = controller.info(for: currency, 
controller.currencyTicker)
         let insufficientLabel = String(localized: "You don't have enough 
\(currency).")
-        let available = amountAvailable?.formatted(currencyInfo) ?? nil
+        let available = amountAvailable?.formatted(currencyInfo, isNegative: 
false) ?? nil
         let flags = checkAvailable(amount: amountToTransfer)
         VStack(alignment: .trailing) {
             if summary.count > 0 {
diff --git a/TalerWallet1/Views/HelperViews/AmountRowV.swift 
b/TalerWallet1/Views/HelperViews/AmountRowV.swift
index 4f30d9f..1ec0782 100644
--- a/TalerWallet1/Views/HelperViews/AmountRowV.swift
+++ b/TalerWallet1/Views/HelperViews/AmountRowV.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 
@@ -9,6 +12,7 @@ import taler_swift
 struct AmountRowV: View {
     let title: String
     let amount: Amount
+    let isNegative: Bool        // if true, show a "-" before the amount
     let color: Color
     let large: Bool      // set to false for QR or IBAN
 
@@ -16,7 +20,7 @@ struct AmountRowV: View {
         let titleV = Text(title)
                         .multilineTextAlignment(.leading)
                         .talerFont(.body)
-        let amountV = AmountV(amount: amount, large: large)
+        let amountV = AmountV(amount: amount, isNegative: isNegative, large: 
large)
                         .foregroundColor(color)
         let verticalV = VStack(alignment: .leading) {
             titleV
@@ -52,9 +56,10 @@ struct AmountRowV: View {
     }
 }
 extension AmountRowV {
-    init(title: String, amount: Amount, color: Color) {
+    init(title: String, amount: Amount, isNegative: Bool, color: Color) {
         self.title = title
         self.amount = amount
+        self.isNegative = isNegative
         self.color = color
         self.large = true
     }
@@ -72,10 +77,10 @@ fileprivate func talerFromStr(_ from: String) -> Amount {
 #Preview {
     List {
         let fee = Amount(currency: "Taler", cent: 20)
-        AmountRowV(title: "Fee", amount: fee, color: Color("Outgoing"), large: 
false)
+        AmountRowV(title: "Fee", amount: fee, isNegative: true, color: 
Color("Outgoing"), large: false)
         let cents = Amount(currency: "Taler", cent: 480)
-        AmountRowV(title: "Cents", amount: cents, color: Color("Incoming"))
+        AmountRowV(title: "Cents", amount: cents, isNegative: false, color: 
Color("Incoming"))
         let amount = talerFromStr("Taler:4.80")
-        AmountRowV(title: "Chosen amount to withdraw", amount: amount, color: 
Color("Incoming"))
+        AmountRowV(title: "Chosen amount to withdraw", amount: amount, 
isNegative: false, color: Color("Incoming"))
     }
 }
diff --git a/TalerWallet1/Views/HelperViews/AmountV.swift 
b/TalerWallet1/Views/HelperViews/AmountV.swift
index a5fb8e6..d565050 100644
--- a/TalerWallet1/Views/HelperViews/AmountV.swift
+++ b/TalerWallet1/Views/HelperViews/AmountV.swift
@@ -1,18 +1,22 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 
 struct AmountV: View {
     let amount: Amount
-    let large: Bool      // set to false for QR or IBAN
+    let isNegative: Bool        // if true, show a "-" before the amount
+    let large: Bool             // set to false for QR or IBAN
 
     @EnvironmentObject private var controller: Controller
 
     var body: some View {
-        Text(amount.formatted())
+        Text(amount.formatted(isNegative: isNegative))
             .multilineTextAlignment(.center)
             .talerFont(large ? .title : .title2)
 //            .fontWeight(large ? .medium : .regular)       // @available(iOS 
16.0, *)
@@ -21,8 +25,9 @@ struct AmountV: View {
     }
 }
 extension AmountV {
-    init(_ amount: Amount) {
+    init(_ amount: Amount, isNegative: Bool) {
         self.amount = amount
+        self.isNegative = isNegative
         self.large = false
     }
 }
diff --git a/TalerWallet1/Views/HelperViews/CurrencyField.swift 
b/TalerWallet1/Views/HelperViews/CurrencyField.swift
index d3e8f66..e053ea3 100644
--- a/TalerWallet1/Views/HelperViews/CurrencyField.swift
+++ b/TalerWallet1/Views/HelperViews/CurrencyField.swift
@@ -19,6 +19,9 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
  * SOFTWARE.
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import UIKit
 import taler_swift
@@ -59,7 +62,7 @@ struct CurrencyField: View {
         ZStack {
             // Text view to display the formatted currency
             // Set as priority so CurrencyInputField size doesn't affect parent
-            Text(amount.formatted(currencyInfo))
+            Text(amount.formatted(currencyInfo, isNegative: false))
                 .layoutPriority(1)
                 // make the textfield use the whole width for tapping inside 
to become active
                 .frame(maxWidth: .infinity, alignment: .trailing)
diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift 
b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
index f0ba201..5e2594d 100644
--- a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
+++ b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 
@@ -37,7 +40,7 @@ struct ShortcutButton: View {
 
     var body: some View {
         let shortie = Amount(currency: currency, cent: UInt64(shortcut))       
 // TODO: adapt for ¥
-        let title = shortie.formatted(currencyInfo)
+        let title = shortie.formatted(currencyInfo, isNegative: false)
         let shortcutLabel = String(localized: "Shortcut", comment: "VoiceOver: 
$50,$25,$10,$5 shortcut buttons")
         Button(action: { action(shortcut, currencyField)} ) {
             Text(title)
diff --git a/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift 
b/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift
index 0eff5ed..d6f596a 100644
--- a/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift
+++ b/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 import AVFoundation
@@ -51,7 +54,7 @@ struct QRCodeDetailView: View {
                     .accessibilityLabel("QR Code")
                     .listRowSeparator(.hidden)
 
-                let amountStr = amount.formatted()
+                let amountStr = amount.formatted(isNegative: false)
                 let scanMini = incoming ? String(localized: "Either (payer) 
Mini 3",
                                               defaultValue: "to pay 
\(amountStr).", comment: "e.g. '5,3 €'")
                                         : String(localized: "Either (payee) 
Mini 3",
diff --git a/TalerWallet1/Views/HelperViews/SubjectInputV.swift 
b/TalerWallet1/Views/HelperViews/SubjectInputV.swift
index bfd3187..79fda31 100644
--- a/TalerWallet1/Views/HelperViews/SubjectInputV.swift
+++ b/TalerWallet1/Views/HelperViews/SubjectInputV.swift
@@ -44,7 +44,7 @@ struct SubjectInputV<TargetView: View>: View {
 //        let insufficientLabel = String(localized: "You don't have enough 
\(currency).")
 //        let feeLabel = insufficient ? insufficientLabel
 //                                    : feeLabel(feeStr)
-        let available = amountAvailable?.formatted(currencyInfo) ?? nil
+        let available = amountAvailable?.formatted(currencyInfo, isNegative: 
false) ?? nil
 //        let disabled = insufficient || summary.count == 0
         let disabled = summary.count == 0
         ScrollView { VStack(alignment: .leading) {
@@ -85,7 +85,7 @@ struct SubjectInputV<TargetView: View>: View {
                 }
             }
             HStack {
-                Text(amountToTransfer.formatted(currencyInfo))
+                Text(amountToTransfer.formatted(currencyInfo, isNegative: 
false))
                 // TODO: hasFees?
 //                Text(feeLabel)
             }
diff --git a/TalerWallet1/Views/Overview/OverviewRowV.swift 
b/TalerWallet1/Views/Overview/OverviewRowV.swift
index b3fde3d..7da3fce 100644
--- a/TalerWallet1/Views/Overview/OverviewRowV.swift
+++ b/TalerWallet1/Views/Overview/OverviewRowV.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 
@@ -18,7 +21,7 @@ struct CurrenciesCell: View {
     /// Renders the Balance button. "Balance" leading, amountStr trailing. If 
it doesn't fit in one row then
     /// amount (trailing) goes underneath "Balance" (leading).
     var body: some View {
-        let amountV = AmountV(amount: amount, large: true)
+        let amountV = AmountV(amount: amount, isNegative: false, large: true)
             .foregroundColor(.primary)
         let hLayout = amountV
                         .frame(maxWidth: .infinity, alignment: .trailing)
diff --git a/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift 
b/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift
index b117d22..d53d50f 100644
--- a/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift
+++ b/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 import SymLog
@@ -36,7 +39,7 @@ struct P2PSubjectV: View {
     @FocusState private var isFocused: Bool
 
     private func buttonTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) 
-> String {
-        let amountWithCurrency = amount.formatted(currencyInfo, useISO: true)
+        let amountWithCurrency = amount.formatted(currencyInfo, isNegative: 
false, useISO: true)
         return amountToSend ? String(localized: "Send \(amountWithCurrency) 
now",
                                        comment: "amount with currency")
                             : String(localized: "Request 
\(amountWithCurrency)",
@@ -44,7 +47,7 @@ struct P2PSubjectV: View {
     }
 
     private func subjectTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) 
-> String {
-        let amountStr = amount.formatted(currencyInfo)
+        let amountStr = amount.formatted(currencyInfo, isNegative: false)
         return amountToSend ? String(localized: "NavTitle_Send_AmountStr",
                                   defaultValue: "Send \(amountStr)",
                                        comment: "NavTitle: Send 'amountStr'")
@@ -136,7 +139,7 @@ struct P2PSubjectV: View {
             if amountToSend && feeLabel == nil {
                 if let ppCheck = try? await 
model.checkPeerPushDebitM(amountToTransfer) {
                     if let feeAmount = p2pFee(ppCheck: ppCheck) {
-                        let feeStr = feeAmount.formatted(currencyInfo)
+                        let feeStr = feeAmount.formatted(currencyInfo, 
isNegative: false)
                         myFeeLabel = String(localized: "+ \(feeStr) fee")
                     } else { myFeeLabel = EMPTYSTRING }
                 }
diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift 
b/TalerWallet1/Views/Peer2peer/SendAmount.swift
index c5f01a0..6df1c88 100644
--- a/TalerWallet1/Views/Peer2peer/SendAmount.swift
+++ b/TalerWallet1/Views/Peer2peer/SendAmount.swift
@@ -76,10 +76,10 @@ struct SendAmount: View {
         let navTitle = String(localized: "NavTitle_Send_Currency",
                            defaultValue: "Send \(currencySymbol)",
                                 comment: "NavTitle: Send 'currencySymbol'")
-        let available = amountAvailable.formatted(currencyInfo)
+        let available = amountAvailable.formatted(currencyInfo, isNegative: 
false)
 //        let _ = print("available: \(available)")
         let _ = symLog.log("currency: \(currency), available: \(available)")
-        let amountVoiceOver = amountToTransfer.formatted(currencyInfo)
+        let amountVoiceOver = amountToTransfer.formatted(currencyInfo, 
isNegative: false)
         let insufficientLabel2 = String(localized: "but you only have 
\(available) to send.")
 
         let inputDestination = LazyView {
@@ -158,7 +158,7 @@ struct SendAmount: View {
                 // TODO: set from exchange
 //                agePicker.setAges(ages: peerPushCheck?.ageRestrictionOptions)
                     if let feeAmount = fee(ppCheck: ppCheck) {
-                        feeStr = feeAmount.formatted(currencyInfo)
+                        feeStr = feeAmount.formatted(currencyInfo, isNegative: 
false)
                         let feeLabel = feeLabel(feeStr)
                         announce("\(amountVoiceOver), \(feeLabel)")
                     } else {
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift 
b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
index 82a46c4..8fd7d04 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -47,10 +47,10 @@ func preparePayForTemplate(model: WalletModel,
         let amountRaw = ppCheck.amountRaw
         let currency = amountRaw.currencyStr
         let currencyInfo = controller.info(for: currency, 
controller.currencyTicker)
-        let amountVoiceOver = amountRaw.formatted(currencyInfo)
+        let amountVoiceOver = amountRaw.formatted(currencyInfo, isNegative: 
false)
         let insufficient = ppCheck.status == .insufficientBalance
         if let feeAmount = templateFee(ppCheck: ppCheck) {
-            let feeStr = feeAmount.formatted(currencyInfo)
+            let feeStr = feeAmount.formatted(currencyInfo, isNegative: false)
             let feeLabel = feeLabel(feeStr)
             announce("\(amountVoiceOver), \(feeLabel)")
             return PayForTemplateResult(ppCheck: ppCheck, insufficient: 
insufficient,
diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift 
b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
index 4151a8d..c33c3b6 100644
--- a/TalerWallet1/Views/Transactions/ManualDetailsV.swift
+++ b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import OrderedCollections
 import taler_swift
@@ -35,7 +38,7 @@ struct SegmentControl: View {
                     let detail = accountDetails[index]
                     let specs = detail.currencySpecification
                     let amount = detail.transferAmount
-                    let amountStr = amount?.formatted(specs: specs, useISO: 
false) ?? ""
+                    let amountStr = amount?.formatted(specs: specs, 
isNegative: false, useISO: false) ?? ""
                     let bankName = detail.bankLabel
                     let a11yLabel = bankName != nil ? (bankName! + " " + 
amountStr) : amountStr
 //            let _ = print(amountStr)
@@ -85,7 +88,7 @@ struct AccountPicker: View {
             ForEach(0..<accountDetails.count, id: \.self, content: { index in
                 let detail = accountDetails[index]
                     if let amount = detail.transferAmount {
-                        let amountStr = amount.formatted(useISO: false)
+                        let amountStr = amount.formatted(isNegative: false, 
useISO: false)
 //            let _ = print(amountStr)
                         if let bankName = detail.bankLabel {
                             Text(bankName + ":   " + amountStr)
@@ -173,8 +176,8 @@ struct ManualDetailsV: View {
                 let account = validDetails[accountID]
                 if let amount = account.transferAmount {
                     let specs = account.currencySpecification
-                    let amountStr = amount.formatted(specs: specs)
-                    let obtainStr = common.amountRaw.formatted()
+                    let amountStr = amount.formatted(specs: specs, isNegative: 
false)
+                    let obtainStr = common.amountRaw.formatted(isNegative: 
false)
 //            let _ = print(amountStr, " | ", obtainStr)
                     if !minimalistic {
                         Text("The Payment Service Provider is waiting for your 
wire-transfer.")
diff --git a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift 
b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
index 8951a92..78ff832 100644
--- a/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
+++ b/TalerWallet1/Views/Transactions/ThreeAmountsV.swift
@@ -1,7 +1,10 @@
 /*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
  * See LICENSE.md
  */
+/**
+ * @author Marc Stibane
+ */
 import SwiftUI
 import taler_swift
 
@@ -101,21 +104,25 @@ struct ThreeAmountsV: View {
             }
             AmountRowV(title: minimalistic ? topAbbrev : topTitle,
                       amount: topAmount,
+                  isNegative: !incoming,
                        color: labelColor,
                        large: false)
                 .padding(.bottom, 4)
             if hasNoFees == false {
                 if let fee {
-                    AmountRowV(title: minimalistic ? String(localized: "Fee 
(short):", defaultValue:"Fee:", comment:"short version")
-                               : String(localized: "Fee (long):", 
defaultValue:"Fee:", comment:"long version"),
-                               amount: fee,
+                    let title = minimalistic ? String(localized: "Exchange fee 
(short):", defaultValue: "Fee:", comment: "short version")
+                                             : String(localized: "Exchange fee 
(long):", defaultValue: "Fee:", comment: "long version")
+                    AmountRowV(title: title,
+                              amount: fee,
+                          isNegative: !incoming,
                                color: labelColor,
                                large: false)
                     .padding(.bottom, 4)
                 }
                 if let bottomAmount {
                     AmountRowV(title: minimalistic ? bottomAbbrev : 
bottomTitle,
-                               amount: bottomAmount,
+                              amount: bottomAmount,
+                          isNegative: !incoming,
                                color: foreColor,
                                large: large)
                 }
diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift 
b/TalerWallet1/Views/Transactions/TransactionRowView.swift
index 316fa84..06ee541 100644
--- a/TalerWallet1/Views/Transactions/TransactionRowView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionRowView.swift
@@ -55,7 +55,7 @@ struct TransactionRowView: View {
         let iconBadge = TransactionIconBadge(type: common.type, foreColor: 
foreColor,
                                              done: done, incoming: incoming,
                                     shouldConfirm: shouldConfirm, needsKYC: 
needsKYC)
-        let amountV = AmountV(common.amountEffective)
+        let amountV = AmountV(common.amountEffective, isNegative: !incoming)
             .foregroundColor(foreColor)
 
         let topString = topString()
@@ -79,7 +79,7 @@ struct TransactionRowView: View {
 #endif
 
         let layout1 = HStack(spacing: 4) {
-                VStack(alignment: .leading) {
+                VStack(alignment: .leading, spacing: 2) {
                     centerTop
                     centerBottom
                 }
@@ -92,11 +92,12 @@ struct TransactionRowView: View {
 
         let layout2 = VStack(alignment: .leading, spacing: 2) {
             centerTop
-            HStack(spacing: 10) {
+            HStack(spacing: 6) {
                 centerBottom
 #if DEBUG
                     .border(green)
 #endif
+                Spacer(minLength: 0)
                 amountV
 #if DEBUG
                     .border(red)
diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift 
b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
index 8e8f306..b140722 100755
--- a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
+++ b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
@@ -349,11 +349,13 @@ struct TransactionSummaryV: View {
                             let input = details.refreshInputAmount
                             AmountRowV(title: minimalistic ? "Refreshed:" : 
"Refreshed amount:",
                                       amount: input,
+                                  isNegative: false,
                                        color: labelColor,
                                        large: true)
                             if let fee = refreshFee(input: input, output: 
details.refreshOutputAmount) {
                                 AmountRowV(title: minimalistic ? "Fee:" : 
"Refreshed fee:",
                                           amount: fee,
+                                      isNegative: !fee.isZero,
                                            color: labelColor,
                                            large: true)
                             }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]