commit e0dc7958786cae4af9aefacde793be301f0ed0de
parent 7950b99b7db92b47074c0fd9fc12fcb829d94c2d
Author: Marc Stibane <marc@taler.net>
Date: Sun, 12 Nov 2023 12:51:38 +0100
RequestPurpose
Diffstat:
4 files changed, 118 insertions(+), 118 deletions(-)
diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj
@@ -67,7 +67,7 @@
4E3EAE472A990778009F1BE8 /* QuiteSomeCoins.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBA82AC2A3F580500E5F39A /* QuiteSomeCoins.swift */; };
4E3EAE482A990778009F1BE8 /* PayTemplateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBA56402A7FF5200084948B /* PayTemplateView.swift */; };
4E3EAE492A990778009F1BE8 /* ManualWithdrawDone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB431662A1E55C700C5690E /* ManualWithdrawDone.swift */; };
- 4E3EAE4A2A990778009F1BE8 /* PaymentPurpose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E9320462A164BC700A87B0E /* PaymentPurpose.swift */; };
+ 4E3EAE4A2A990778009F1BE8 /* RequestPurpose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E9320462A164BC700A87B0E /* RequestPurpose.swift */; };
4E3EAE4B2A990778009F1BE8 /* ShareSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E753A072A0B6A5F002D9328 /* ShareSheet.swift */; };
4E3EAE4C2A990778009F1BE8 /* AmountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095492989CBFE0043A8A1 /* AmountView.swift */; };
4E3EAE4D2A990778009F1BE8 /* P2pAcceptDone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E3B4BC22A42252300CC88B8 /* P2pAcceptDone.swift */; };
@@ -167,7 +167,7 @@
4E8E25332A1CD39700A27BFA /* EqualIconWidthDomain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E8E25322A1CD39700A27BFA /* EqualIconWidthDomain.swift */; };
4E9320432A14F6EA00A87B0E /* WalletColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E9320422A14F6EA00A87B0E /* WalletColors.swift */; };
4E9320452A1645B600A87B0E /* RequestPayment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E9320442A1645B600A87B0E /* RequestPayment.swift */; };
- 4E9320472A164BC700A87B0E /* PaymentPurpose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E9320462A164BC700A87B0E /* PaymentPurpose.swift */; };
+ 4E9320472A164BC700A87B0E /* RequestPurpose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E9320462A164BC700A87B0E /* RequestPurpose.swift */; };
4E9796902A3765ED006F73BC /* AgePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E97968F2A3765ED006F73BC /* AgePicker.swift */; };
4E983C292ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E983C282ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift */; };
4E983C2A2ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E983C282ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift */; };
@@ -344,7 +344,7 @@
4E8E25322A1CD39700A27BFA /* EqualIconWidthDomain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EqualIconWidthDomain.swift; sourceTree = "<group>"; };
4E9320422A14F6EA00A87B0E /* WalletColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletColors.swift; sourceTree = "<group>"; };
4E9320442A1645B600A87B0E /* RequestPayment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestPayment.swift; sourceTree = "<group>"; };
- 4E9320462A164BC700A87B0E /* PaymentPurpose.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaymentPurpose.swift; sourceTree = "<group>"; };
+ 4E9320462A164BC700A87B0E /* RequestPurpose.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestPurpose.swift; sourceTree = "<group>"; };
4E97968F2A3765ED006F73BC /* AgePicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AgePicker.swift; sourceTree = "<group>"; };
4E983C282ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleAxisGeometryReader.swift; sourceTree = "<group>"; };
4E983C2B2ADC416800FA9CC5 /* View+fitsSideBySide.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "View+fitsSideBySide.swift"; sourceTree = "<group>"; };
@@ -775,7 +775,7 @@
4E7940DD29FC307C00A9AEA1 /* SendPurpose.swift */,
4EB3136029FEE79B007D68BC /* SendDoneV.swift */,
4E9320442A1645B600A87B0E /* RequestPayment.swift */,
- 4E9320462A164BC700A87B0E /* PaymentPurpose.swift */,
+ 4E9320462A164BC700A87B0E /* RequestPurpose.swift */,
);
path = Peer2peer;
sourceTree = "<group>";
@@ -1090,7 +1090,7 @@
4E3EAE472A990778009F1BE8 /* QuiteSomeCoins.swift in Sources */,
4E3EAE482A990778009F1BE8 /* PayTemplateView.swift in Sources */,
4E3EAE492A990778009F1BE8 /* ManualWithdrawDone.swift in Sources */,
- 4E3EAE4A2A990778009F1BE8 /* PaymentPurpose.swift in Sources */,
+ 4E3EAE4A2A990778009F1BE8 /* RequestPurpose.swift in Sources */,
4E3EAE4B2A990778009F1BE8 /* ShareSheet.swift in Sources */,
4EC4008F2AE8019700DF72C7 /* ExchangeRowView.swift in Sources */,
4E3EAE4C2A990778009F1BE8 /* AmountView.swift in Sources */,
@@ -1199,7 +1199,7 @@
4EBA82AD2A3F580500E5F39A /* QuiteSomeCoins.swift in Sources */,
4EBA56412A7FF5200084948B /* PayTemplateView.swift in Sources */,
4EB431672A1E55C700C5690E /* ManualWithdrawDone.swift in Sources */,
- 4E9320472A164BC700A87B0E /* PaymentPurpose.swift in Sources */,
+ 4E9320472A164BC700A87B0E /* RequestPurpose.swift in Sources */,
4E753A082A0B6A5F002D9328 /* ShareSheet.swift in Sources */,
4EC400902AE8019700DF72C7 /* ExchangeRowView.swift in Sources */,
4EB0956C2989CBFE0043A8A1 /* AmountView.swift in Sources */,
diff --git a/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift b/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift
@@ -1,111 +0,0 @@
-/*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
- * See LICENSE.md
- */
-import SwiftUI
-import taler_swift
-import SymLog
-
-struct PaymentPurpose: View {
- private let symLog = SymLogV(0)
- let stack: CallStack
-
- let scopeInfo: ScopeInfo
- let centsToTransfer: UInt64
- let fee: String
- @Binding var summary: String
- @Binding var expireDays: UInt
- @AppStorage("iconOnly") var iconOnly: Bool = false
- let navTitle = String(localized: "NavTitle_Request_Subject", defaultValue: "Request", comment: "NavTitle for entering the subject for Request-Payment")
-
- @State private var transactionStarted: Bool = false
- @FocusState private var isFocused: Bool
-
- private var label: String {
-// let mag = pow(10, formatter.maximumFractionDigits)
-// return formatter.string(for: Decimal(centsToTransfer) / mag) ?? ""
- return String(centsToTransfer / 100) // TODO: based on currency
- }
-
- var body: some View {
- let amount = Amount.amountFromCents(scopeInfo.currency, centsToTransfer)
-
- VStack (spacing: 6) {
- Text(amount.readableDescription)
- Text("+ \(fee) payment fee")
- .foregroundColor(.red)
- VStack(alignment: .leading, spacing: 6) {
- if !iconOnly {
- Text("Subject:")
- .accessibilityFont(.title3)
- .padding(.top)
- }
- TextField("Subject", text: $summary)
- .accessibilityFont(.title)
- .foregroundColor(WalletColors().fieldForeground) // text color
- .background(WalletColors().fieldBackground)
- .textFieldStyle(.roundedBorder)
- .focused($isFocused)
- .onAppear {
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
- isFocused = true // make first responder - raise keybord
- }
- }
-
- HStack{
- Spacer()
- Text(verbatim: "\(summary.count)/100")
- } // maximum 100 characters
-
- SelectDays(selected: $expireDays, maxExpiration: THIRTYDAYS)
- .disabled(false)
- .padding(.bottom)
-
- let disabled = (expireDays == 0) || (summary.count < 1)
- NavigationLink(destination: LazyView {
- SendDoneV(stack: stack.push(),
- amountToSend: nil,
- amountToReceive: amount,
- summary: summary,
- expireDays: expireDays,
- transactionStarted: $transactionStarted)
- }) {
- Text("Request \(label) \(scopeInfo.currency)")
-// .accessibilityFont(buttonFont)
- }
- .buttonStyle(TalerButtonStyle(type: .prominent))
- .disabled(disabled)
- .accessibilityHint(disabled ? "enabled when subject and expiration are set" : EMPTYSTRING)
-
- Spacer()
- }
- .frame(maxWidth: .infinity, alignment: .leading)
- .padding(.horizontal)
- }
- .navigationTitle(navTitle)
- .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
- .onAppear {
- DebugViewC.shared.setViewID(VIEW_REQUEST_PURPOSE, stack: stack.push())
-// print("❗️ PaymentPurpose onAppear")
- }
- .onDisappear {
-// print("❗️ PaymentPurpose onDisappear")
- }
- }
-
-}
-// MARK: -
-#if DEBUG
-//struct PaymentPurpose_Previews: PreviewProvider {
-// static var previews: some View {
-// let scopeInfo = ScopeInfo(type: ScopeInfo.ScopeInfoType.exchange, exchangeBaseUrl: DEMOEXCHANGE, currency: LONGCURRENCY)
-// @State var summary: String = "pUrPoSe"
-// @State var expireDays: UInt = 0
-// PaymentPurpose(scopeInfo: scopeInfo,
-// centsToTransfer: 5,
-// fee: "fee",
-// summary: $summary,
-// expireDays: $expireDays)
-// }
-//}
-#endif
diff --git a/TalerWallet1/Views/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Peer2peer/RequestPayment.swift
@@ -41,7 +41,7 @@ struct RequestPayment: View {
let disabled = (centsToTransfer == 0) || someCoins.invalid || someCoins.tooMany
NavigationLink(destination: LazyView {
- PaymentPurpose(stack: stack.push(),
+ RequestPurpose(stack: stack.push(),
scopeInfo: scopeInfo,
centsToTransfer: centsToTransfer,
fee: someCoins.fee,
diff --git a/TalerWallet1/Views/Peer2peer/RequestPurpose.swift b/TalerWallet1/Views/Peer2peer/RequestPurpose.swift
@@ -0,0 +1,111 @@
+/*
+ * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * See LICENSE.md
+ */
+import SwiftUI
+import taler_swift
+import SymLog
+
+struct RequestPurpose: View {
+ private let symLog = SymLogV(0)
+ let stack: CallStack
+
+ let scopeInfo: ScopeInfo
+ let centsToTransfer: UInt64
+ let fee: String
+ @Binding var summary: String
+ @Binding var expireDays: UInt
+ @AppStorage("iconOnly") var iconOnly: Bool = false
+ let navTitle = String(localized: "NavTitle_Request_Subject", defaultValue: "Request", comment: "NavTitle for entering the subject for Request-Payment")
+
+ @State private var transactionStarted: Bool = false
+ @FocusState private var isFocused: Bool
+
+ private var label: String {
+// let mag = pow(10, formatter.maximumFractionDigits)
+// return formatter.string(for: Decimal(centsToTransfer) / mag) ?? ""
+ return String(centsToTransfer / 100) // TODO: based on currency
+ }
+
+ var body: some View {
+ let amount = Amount.amountFromCents(scopeInfo.currency, centsToTransfer)
+
+ VStack (spacing: 6) {
+ Text(amount.readableDescription)
+ Text("+ \(fee) payment fee")
+ .foregroundColor(.red)
+ VStack(alignment: .leading, spacing: 6) {
+ if !iconOnly {
+ Text("Subject:")
+ .accessibilityFont(.title3)
+ .padding(.top)
+ }
+ TextField("Subject", text: $summary)
+ .accessibilityFont(.title)
+ .foregroundColor(WalletColors().fieldForeground) // text color
+ .background(WalletColors().fieldBackground)
+ .textFieldStyle(.roundedBorder)
+ .focused($isFocused)
+ .onAppear {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
+ isFocused = true // make first responder - raise keybord
+ }
+ }
+
+ HStack{
+ Spacer()
+ Text(verbatim: "\(summary.count)/100")
+ } // maximum 100 characters
+
+ SelectDays(selected: $expireDays, maxExpiration: THIRTYDAYS)
+ .disabled(false)
+ .padding(.bottom)
+
+ let disabled = (expireDays == 0) || (summary.count < 1)
+ NavigationLink(destination: LazyView {
+ SendDoneV(stack: stack.push(),
+ amountToSend: nil,
+ amountToReceive: amount,
+ summary: summary,
+ expireDays: expireDays,
+ transactionStarted: $transactionStarted)
+ }) {
+ Text("Request \(label) \(scopeInfo.currency)")
+// .accessibilityFont(buttonFont)
+ }
+ .buttonStyle(TalerButtonStyle(type: .prominent))
+ .disabled(disabled)
+ .accessibilityHint(disabled ? "enabled when subject and expiration are set" : EMPTYSTRING)
+
+ Spacer()
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.horizontal)
+ }
+ .navigationTitle(navTitle)
+ .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
+ .onAppear {
+ DebugViewC.shared.setViewID(VIEW_REQUEST_PURPOSE, stack: stack.push())
+// print("❗️ PaymentPurpose onAppear")
+ }
+ .onDisappear {
+// print("❗️ PaymentPurpose onDisappear")
+ }
+ }
+
+}
+// MARK: -
+#if DEBUG
+//struct PaymentPurpose_Previews: PreviewProvider {
+// static var previews: some View {
+// let scopeInfo = ScopeInfo(type: ScopeInfo.ScopeInfoType.exchange, exchangeBaseUrl: DEMOEXCHANGE, currency: LONGCURRENCY)
+// @State var summary: String = "pUrPoSe"
+// @State var expireDays: UInt = 0
+// PaymentPurpose(scopeInfo: scopeInfo,
+// centsToTransfer: 5,
+// fee: "fee",
+// summary: $summary,
+// expireDays: $expireDays)
+// }
+//}
+#endif