defagos / SwiftUICollection

A collection view for SwiftUI
MIT License
91 stars 6 forks source link

Navigation links in `CollectionView` #4

Open danielsaidi opened 3 years ago

danielsaidi commented 3 years ago

Hi! I noticed that navigation links don't work when I use them within a CollectionView, while regular buttons do work. I wonder if it has something to do with the hosting controller and how it may block the navigation from happening.

defagos commented 3 years ago

Good catch! I wouldn't be surprised if this is related to missing parent-child containment relationship, see this tweet from Peter Steinberger and related articles and links.

Didn't have to focus on this specific question myself, but this is definitely where I would have a look first.

danielsaidi commented 3 years ago

I'd be happy to not have navigation links, but rather use buttons that trigger sheets or full screen covers...but I guess it would be nice to solve this for other scenarios than tvOS.

danielsaidi commented 3 years ago

Since the scroll view offset and item re-selection works when returning to the collection from a sheet or full screen modal (after I fixed my incorrect data reload), I have no need to do "real" navigation anymore...at least for now. It may however be good to have support for navigation links when the target destination can have deeper navigation, right?

defagos commented 3 years ago

I fear this collection view implementation might have some limitations, but if navigation links could be properly supported that would be nice (and probably something has to be learnt when trying to make them work).

I therefore labeled this issue as a bug.

danielsaidi commented 3 years ago

Perfect, I'll see if I can come up with a solution, but until then the sheet and full screen cover approach work well when the navigation is not that deep. I don't even know if there would be any problems with deep navigation and sheets on tvOS.

defagos commented 3 years ago

Didn’t see any deep navigation issues in the app I am working on 🙂

danielsaidi commented 3 years ago

Great! I realized that perhaps on tvOS the sheet implementation is the same thing as pushing onto a navigation stack. I mean, there is no sheet concept on the platform, so the implementation could actually be that they do that.