gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 67/204: Simplify


From: gnunet
Subject: [taler-taler-ios] 67/204: Simplify
Date: Thu, 05 Dec 2024 23:50:35 +0100

This is an automated email from the git hooks/post-receive script.

marc-stibane pushed a commit to branch master
in repository taler-ios.

commit 1e4fc8b8456e4d8ff5484b2e1f154901c065691f
Author: Marc Stibane <marc@taler.net>
AuthorDate: Tue Oct 15 10:56:49 2024 +0200

    Simplify
---
 TalerWallet1/Views/Actions/DepositWithdrawV.swift | 15 +++---------
 TalerWallet1/Views/Actions/SendRequestV.swift     | 15 +++---------
 TalerWallet1/Views/Actions/TwoRowButtons.swift    | 30 +++++++++++++++--------
 3 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/TalerWallet1/Views/Actions/DepositWithdrawV.swift 
b/TalerWallet1/Views/Actions/DepositWithdrawV.swift
index c8af0bb..0b461d1 100644
--- a/TalerWallet1/Views/Actions/DepositWithdrawV.swift
+++ b/TalerWallet1/Views/Actions/DepositWithdrawV.swift
@@ -6,19 +6,10 @@
  * @author Marc Stibane
  */
 import SwiftUI
-import taler_swift
-import SymLog
 
 struct DepositWithdrawV: View {
-    private let symLog = SymLogV(0)
     let stack: CallStack
-    let sendDisabled: Bool          // can't send/deposit if wallet has no 
coins
-
-    @MainActor
-    func dismissAndPost(_ name: NSNotification.Name) {
-        dismissTop(stack.push())
-        NotificationCenter.default.post(name: name, object: nil)              
// will trigger NavigationLink
-    }
+    let sendDisabled: Bool   // can't send/deposit if wallet has no coins at 
all
 
     var body: some View {
         let depositTitle = String(localized: "DepositButton_Short", 
defaultValue: "Deposit",
@@ -33,7 +24,7 @@ struct DepositWithdrawV: View {
                    recvType: .withdrawal,
                    recvA11y: withdrawTitle,
                sendDisabled: sendDisabled,
-                 sendAction: { dismissAndPost(.DepositAction) },
-                 recvAction: { dismissAndPost(.WithdrawAction) })
+                 sendAction: .DepositAction,
+                 recvAction: .WithdrawAction)
     }
 }
diff --git a/TalerWallet1/Views/Actions/SendRequestV.swift 
b/TalerWallet1/Views/Actions/SendRequestV.swift
index 258ae49..b64ca70 100644
--- a/TalerWallet1/Views/Actions/SendRequestV.swift
+++ b/TalerWallet1/Views/Actions/SendRequestV.swift
@@ -6,19 +6,10 @@
  * @author Marc Stibane
  */
 import SwiftUI
-import taler_swift
-import SymLog
 
 struct SendRequestV: View {
-    private let symLog = SymLogV(0)
     let stack: CallStack
-    let sendDisabled: Bool          // can't send/deposit if wallet has no 
coins
-
-    @MainActor
-    func dismissAndPost(_ name: NSNotification.Name) {
-        dismissTop(stack.push())
-        NotificationCenter.default.post(name: name, object: nil)              
// will trigger NavigationLink
-    }
+    let sendDisabled: Bool   // can't send/deposit if wallet has no coins at 
all
 
     var body: some View {
         let sendTitle = String(localized: "SendButton_Short", defaultValue: 
"Send",
@@ -33,7 +24,7 @@ struct SendRequestV: View {
                    recvType: .peerPullCredit,
                    recvA11y: requTitle,
                sendDisabled: sendDisabled,
-                 sendAction: { dismissAndPost(.SendAction) },
-                 recvAction: { dismissAndPost(.RequestAction) })
+                 sendAction: .SendAction,
+                 recvAction: .RequestAction)
     }
 }
diff --git a/TalerWallet1/Views/Actions/TwoRowButtons.swift 
b/TalerWallet1/Views/Actions/TwoRowButtons.swift
index 0bc7ac2..de19edb 100644
--- a/TalerWallet1/Views/Actions/TwoRowButtons.swift
+++ b/TalerWallet1/Views/Actions/TwoRowButtons.swift
@@ -11,14 +11,21 @@ import taler_swift
 let LINELIMIT = 5
 
 struct TypeButton: View {
+    let stack: CallStack
     let title: String
     let a11y: String
     var type: TransactionType
     let disabled: Bool
-    let action: () -> Void
+    let action: NSNotification.Name
 
     @AppStorage("minimalistic") var minimalistic: Bool = false
 
+    @MainActor
+    func dismissAndPost() {
+        dismissTop(stack.push())
+        NotificationCenter.default.post(name: action, object: nil)             
   // will trigger NavigationLink
+    }
+
     var body: some View {
 #if DEBUG
         let debug = 1==0
@@ -68,7 +75,7 @@ struct TypeButton: View {
             .border(red)
 #endif
 
-        Button(action: action) {
+        Button(action: dismissAndPost) {
             if minimalistic {
                 badge
             } else {
@@ -89,8 +96,7 @@ struct TypeButton: View {
                                    aligned: .center))
     }
 }
-
-
+// MARK: -
 struct TwoRowButtons: View {
     let stack: CallStack
     let sendTitle: String
@@ -100,11 +106,12 @@ struct TwoRowButtons: View {
     var recvType: TransactionType
     let recvA11y: String
     let sendDisabled: Bool
-    let sendAction: () -> Void
-    let recvAction: () -> Void
+    let sendAction: NSNotification.Name
+    let recvAction: NSNotification.Name
 
     func sendButton(_ title: String) -> TypeButton {
-        TypeButton(title: title,
+        TypeButton(stack: stack.push(),
+                   title: title,
                     a11y: sendA11y,
                     type: sendType,
                 disabled: sendDisabled,
@@ -112,7 +119,8 @@ struct TwoRowButtons: View {
     }
 
     func recvButton(_ title: String) -> TypeButton {
-        TypeButton(title: title,
+        TypeButton(stack: stack.push(),
+                   title: title,
                     a11y: recvA11y,
                     type: recvType,
                 disabled: false,
@@ -154,7 +162,8 @@ struct TwoRowButtons_Previews: PreviewProvider {
                        recvType: .peerPullCredit,
                        recvA11y: "Request " + LONGCURRENCY,
                    sendDisabled: true,
-                     sendAction: {}, recvAction: {})
+                     sendAction: .SendAction,
+                     recvAction: .RequestAction)
                 .listRowSeparator(.hidden)
             TwoRowButtons(stack: CallStack("Preview"),
                       sendTitle: "Send " + DEMOCURRENCY,
@@ -164,7 +173,8 @@ struct TwoRowButtons_Previews: PreviewProvider {
                        recvType: .peerPullCredit,
                        recvA11y: "Request " + DEMOCURRENCY,
                    sendDisabled: true,
-                     sendAction: {}, recvAction: {})
+                     sendAction: .SendAction,
+                     recvAction: .RequestAction)
                 .listRowSeparator(.hidden)
         }
     }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]