0
votes

I have a NavigationView that leaves what looks like padding above the List of NavigationLink's and I can't work out how to get rid of it? Weird NavigationView bug

Here's the view that calls the NavigationView:

struct SearchView: View {
    @EnvironmentObject var networkManager:NetworkManager
    
    var body: some View {
        VStack {
            SearchBar()//<- This view houses the content above the list but contains no padding after the divider and when the filesToDisplay is false it shrinks to the divider as expected
            if networkManager.filesToDisplay {
                ResultsView()
            }
        }
    }
}

Here's the NavigationView:

struct ResultsView: View {
    @EnvironmentObject var networkManager:NetworkManager
    var body: some View {
        NavigationView {
            List {
                ForEach(networkManager.FileList!.items) { file in
                    NavigationLink(destination: FileDetail(fileDetail: file)) {
                        FileRow(fileRow: file)
                    }
                }
            }
            Rectangle().frame(maxWidth: 0, maxHeight: .infinity)
            }.frame(minHeight:500, idealHeight: 550, maxHeight: .infinity)
    }
}

I thought the problem might be to do with navigationBarTitle but MacOS does not appear to use this? I've tried all sorts of different padding and listRowInsets but nothing is working.

1

1 Answers

3
votes

Add explicit spacing

VStack(spacing: 0) {   // << here !!
    SearchBar()
    if networkManager.filesToDisplay {
        ResultsView()
    }
}