taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

BalancesDialogRowV.swift (3289B)


      1 /*
      2  * This file is part of GNU Taler, ©2022-25 Taler Systems S.A.
      3  * See LICENSE.md
      4  */
      5 /**
      6  * @author Marc Stibane
      7  */
      8 import SwiftUI
      9 import taler_swift
     10 //import SymLog
     11 
     12 struct BalancesDialogRowV: View {
     13 //    let symLog: SymLogV?            // inherited from BalancesSectionView
     14     let stack: CallStack
     15     let balance: Balance
     16     @Binding var selectedBalance: Balance?          // <- return here the balance when we go to Transactions
     17     @Binding var scannedTransactions: [TalerTransaction]
     18     let reloadScanned: (_ stack: CallStack) async -> ()
     19 
     20     @AppStorage("oimEuro") var oimEuro: Bool = false
     21 
     22     @ViewBuilder func pendingRowLabel() -> some View {
     23 
     24         VStack(spacing: 6) {
     25                 Text("Scanned transactions")
     26                     .talerFont(.body)
     27         }
     28         .accessibilityElement(children: .combine)
     29         .accessibilityHint(String(localized: "Will go to Scanned transactions.", comment: "a11y"))
     30     }
     31 
     32     var body: some View {
     33             let destination = TransactionsListView(stack: stack.push(),
     34                                                    scope: balance.scopeInfo,
     35                                                  balance: balance,
     36                                          selectedBalance: $selectedBalance,     // set in there
     37                                                 navTitle: String(localized: "Scanned", comment: "ViewTitle of TransactionList"),
     38                                                  oimEuro: oimEuro,
     39                                             transactions: $scannedTransactions,
     40                                          reloadAllAction: reloadScanned)
     41             NavigationLink(destination: destination) { pendingRowLabel() }
     42             //let _ = print("button: Pending Transactions: \(currency)")
     43     } // body
     44 } // BalancesDialogRowV
     45 
     46 // MARK: -
     47 #if DEBUG
     48 fileprivate struct BalancesDialogRowV_Previews: PreviewProvider {
     49     @MainActor
     50     struct BindingViewContainer: View {
     51         @State private var previewTransactions: [TalerTransaction] = []
     52         @State private var previewD: CurrencyInfo = CurrencyInfo.zero(DEMOCURRENCY)
     53         @State private var selectedPreviewBalance: Balance? = nil
     54         var body: some View {
     55             let flags: [BalanceFlag] = [.incomingConfirmation]
     56 
     57             let scopeInfo = ScopeInfo(type: ScopeInfo.ScopeInfoType.exchange, currency: DEMOCURRENCY, url: DEMOEXCHANGE)
     58             let balance = Balance(scopeInfo: scopeInfo,
     59                                   available: Amount(currency: DEMOCURRENCY, cent:1000),
     60                             pendingIncoming: Amount(currency: DEMOCURRENCY, cent: 555),
     61                             pendingOutgoing: Amount(currency: DEMOCURRENCY, cent: 333),
     62                                       flags: flags)
     63             BalancesDialogRowV(//symLog: nil,
     64                                  stack: CallStack("Preview"),
     65                                balance: balance,
     66                        selectedBalance: $selectedPreviewBalance,
     67                    scannedTransactions: $previewTransactions,
     68                          reloadScanned: {stack in })
     69         }
     70     }
     71 
     72     @MainActor
     73     static var previews: some View {
     74         List {
     75             Section {
     76                 BindingViewContainer()
     77             }
     78         }
     79     }
     80 }
     81 #endif