ToSButtonView.swift (2024B)
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 10 struct ToSButtonView: View { 11 let stack: CallStack 12 let exchangeBaseUrl: String? 13 let viewID: Int // either VIEW_WITHDRAW_TOS or SHEET_WITHDRAW_TOS 14 let p2p: Bool 15 let acceptAction: (() async -> Void)? 16 17 @EnvironmentObject private var model: WalletModel 18 @AppStorage("minimalistic") var minimalistic: Bool = false 19 20 var body: some View { 21 let hint = minimalistic ? String(localized: "You must first accept the payment service's terms of service.") 22 : p2p ? String(localized: "You must first accept the payment service's terms of service before you can receive digital cash in your wallet.", comment: "P2P Receive") 23 : String(localized: "You must first accept the payment service's terms of service before you can withdraw digital cash to your wallet.") 24 Text(hint) 25 .talerFont(.body) 26 .multilineTextAlignment(.leading) 27 .padding() 28 if let exchangeBaseUrl { 29 Text(exchangeBaseUrl.trimURL) 30 .talerFont(.body) 31 } 32 let destination = WithdrawTOSView(stack: stack.push(), 33 exchangeBaseUrl: exchangeBaseUrl, 34 viewID: viewID, 35 acceptAction: acceptAction) // pop back to here 36 NavigationLink(destination: destination) { 37 Text("Terms of Service") // VIEW_WITHDRAW_TOS 38 }.buttonStyle(TalerButtonStyle(type: .prominent)) 39 .padding(.horizontal) 40 #if false 41 let title = "getPerformanceStats" 42 Button(title) { 43 Task { 44 try? await model.getPerformanceStats() 45 } 46 } 47 #endif 48 } 49 } 50 51 #Preview { 52 ToSButtonView(stack: CallStack("Preview"), exchangeBaseUrl: nil, viewID: 0, p2p: false, acceptAction: nil) 53 }