TalDirSettingsView.swift (5598B)
1 /* 2 * This file is part of GNU Taler, ©2022-26 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 struct TalDirSettingsView: View { 13 private let symLog = SymLogV(0) 14 let stack: CallStack 15 let navTitle: String 16 17 @EnvironmentObject private var controller: Controller 18 @EnvironmentObject private var model: WalletModel 19 // @Environment(\.colorSchemeContrast) private var colorSchemeContrast 20 #if DEBUG 21 @AppStorage("developerMode") var developerMode: Bool = true 22 #else 23 @AppStorage("developerMode") var developerMode: Bool = false 24 #endif 25 @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic 26 @AppStorage("acceptAutomatically") var acceptAutomatically: Bool = false 27 @AppStorage("deleteAutomatically") var deleteAutomatically: Bool = false 28 // @AppStorage("minimalistic") var minimalistic: Bool = false 29 30 var body: some View { 31 #if PRINT_CHANGES 32 let _ = Self._printChanges() 33 let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear 34 #endif 35 let list = List { 36 Section { 37 let contacts = "contacts" 38 let contactsDest = ContactsView(stack: stack.push(contacts), talerURI: nil, subject: nil) 39 NavigationLink { 40 contactsDest 41 } label: { 42 SettingsItem(name: contactsDest.navTitle, id1: contacts, 43 imageName: ICONNAME_PERSON3, // 44 description: String(localized: "Manage contact information")) {} 45 } 46 } // contacts 47 if let configuration = controller.mailboxConfiguration { 48 Section { 49 let mailboxTitle = String(localized: "TitleMailbox", defaultValue: "Mailbox") 50 let mailboxDest = MailboxView(stack: stack.push(mailboxTitle), 51 navTitle: mailboxTitle) 52 NavigationLink { 53 mailboxDest 54 } label: { 55 SettingsItem(name: mailboxTitle, id1: "mailbox", 56 imageName: ICONNAME_MAILBOX, // 57 description: String(localized: "P2P Messaging")) {} 58 }.listRowSeparator(.hidden) 59 #if TALDIR2 60 SettingsToggle(name: String(localized: "Automatically accept"), 61 value: $acceptAutomatically, 62 id1: "acceptAutomatically", 63 description: String(localized: "...incoming payments, skip confirmation") 64 ).listRowSeparator(.hidden) 65 SettingsToggle(name: String(localized: "Automatically delete"), 66 value: $deleteAutomatically, 67 id1: "deleteAutomatically", 68 description: String(localized: "...messages after the transaction finishes") 69 ) 70 #endif 71 let aliasTitle = String(localized: "TitleAlias", defaultValue: "Alias Registration") 72 let aliasDest = AliasView(stack: stack.push(aliasTitle), 73 navTitle: aliasTitle) 74 NavigationLink { 75 aliasDest 76 } label: { 77 SettingsItem(name: aliasTitle, id1: "alias", 78 imageName: ICONNAME_ALIAS, // 79 description: String(localized: "Taldir Registration")) {} 80 } 81 82 } 83 } else { 84 Text("If you only want to send money (or payment requests) to others you don't need a mailbox.") 85 .listRowSeparator(.hidden) 86 let contactsIcon = Image(systemName: ICONNAME_PERSON3) // 87 Text("Just add contacts, e.g. by scanning a QR code. Send as usual, then in the final step choose '\(contactsIcon)\(NONBREAKING)Contacts'.", comment: "contactsIcon, NONBREAKING - don't add a space") 88 .padding(.top, -4) 89 .padding(.bottom, 6) 90 .listRowSeparator(.visible) 91 Text("You need a mailbox to be able to receive money (or requests) that other people send to your mail address or phone number.") 92 .padding(.top, 6) 93 .listRowSeparator(.hidden) 94 Text("Once you have a mailbox, create one or more Aliases (of your mail address, phone number, matrix ID, ...) and publish them on your website, GitHub page, on Mastodon or any other place.") 95 .listRowSeparator(.hidden) 96 Button("Create Mailbox") { 97 Task { 98 await controller.createMailbox() 99 } 100 }.buttonStyle(TalerButtonStyle(type: .bordered)) 101 .padding() 102 .listRowSeparator(.hidden) 103 Text("Your mailbox will be hosted at gnunet.org. Currently there is no fee.") 104 } 105 } 106 .listStyle(myListStyle.style).anyView 107 .navigationTitle(navTitle) 108 .onAppear() { 109 DebugViewC.shared.setViewID(VIEW_SETTINGS4, stack: stack.push()) 110 } 111 if #available(iOS 26.0, *) { 112 list 113 } else { 114 list 115 .padding(.bottom) 116 } 117 } // body 118 }