From fda864a41830a3119f5983ab78f89e80680119cf Mon Sep 17 00:00:00 2001 From: Lumaa Date: Thu, 15 Feb 2024 22:42:26 +0100 Subject: [PATCH] Additional tab actions --- Threaded/Components/TabsView.swift | 33 +++++++++++++++++++++++++----- Threaded/Views/ContentView.swift | 10 ++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Threaded/Components/TabsView.swift b/Threaded/Components/TabsView.swift index 23e041e..81f832e 100644 --- a/Threaded/Components/TabsView.swift +++ b/Threaded/Components/TabsView.swift @@ -4,12 +4,20 @@ import SwiftUI struct TabsView: View { @Binding var selectedTab: TabDestination - var postButton: () -> Void + + var postButton: () -> Void = {} + var tapAction: () -> Void = {} + var retapAction: () -> Void = {} var body: some View { HStack(alignment: .center) { Button { - selectedTab = .timeline + if selectedTab == .timeline { + retapAction() + } else { + selectedTab = .timeline + tapAction() + } } label: { if selectedTab == .timeline { Tabs.timeline.imageFill @@ -22,7 +30,12 @@ struct TabsView: View { Spacer() Button { - selectedTab = .search + if selectedTab == .search { + retapAction() + } else { + selectedTab = .search + tapAction() + } } label: { if selectedTab == .search { Tabs.search.imageFill @@ -44,7 +57,12 @@ struct TabsView: View { Spacer() Button { - selectedTab = .activity + if selectedTab == .activity { + retapAction() + } else { + selectedTab = .activity + tapAction() + } } label: { if selectedTab == .activity { Tabs.activity.imageFill @@ -57,7 +75,12 @@ struct TabsView: View { Spacer() Button { - selectedTab = .profile + if selectedTab == .profile { + retapAction() + } else { + selectedTab = .profile + tapAction() + } } label: { if selectedTab == .profile { Tabs.profile.imageFill diff --git a/Threaded/Views/ContentView.swift b/Threaded/Views/ContentView.swift index 7237b7d..6385966 100644 --- a/Threaded/Views/ContentView.swift +++ b/Threaded/Views/ContentView.swift @@ -38,13 +38,11 @@ struct ContentView: View { }) } .overlay(alignment: .bottom) { - if uniNavigator.showTabbar { - TabsView(selectedTab: $uniNavigator.selectedTab) { - uniNavigator.presentedSheet = .post(content: "", replyId: nil, editId: nil) - } - .offset(y: uniNavigator.showTabbar ? 0 : -20) - .zIndex(10) + TabsView(selectedTab: $uniNavigator.selectedTab) { + uniNavigator.presentedSheet = .post(content: "", replyId: nil, editId: nil) } + .padding(.vertical, 10) + .zIndex(10) } .withSheets(sheetDestination: $uniNavigator.presentedSheet) .withCovers(sheetDestination: $uniNavigator.presentedCover)