spacenation/swiftui-grid

NavigationLink's cell view not working inside grid

nobanhasan2 opened this issue · 13 comments

Image and text rendered in the grid view
Grid(viewModel.items){ item in NavigationLink(destination: BookDetail(displayData: item)){ SearchBookCell(displayData: item) } } .gridStyle( ModularGridStyle(columns: 2, rows: .fixed(200)) ).animation(.easeInOut)

ay42 commented

@nobanhasan2 do you have a NavigationView one level above grid?

var body: some View {
    NavigationView {
        Grid(...)
    }
}
ay42 commented

@nobanhasan2 I just added a working example with #79.
Closing this for now.

ay42 commented

@nobanhasan2 ok. I'm not sure what is not working for you there. Can you clarify?

Here is the full code. I don't know why its overlay on my image and also in text.
`var body: some View {
ZStack {
Color(0xedeef0)
.edgesIgnoringSafeArea(.all)
NavigationView{
VStack {
SearchBookBar(text: $viewModel.searchText)

                                  Grid(viewModel.items){ item in
                                    NavigationLink(destination: BookDetail(displayData: item)){
                                        SearchBookCell(displayData: item)
                                        }
                                   }
                                  .gridStyle(
                                    ModularGridStyle(columns: 2, rows: .fixed(200))
                                       ).animation(.easeInOut)
                 
                      
                          }
        }
        
           }`
ay42 commented

@nobanhasan2 you mean where is the blue square should be an image rendered?

ay42 commented

@nobanhasan2 my guess is you are missing this line.

@ay42 Yes.. i can solve the image render with that line but there Text is also rendered . Text has no function like renderingMode . How can i solve this?

ay42 commented

@nobanhasan2 for text color change .accentColor(...), .foregroundColor(...) ? Is that what you are trying to do just a color change?

i didn't do any color change. Everything was fine without NavigationLink

ay42 commented

@nobanhasan2 navigation link makes it a button and it's rendered with system accent color

Ohhh now i see. Thank you so much bro for your help ^_^