I have bottom navigation bar and in fist view I have list item, when I click the list item, it is open detail view, but bottom navigation bar still stay in detail view, I want to hide navigation bar when I click open the detail view. Is it possible?
ContentView:
struct TabView : View {
@State private var selection = 0
@State var index = 0
var body: some View{
VStack(spacing: 0){
ZStack{
ListView()
.opacity(self.index == 0 ? 1 : 0)
}
HStack{
Button(action: {
self.index = 0
}) {
HStack(spacing: 6){
Image("List")
.foregroundColor(self.index == 0 ? Color("blue") : .black)
if self.index == 0{
Text("List")
.foregroundColor(Color("blue"))
}
}
.padding(.vertical,10)
.padding(.horizontal)
.background(self.index == 0 ? Color("tabbar-background") : Color.clear)
.clipShape(Capsule())
}
Spacer(minLength: 0)
Button(action: {
self.index = 1
}) {
HStack(spacing: 6){
Image("SecondList")
.foregroundColor(self.index == 1 ? Color("blue") : .black)
if self.index == 1{
Text("SecondList")
.foregroundColor(Color("blue"))
}
}
.padding(.vertical,10)
.padding(.horizontal)
.background(self.index == 1 ? Color("tabbar-background"): Color.clear)
.clipShape(Capsule())
}}}
.edgesIgnoringSafeArea(.bottom)
}
}
ListView:
struct ListView: View {
var body: some View {
VStack{
ScrollView(.vertical, showsIndicators: false, content: {
VStack(spacing: 15){
RowView(docs: docs)
}
}
}
}
}
}
struct RowView: View {
@State var docs: Datas
var body: some View {
HStack(spacing: 15){
NavigationLink(destination: ListDetailView(docs: docs)) {
HStack{
Image(docs.image)
.resizable()
.frame(width: 64, height: 48)
}
}
}
.padding(.horizontal)
}
}
ListDetailView:
import SwiftUI
struct ListDetailView: View {
@State var docs: Datas
var body: some View {
ZStack{
Image(docs.image)
.resizable()
.aspectRatio(contentMode: .fit)
}
}
}
struct ListDetailView_Previews: PreviewProvider {
static var previews: some View {
ListDetailView(docs: datas[0])
}
}