0
votes

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:

  1. The first Group contains app logo and a search bar
  2. 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
1
Try to put the NavigationView in top of the VStack (after var body: some View { )arata
Thank you, it works!Antonio De Simone
Good! I will write it as the answer.arata

1 Answers

0
votes

You have to put the NavigationView on top of everything. put the NavigationView in top of the VStack (after var body: some View {)