ToSButtonView.swift (2036B)
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 shouldDismiss: Bool 15 let p2p: Bool 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 shouldDismiss: shouldDismiss, 35 viewID: viewID) 36 NavigationLink(destination: destination) { 37 Text("Terms of Service") // VIEW_WITHDRAW_TOS 38 }.buttonStyle(TalerButtonStyle(type: .prominent)) 39 .padding(.horizontal) 40 .accessibilityIdentifier(A11yID.tosOpenButton) 41 #if false 42 let title = "getPerformanceStats" 43 Button(title) { 44 Task { 45 try? await model.getPerformanceStats() 46 } 47 } 48 #endif 49 } 50 } 51 52 #Preview { 53 ToSButtonView(stack: CallStack("Preview"), exchangeBaseUrl: nil, viewID: 0, shouldDismiss: false, p2p: false) 54 }