I am facing an issue while implementing NavigationView with list and LazyVGrid. In the first switch statement I am using TabView to display horizontal views,and in the second switch statement I am using lazyVGrid to display Vertical Grid. The problem is that when I click on horizontalView(TabView) it works fine and navigate to another screen but when I click on the GridItem to navigate to another screen it makes the background grey and pause the whole UI.
Here is my code,
import SwiftUI
struct BreakingNewsHorizontalView: View {
let articles: [GNewsArticle]
var body: some View {
TabView {
ForEach(0 ..< articles.count) { index in
NavigationLink(destination: NewsDetailView(url: URL(string: articles[index].url)!)) {
ZStack {
AsyncImage(url: URL(string: articles[index].image)) { image in
image
.resizable()
.scaledToFill()
} placeholder: {
ProgressView()
}
VStack {
Spacer()
VStack {
Text(articles[index].title)
.font(.system(size: 20, weight: .black))
.foregroundColor(.white)
.lineLimit(2)
.frame(width: 370)
}
.frame(height: 70, alignment: .center)
.frame(maxWidth: .infinity)
.background(Color.black.opacity(0.5))
Spacer()
.frame(height: 10)
}//: VSTACK
}//: ZSTACK
}
}//: FOREACH
}//: TABVIEW
.tabViewStyle(PageTabViewStyle())
.cornerRadius(10)
.padding()
}
}
NavigationView, list, LazyVGrid and TabView