Additional tab actions

This commit is contained in:
Lumaa 2024-02-15 22:42:26 +01:00
parent c8853d9e05
commit fda864a418
2 changed files with 32 additions and 11 deletions

View File

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

View File

@ -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)