ReportView.swift (2420B)
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 //let BACKUP = "Taler-" 13 //let PREFIX = "file://" 14 15 /// This view shows the list of backups 16 struct ReportView: View { 17 private let symLog = SymLogV(0) 18 let stack: CallStack 19 let navTitle: String 20 21 @EnvironmentObject private var model: WalletModel 22 @EnvironmentObject private var controller: Controller 23 @AppStorage("minimalistic") var minimalistic: Bool = false 24 @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic 25 26 @State private var creating: Bool = false 27 @State private var report: String = EMPTYSTRING 28 @State private var expanded: Bool = false 29 30 private func createReport() { 31 creating = true 32 Task { 33 if let diagnostics = try? await model.getDiagnostics() { 34 report = diagnostics 35 } 36 creating = false 37 } 38 } 39 40 var body: some View { 41 #if PRINT_CHANGES 42 let _ = Self._printChanges() 43 let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear 44 #endif 45 let buttonTitle = String(localized: "Create Report", comment: "button") 46 47 let reportHint = Text("Tap 'Create Report' to build a report of your wallet's state, to help improve Taler...\nThis report will not enable the receiver to access your money.") 48 49 List { 50 Section { 51 if report.isEmpty { 52 reportHint 53 Button(buttonTitle) { createReport() } 54 .buttonStyle(TalerButtonStyle(type: .bordered, disabled: creating)) 55 .disabled(creating) 56 .padding() 57 } else { 58 Text(report) 59 .multilineTextAlignment(.leading) 60 .lineLimit(expanded ? nil : 3) 61 .onTapGesture { 62 expanded.toggle() 63 } 64 CopyShare(stack.push(), report) 65 } 66 } 67 .listRowSeparator(.hidden) 68 } 69 .listStyle(myListStyle.style).anyView 70 .navigationTitle(navTitle) 71 .onAppear() { 72 DebugViewC.shared.setViewID(VIEW_BANK_ACCOUNTS, stack: stack.push()) 73 } 74 } // body 75 }