ReportView.swift (2357B)
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 } 37 } 38 39 var body: some View { 40 #if PRINT_CHANGES 41 let _ = Self._printChanges() 42 let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear 43 #endif 44 let buttonTitle = String(localized: "Create Report", comment: "button") 45 46 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.") 47 48 List { 49 Section { 50 if report.isEmpty { 51 reportHint 52 Button(buttonTitle) { createReport() } 53 .buttonStyle(TalerButtonStyle(type: .bordered, disabled: creating)) 54 .padding() 55 } else { 56 Text(report) 57 .multilineTextAlignment(.leading) 58 .lineLimit(expanded ? nil : 3) 59 .onTapGesture { 60 expanded.toggle() 61 } 62 CopyShare(textToCopy: report, image: nil) 63 } 64 } 65 .listRowSeparator(.hidden) 66 } 67 .listStyle(myListStyle.style).anyView 68 .navigationTitle(navTitle) 69 .onAppear() { 70 DebugViewC.shared.setViewID(VIEW_BANK_ACCOUNTS, stack: stack.push()) 71 } 72 } // body 73 }