gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 48/204: DragGesture


From: gnunet
Subject: [taler-taler-ios] 48/204: DragGesture
Date: Thu, 05 Dec 2024 23:50:16 +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 b94b4aa4750133213469e878dba4e14fe6238f64
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sat Oct 12 16:22:20 2024 +0200

    DragGesture
---
 TalerWallet1/Views/HelperViews/TabBarView.swift | 29 +++++++++++++++++++++++++
 TalerWallet1/Views/Main/MainView.swift          |  3 +++
 2 files changed, 32 insertions(+)

diff --git a/TalerWallet1/Views/HelperViews/TabBarView.swift 
b/TalerWallet1/Views/HelperViews/TabBarView.swift
index c188e79..24e539a 100644
--- a/TalerWallet1/Views/HelperViews/TabBarView.swift
+++ b/TalerWallet1/Views/HelperViews/TabBarView.swift
@@ -11,11 +11,15 @@ struct TabBarView: View {
     @Binding var selection: Tab
     @Binding var hidden: Int
     let onActionTab: () -> Void
+    let onActionDrag: () -> Void
 
     @Environment(\.keyboardShowing) var keyboardShowing
 
     @AppStorage("minimalistic") var minimalistic: Bool = false
 
+    @State private var offset = CGSize.zero
+    @State private var didDrag = false
+
     private func tabBarItem(for tab: Tab) -> some View {
         VStack(spacing: 0) {
             if tab == .actions {
@@ -27,6 +31,31 @@ struct TabBarView: View {
                     .frame(width: width, height: height)
                     .clipped() // Crop the image to the frame size
                     .padding(.bottom, 4)
+                    .offset(offset)
+                    .opacity(1 - Double(abs(offset.height / 35)))
+                    .gesture(
+                        DragGesture()
+                            .onChanged { gesture in
+                                var trans = gesture.translation
+                                trans.width = .zero
+                                if abs(offset.height) > 30 {
+                                    offset = .zero
+                                    didDrag = true
+                                    onActionDrag()    // switch to camera
+                                } else {
+                                    offset = trans
+                                }
+                            }
+                            .onEnded { _ in
+                                if didDrag {
+                                    didDrag = false
+                                } else {
+                                    onActionTab()
+                                }
+                                offset = .zero
+                            }
+                    )
+
             } else {
                 let size = minimalistic ? 36.0 : 24.0
                 tab.image
diff --git a/TalerWallet1/Views/Main/MainView.swift 
b/TalerWallet1/Views/Main/MainView.swift
index 7a8a470..3d38817 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -328,6 +328,9 @@ extension MainView {
                 // TODO: check NavigationStack, pop only if necessary
 //                ViewState.shared.popToRootView(nil)   either do this after 
any of the buttons was operated, or don't do it at all
                 showActionSheet = true
+            } onActionDrag: {
+//                showScanner = true
+//                showActionSheet = true
             }
 
             let scope = ScopeInfo(type: ScopeInfo.ScopeInfoType.exchange,

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