I am using SwiftUI to create NavigationLinks from a List's rows to detail views in a NavigationView. In my CustomView I have 2 Groups:
- The first Group contains app logo and a search bar
- The second contains a List (that I use to show search results) with NavigationLink
When I use NavigationLink to show detail of a row, it works but my RetailerView() is displayed in the bottom of the screen.
var body: some View {
VStack {
// Logo
Group {
Spacer()
LogoView()
Spacer()
}
// search bar
Group {
TextField("search you retailer...", text:$search, onCommit: searchRetailer)
.disableAutocorrection(true).font(.body).frame(width: 270, height: 30, alignment: .center).padding().textFieldStyle(RoundedBorderTextFieldStyle()).autocapitalization(UITextAutocapitalizationType.none)
Spacer()
}
if(self.retailersList.count == 0){
Text("No results found!")
}else{
Group {
VStack {
NavigationView {
List {
ForEach(retailersList) { retailer in
NavigationLink(destination: RetailerView()){
RetailerRaw(retailer: retailer, color: self.computeColor(retailer: retailer))
}.isDetailLink(true)
}
}.listStyle(GroupedListStyle())
} //end NavigationView
}
}
}
Spacer()
} //end VStack
} //end body
var body: some View {
) – arata