spacenation / swiftui-grid

:rocket: SwiftUI Grid layout with custom styles
MIT License
961 stars 60 forks source link

NavigationLink's cell view not working inside grid #75

Closed nobanhasan2 closed 4 years ago

nobanhasan2 commented 4 years ago

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 4 years ago

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

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

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

nobanhasan2 commented 4 years ago

@ay42 please see this screenshot https://drive.google.com/open?id=1WqTVLlI4AMMxioBADtkNLrH4K-At6-lY

ay42 commented 4 years ago

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

nobanhasan2 commented 4 years ago

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 4 years ago

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

ay42 commented 4 years ago

@nobanhasan2 my guess is you are missing this line. https://github.com/spacenation/swiftui-grid/blob/978cc2eae7ced4a4d3cf9b6728503edc62a2969f/GridDemo%20iOS/StaggeredGrid/StaggeredGridView.swift#L14

nobanhasan2 commented 4 years ago

@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 4 years ago

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

nobanhasan2 commented 4 years ago

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

ay42 commented 4 years ago

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

nobanhasan2 commented 4 years ago

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

ay42 commented 4 years ago

@nobanhasan2 np