Tool bar inside the tab view screens are not working. All the views are inside the navigation view, still the dismiss action is not working in the tab bar contain screens(profile, settings, and search). Does tool bars don't work with the tab bar views?, saw some other questions here but they're all about the icons are not showing in the tool bar. In my case, one button is working another one is not working. What's the issue here? Navigation hierarchy or anything else.
@Environment(\.dismiss) private var dismiss
.toolbar {
ToolbarItem(placement: .primaryAction) {
HStack(alignment: .top, spacing: 290) {
if !isSidebarOpen {
Button(action: {
withAnimation {
dismiss()
print("Back Button tapped!")
}
}) {
Image("arrowleft")
.frame(width: 35, height: 35)
.foregroundColor(.white)
.background(Color.white)
.clipShape(Circle())
.shadow(radius: 2.5)
}
}
Button(action: {
self.isSidebarOpen.toggle()
print("Menu Button Tapped")
}) {
Image(isSidebarOpen ? "close" : "menu")
.resizable()
.frame(width: 40, height: 40)
}
}
}
}