rundfunk47 / stinsen

Coordinators in SwiftUI. Simple, powerful and elegant.
MIT License
907 stars 95 forks source link

Issues caused by use of SwiftUI's NavigationStack #115

Open sgade opened 1 year ago

sgade commented 1 year ago

When targeting iOS 16 and above, the use of NavigationView is deprecated (since iOS 16.2 and similar). Stinsen internally uses NavigationView (in its NavigationViewCoordinator) in combination NavigationLink for navigation. This implementation detail came up as an issue in a custom ViewWrapperCoordinator that was doing if #available checks for iOS 16 and then using SwiftUI's NavigationStack instead.

Environment

Problematic behaviour

The problem is that the dismissal of views and coordinators is broken with the approach described above. Inconsistent behaviour and white screens are symptoms. The console also frequently shows the warning: NavigationLink presenting a value must appear inside a NavigationContent-based NavigationView. Link will be disabled..

Presentation of views and coordinators actually works just fine, as far as I can tell.

Proposed changes

I know Stinsen strives to be backward very compatible. Coming from iOS 13, there is a long way until the minimum supported version will be iOS 16. Even then, NavigationView still works the same as in previous versions of iOS.

However, it would still benefit users if there was support for the new navigation types, as it would make integrating more current implementations much easier and familiar going forward. As NavigationView is still widely used, there could be an option to either use the old or new version.

At the very least it would be very helpful if there was a hint (e.g. in the README) that custom ViewWrapperCoordinators for stack-based navigation should use NavigationView instead of NavigationStack.

Let me know what direction you would prefer and if I could be of any help.

LePips commented 1 year ago

The requirement for moving to the new APIs isn't unknown, it just ... hasn't happened yet

sgade commented 1 year ago

Thanks for the quick reply and for referring to the existing discussion. I didn't expect the topic to be in the comments to that issue but now I read it.

Are there any updates on the topic? I think the suggested Backport solution might make it somewhat manageable to keep both implementations around for the foreseeable future.

Also, do you want to keep tracking the progress in the other ticket? Then I'll close this one.