Q-Mobile / QGrid

🎛 QGrid: The missing SwiftUI collection view.
MIT License
1.65k stars 105 forks source link

Multiple items navigation #33

Open artalejo opened 4 years ago

artalejo commented 4 years ago

Hello,

I am wondering if is there any solution for navigating to different items inside the QGrid. When clicking in an item it processes all the items click actions and navigates to all the links one after the other.

QGrid(self.dashboardViewModel.dashboardItems, columns: 2, isScrollable: false, showScrollIndicators: false) { dashboardItem in
    NavigationLink(destination: PlayerProfileView(playerLocalId: dashboardItem.actionId)) {
        DashboardItem(dashboardItemVE: dashboardItem)
    }.buttonStyle(PlainButtonStyle())
}
zgluis commented 4 years ago

I solved it navigating programmatically, check this: https://stackoverflow.com/questions/57315409

And I also used .onTapGesture to execute the navigation:

QGrid(Storage.people, columns: 3) { person in
        GridCell(person: person).onTapGesture {
           self.viewModel.personTapped(person)
    }
}

Here is a very useful post about navigation: https://medium.com/better-programming/swiftui-navigation-links-and-the-common-pitfalls-faced-505cbfd8029b