Hi Folks,
I would like it so that when I press the button on the HomeScreen, the TabView hides and the toolbar item appears in its place.
Currently, the toolbar item stacks on top of the TabView. However, when I try to hide the TabView, with an if condition for example, the screens turn black. I think it's because of the screen calls in the TabView. Is there an option to achieve what I want?
I'm new to SwiftUI, so I'm very glad for any Solutions or advices.
struct NavBar: View {
var body: some View {
TabView {
HomeScreen()
.tabItem {
Label(
"Home",
systemImage: "house"
)
}
...
}
}
}
struct HomeScreen: View {
@State private var showDeleteButton = false
var body: some View {
Button("Show/Dissmiss Delete Button", action: {
showDeleteButton.toggle()
}).toolbar {
if showDeleteButton {
ToolbarItem(placement: .bottomBar) {
Button("Delete", action: {})
}
}
}
}
}