taler-ios

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

commit 87d921e99a86d4a6b7409b17d080d3b553234a41
parent ac13e889c9563f30109c8879b5edaa322df7d09c
Author: Marc Stibane <marc@taler.net>
Date:   Tue, 18 Feb 2025 18:14:55 +0100

Only hide (negative padding) SwiftUI tabBar when our custom tabBar is hidden, otherwise the bottom item in the scrollView is drawn under our bar and cannot be tapped

Diffstat:
MTalerWallet1/Views/Main/MainView.swift | 4++--
MTalerWallet1/Views/ViewModifier/View+TabBar.swift | 15+++++++++------
2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -247,7 +247,7 @@ extension MainView { @State private var shouldReloadBalances = 0 @State private var shouldReloadTransactions = 0 @State private var shouldReloadPending = 0 - @State private var tabBarHeight: CGFloat = 0 + @State private var tabBarHeight: CGFloat = 0 // SwiftUI tabBar height @State private var selectedTab: Tab = .balances @State private var showKycAlert: Bool = false @State private var kycURI: URL? @@ -407,7 +407,7 @@ extension MainView { /// custom tabBar is rendered on top of the TabView, and overlaps its tabBar ZStack(alignment: .bottom) { tabContent - .hideTabBar + .hideTabBar($tabBarModel.tabBarHidden) .environment(\.tabBarHeight, tabBarHeight) tabBarView .ignoresSafeArea(.keyboard, edges: .bottom) diff --git a/TalerWallet1/Views/ViewModifier/View+TabBar.swift b/TalerWallet1/Views/ViewModifier/View+TabBar.swift @@ -62,8 +62,9 @@ extension View { let onePixel: CGFloat = 1/3 let separatorHeight: CGFloat = tabViewHeightShouldIncludeSeparator ? onePixel : 0 DispatchQueue.main.async { - // -4 still hides the "visible" tabBar, but leaves it available for A11Y voiceOver - storage.wrappedValue = tabBar.bounds.height + separatorHeight - 4 + // -4 still hides the "visible" SwiftUI tabBar, but leaves it available for A11Y voiceOver + // no longer necessary if we only hide the SwiftUI tabBar when our custom tabBar is hidden + storage.wrappedValue = tabBar.bounds.height + separatorHeight // - 4 } }) } @@ -100,18 +101,20 @@ struct TabBarAccessor: UIViewControllerRepresentable { // MARK: - Content extension View { - var hideTabBar: some View { - modifier(HideTabBarModifier()) + func hideTabBar(_ hidden: Binding<Int>) -> some View { + modifier(HideTabBarModifier(tabBarHidden: hidden)) } } struct HideTabBarModifier: ViewModifier { + @Binding var tabBarHidden: Int @Environment(\.safeAreaEdgeInsets) private var safeAreaEdgeInsets @Environment(\.tabBarHeight) private var tabBarHeight func body(content: Content) -> some View { + let padding = tabBarHidden == 0 ? 0 + : tabBarHeight content - .padding(.bottom, -safeAreaEdgeInsets.bottom - tabBarHeight) + .padding(.bottom, -safeAreaEdgeInsets.bottom - padding) } } -