I have this struct:
struct Final_Restaurant_View: View { var data: [RestaurantListViewModel] @State private var isHome = false var body: some View { NavigationView{ VStack { List(data) { data in layout(data: data) } .listStyle(GroupedListStyle()) Button(action: { isHome = true }, label: { Text("Go Home") }) .padding() } .fullScreenCover(isPresented: $isHome, content: { ContentView() }) .navigationBarTitle("Results") } } }
Which is supposed to get data and display it in a list. The problem is that I can't find anything about sections on a table structured like this and therefore, it goes wack with the section title. Any Ideas???
Thanks for showing the code. I could have reproduce the similar layout with the new code.
(I used simplified layout
because I could not make it work but that was enough. By the way, you should better follow the naming rule of Swift when you write code in Swift.)
With this part:
List(data) { data in Section(header: Text("GroupPicks")) { layout(data: data) } }
You are trying to add a section to each row of your List. Which causes the result as shown in your previous screen shot.
Putting Section
inside List(data) { ... }
does not make sense.
Please try something like this:
if data.count == 0 { Text("No Picks Found") } else { List { Section(header: Text("GroupPicks")) { ForEach(data) { data in layout(data: data) } } } .listStyle(GroupedListStyle()) //.listStyle(PlainListStyle()) //.listStyle(InsetListStyle()) }