ToSButtonView.swift (1905B)
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 let destination = WithdrawTOSView(stack: stack.push(), 29 exchangeBaseUrl: exchangeBaseUrl, 30 viewID: viewID, 31 acceptAction: acceptAction) // pop back to here 32 NavigationLink(destination: destination) { 33 Text("Terms of Service") // VIEW_WITHDRAW_TOS 34 }.buttonStyle(TalerButtonStyle(type: .prominent)) 35 .padding(.horizontal) 36 #if false 37 let title = "getPerformanceStats" 38 Button(title) { 39 Task { 40 try? await model.getPerformanceStats() 41 } 42 } 43 #endif 44 } 45 } 46 47 #Preview { 48 ToSButtonView(stack: CallStack("Preview"), exchangeBaseUrl: nil, viewID: 0, p2p: false, acceptAction: nil) 49 }