taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit b94b4aa4750133213469e878dba4e14fe6238f64
parent d370e2c4ec12832e7033a55948f5359eb30c7621
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 12 Oct 2024 16:22:20 +0200

DragGesture

Diffstat:
MTalerWallet1/Views/HelperViews/TabBarView.swift | 29+++++++++++++++++++++++++++++
MTalerWallet1/Views/Main/MainView.swift | 3+++
2 files changed, 32 insertions(+), 0 deletions(-)

diff --git 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 @@ -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,