gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 28/54: playSound


From: gnunet
Subject: [taler-taler-ios] 28/54: playSound
Date: Fri, 30 Jun 2023 22:34:00 +0200

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 7ded59c6deb9d4646a29c2d00c57751f34fd5be4
Author: Marc Stibane <marc@taler.net>
AuthorDate: Tue Jun 27 14:46:01 2023 +0200

    playSound
---
 TalerWallet1/Controllers/TalerWallet1App.swift           |  3 ++-
 TalerWallet1/Views/Main/MainView.swift                   | 14 ++++++++++++++
 TalerWallet1/Views/Payment/PaymentURIView.swift          |  1 +
 TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift |  9 +++++----
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift 
b/TalerWallet1/Controllers/TalerWallet1App.swift
index 593d0c7..bff3e7a 100644
--- a/TalerWallet1/Controllers/TalerWallet1App.swift
+++ b/TalerWallet1/Controllers/TalerWallet1App.swift
@@ -19,6 +19,7 @@ struct TalerWallet1App: App {
     @Environment(\.scenePhase) private var phase
     @StateObject private var viewState = ViewState.shared         // 
popToRootView()
     @State private var isActive = true
+    @State private var soundPlayed = false
 
     private let walletCore = WalletCore.shared
     // our main controller
@@ -35,7 +36,7 @@ struct TalerWallet1App: App {
 
     var body: some Scene {
         WindowGroup {
-            MainView()
+            MainView(soundPlayed: $soundPlayed)
                 .environmentObject(debugViewC)      // change viewID / sheetID
                 .environmentObject(viewState)       // popToRoot
                 .environmentObject(controller)
diff --git a/TalerWallet1/Views/Main/MainView.swift 
b/TalerWallet1/Views/Main/MainView.swift
index 20eea52..3c30967 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -19,7 +19,17 @@ struct MainView: View {
     @EnvironmentObject private var controller: Controller
     @State private var sheetPresented = false
     @State private var urlToOpen: URL? = nil
+    @Binding var soundPlayed: Bool
 
+    func playSound() -> Void {
+        if !soundPlayed {
+            let url = URL(fileURLWithPath: "/System/Library/Audio/UISounds/"
+                          + "PaymentReceived.caf")
+            //                                  + "payment_success.caf")
+            //                                  + "payment_failure.caf")
+            GNU_Taler.playSound(fileURL: url)
+        }
+    }
     func sheetDismissed() -> Void {
         symLog.log("sheet dismiss")
     }
@@ -33,6 +43,10 @@ struct MainView: View {
                 Content(symLog: symLog)
                 // any change to rootViewId triggers popToRootView behaviour
                     .id(viewState.rootViewId)
+                    .onAppear() {
+                        playSound()
+                        soundPlayed = true
+                    }
             } else if controller.backendState == .error {
                 ErrorView(errortext: nil)            // TODO: show Error View
             } else {
diff --git a/TalerWallet1/Views/Payment/PaymentURIView.swift 
b/TalerWallet1/Views/Payment/PaymentURIView.swift
index 48313aa..5b4a0d6 100644
--- a/TalerWallet1/Views/Payment/PaymentURIView.swift
+++ b/TalerWallet1/Views/Payment/PaymentURIView.swift
@@ -36,6 +36,7 @@ struct PaymentURIView: View {
                     }
                 }
             } catch {    // TODO: error
+                playSound(success: false)
                 symLog.log(error.localizedDescription)
             }
             dismissTop()
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift 
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
index 09e5461..d43dfb3 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
@@ -16,9 +16,10 @@ struct P2pAcceptDone: View {
 
     @State private var finished: Bool = false
 
-    func playSound(success: Bool) {
+    func playSound(success: Bool, incoming: Bool) {
         let url = URL(fileURLWithPath: "/System/Library/Audio/UISounds/"
-                      + (success ? "PaymentReceived.caf"
+                      + (success ? (incoming ? "PaymentReceived.caf"
+                                             : "payment_success.caf")
                                  : "payment_failure.caf"))
         GNU_Taler.playSound(fileURL: url)
     }
@@ -52,10 +53,10 @@ struct P2pAcceptDone: View {
                     _ = try await model.confirmPeerPullDebitM(transactionId)
                 }
                 finished = true
-                playSound(success: true)
+                playSound(success: true, incoming: incoming)
             } catch {    // TODO: error
                 symLog.log(error.localizedDescription)
-                playSound(success: false)
+                playSound(success: false, incoming: incoming)
             }
         }
     }

-- 
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]