gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 29/35: show up to 3 transactions in Balances


From: gnunet
Subject: [taler-taler-ios] 29/35: show up to 3 transactions in Balances
Date: Thu, 27 Jul 2023 09:10:02 +0200

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 a2f80815c7baf4dcada9b1b68d913978431f36b7
Author: Marc Stibane <marc@taler.net>
AuthorDate: Tue Jul 25 16:35:50 2023 +0200

    show up to 3 transactions in Balances
---
 TalerWallet1/Views/Balances/BalancesListView.swift |  4 ++-
 .../Views/Balances/BalancesSectionView.swift       | 29 +++++++++++++++++++++-
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift 
b/TalerWallet1/Views/Balances/BalancesListView.swift
index d1b31d2..de41025 100644
--- a/TalerWallet1/Views/Balances/BalancesListView.swift
+++ b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -10,7 +10,7 @@ import AVFoundation
 /// This view shows the list of balances / currencies, each in its own section
 
 struct BalancesListView: View {
-    private let symLog = SymLogV(0)
+    private let symLog = SymLogV()
     let navTitle: String
     let hamburgerAction: () -> Void
 
@@ -139,8 +139,10 @@ extension BalancesListView {
             let _ = symLog?.vlog()       // just to get the # to compare it 
with .onAppear & onDisappear
 #endif
             Group { // necessary for .backslide transition (bug in SwiftUI)
+                let count = balances.count
                 List(balances, id: \.self) { balance in
                     BalancesSectionView(balance: balance,
+                                   sectionCount: count,
                                 centsToTransfer: $centsToTransfer,
                                         summary: $summary)
                 }
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift 
b/TalerWallet1/Views/Balances/BalancesSectionView.swift
index 655bb9a..6cf640c 100644
--- a/TalerWallet1/Views/Balances/BalancesSectionView.swift
+++ b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -16,7 +16,8 @@ import SymLog
 
 struct BalancesSectionView: View {
     private let symLog = SymLogV()
-    var balance:Balance
+    let balance: Balance
+    let sectionCount: Int
     @Binding var centsToTransfer: UInt64
     @Binding var summary: String
 
@@ -174,11 +175,36 @@ struct BalancesSectionView: View {
                 transactions = response
                 pendingTransactions = WalletModel.pendingTransactions(response)
                 uncompletedTransactions = 
WalletModel.uncompletedTransactions(response)
+                completedTransactions = 
WalletModel.completedTransactions(response)
                 shownSectionID = sectionID
 //            } else {
 //                symLog.log("task for BalancesSectionView \(sectionID) ❗️ 
skip reloading Transactions")
 //            }
         }
+        let transactionCount = completedTransactions.count
+        if sectionCount == 1 && transactionCount > 0 {
+            let sortedTransactions = completedTransactions.sorted {
+                do {
+                    let first = try $0.common.timestamp.milliseconds()
+                    let second = try $1.common.timestamp.milliseconds()
+                    return first > second
+                } catch {
+                    symLog.log(error)
+                    return false        // should never happen
+                }
+            }
+            Section {
+                let slice = sortedTransactions.prefix(3)
+                let threeTransactions = Array(slice)
+                TransactionsRowsView(symLog: symLog,
+                                     currency: currency,
+                                     transactions: threeTransactions,
+                                     reloadOneAction: reloadOneAction)
+            } header: {
+                Text("Last transactions")
+                    .font(.callout)
+            }
+        }
     } // body
 }
 // MARK: -
@@ -194,6 +220,7 @@ fileprivate struct BindingViewContainer : View {
                       requiresUserInput: false,
                  hasPendingTransactions: true)
         BalancesSectionView(balance: balance,
+                       sectionCount: 2,
                     centsToTransfer: $centsToTransfer,
                             summary: $summary)
     }

-- 
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]