WalletEmptyView.swift (3700B)
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 SymLog 10 import taler_swift 11 12 /// This view shows hints if a wallet is empty 13 /// It is the very first thing the user sees after installing the app 14 15 struct WalletEmptyView: View { 16 private let symLog = SymLogV(0) 17 let stack: CallStack 18 19 @Environment(\.colorScheme) private var colorScheme 20 @Environment(\.colorSchemeContrast) private var colorSchemeContrast 21 @EnvironmentObject private var model: WalletModel 22 @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic 23 @State private var withDrawStarted = false 24 25 var body: some View { 26 let list = List { 27 #if false // EMPTY 28 Section { 29 Text("There is no digital cash in your wallet yet.") 30 .talerFont(.title3) 31 } 32 #endif 33 Section { 34 let qrButton = Image(systemName: QRBUTTON) // "qrcode.viewfinder" 35 let settings = Image(systemName: SETTINGS) // "gear" 36 Text("Use «\(qrButton) Scan QR code» in the Actions menu to start a withdrawal if your bank already supports Taler payments.", comment: "« » 'qrcode.viewfinder'") 37 .talerFont(.body) 38 .listRowSeparator(.hidden) 39 Text("You can also add a payment service manually in the \(settings) Settings tab.", comment: "« » 'gear'") 40 .talerFont(.body) 41 } header: { 42 let firstHeader = String(localized: "Withdraw digital cash", comment: "section header") 43 Text(firstHeader) 44 .talerFont(.title3) 45 .foregroundColor(WalletColors().secondary(colorScheme, colorSchemeContrast)) 46 } 47 Section { 48 Text("Get digital cash to experience how to pay with the money of the future.") 49 .talerFont(.body) 50 .listRowSeparator(.hidden) 51 let title = String(localized: "LinkTitle_Test_Money", defaultValue: "Get demo money") 52 Button(title) { 53 withDrawStarted = true // don't run twice 54 Task { // runs on MainActor 55 let amount = Amount(currency: DEMOCURRENCY, cent: 2500) 56 symLog.log("Withdraw KUDOS") 57 try? await model.loadTestKudos(0, amount: amount) 58 } 59 } 60 .buttonStyle(TalerButtonStyle(type: .prominent, narrow: false, disabled: withDrawStarted, aligned: .center)) 61 .disabled(withDrawStarted) 62 } header: { 63 let secondHeader = String(localized: "Demo", comment: "section header") 64 Text(secondHeader) 65 .talerFont(.title3) 66 .foregroundColor(WalletColors().secondary(colorScheme, colorSchemeContrast)) 67 } 68 } 69 .listStyle(myListStyle.style).anyView 70 .talerFont(.title2) 71 .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) 72 ZStack { 73 list 74 if withDrawStarted { 75 RotatingTaler(size: 150, progress: true, rotationEnabled: $withDrawStarted) 76 } 77 } 78 .onAppear() { 79 DebugViewC.shared.setViewID(VIEW_EMPTY_WALLET, stack: stack.push("onAppear")) // 10 80 } 81 } 82 } 83 84 struct WalletEmptyView_Previews: PreviewProvider { 85 static var previews: some View { 86 WalletEmptyView(stack: CallStack("Preview")) 87 } 88 }