Tab bar issue
This commit is contained in:
parent
c868b0cd2e
commit
d4d3fe43d3
|
@ -5,6 +5,8 @@ import SwiftUI
|
|||
struct TabsView: View {
|
||||
@State var selectedTab: TabDestination = Navigator.shared.selectedTab
|
||||
|
||||
var canTap: Binding<Bool> = .constant(true)
|
||||
|
||||
var postButton: () -> Void = {}
|
||||
var tapAction: () -> Void = {}
|
||||
var retapAction: () -> Void = {}
|
||||
|
@ -12,6 +14,8 @@ struct TabsView: View {
|
|||
var body: some View {
|
||||
HStack(alignment: .center) {
|
||||
Button {
|
||||
guard canTap.wrappedValue else { return }
|
||||
|
||||
if selectedTab == .timeline {
|
||||
retapAction()
|
||||
} else {
|
||||
|
@ -25,11 +29,14 @@ struct TabsView: View {
|
|||
Tabs.timeline.image
|
||||
}
|
||||
}
|
||||
.disabled(!canTap.wrappedValue)
|
||||
.buttonStyle(NoTapAnimationStyle())
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
guard canTap.wrappedValue else { return }
|
||||
|
||||
if selectedTab == .search {
|
||||
retapAction()
|
||||
} else {
|
||||
|
@ -43,20 +50,26 @@ struct TabsView: View {
|
|||
Tabs.search.image
|
||||
}
|
||||
}
|
||||
.disabled(!canTap.wrappedValue)
|
||||
.buttonStyle(NoTapAnimationStyle())
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
guard canTap.wrappedValue else { return }
|
||||
|
||||
postButton()
|
||||
} label: {
|
||||
Tabs.post.image
|
||||
}
|
||||
.disabled(!canTap.wrappedValue)
|
||||
.buttonStyle(NoTapAnimationStyle())
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
guard canTap.wrappedValue else { return }
|
||||
|
||||
if selectedTab == .activity {
|
||||
retapAction()
|
||||
} else {
|
||||
|
@ -70,11 +83,14 @@ struct TabsView: View {
|
|||
Tabs.activity.image
|
||||
}
|
||||
}
|
||||
.disabled(!canTap.wrappedValue)
|
||||
.buttonStyle(NoTapAnimationStyle())
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
guard canTap.wrappedValue else { return }
|
||||
|
||||
if selectedTab == .profile {
|
||||
retapAction()
|
||||
} else {
|
||||
|
@ -88,6 +104,7 @@ struct TabsView: View {
|
|||
Tabs.profile.image
|
||||
}
|
||||
}
|
||||
.disabled(!canTap.wrappedValue)
|
||||
.buttonStyle(NoTapAnimationStyle())
|
||||
}
|
||||
.padding(.horizontal, 30)
|
||||
|
|
|
@ -41,7 +41,7 @@ struct ContentView: View {
|
|||
}
|
||||
.frame(maxWidth: appDelegate.windowWidth)
|
||||
.overlay(alignment: .bottom) {
|
||||
TabsView(postButton: {
|
||||
TabsView(canTap: $navigator.showTabbar, postButton: {
|
||||
uniNavigator.presentedSheet = .post(content: "", replyId: nil, editId: nil)
|
||||
}, retapAction: {
|
||||
navigator.path = []
|
||||
|
@ -53,6 +53,7 @@ struct ContentView: View {
|
|||
y: navigator.showTabbar ? 0 : CGFloat
|
||||
.getFontSize(from: .extraLargeTitle) * 7.5
|
||||
)
|
||||
.allowsHitTesting(navigator.showTabbar)
|
||||
}
|
||||
.withSheets(sheetDestination: $uniNavigator.presentedSheet)
|
||||
.withCovers(sheetDestination: $uniNavigator.presentedCover)
|
||||
|
|
Loading…
Reference in New Issue