Conversation

Fahim Farook

While I have come to love the latest iteration of SwiftUI for how fast I can get stuff done, one thing that still trips me up is navigation — it’s almost as if Apple expects all screen navigation to happen either as explicit taps on UI elements, or simply modal screens 🙂

With my latest app, I have been hitting navigation limitations pretty hard. I have a list item which also has a button on it which should take you to a different item than tapping on the list item itself. Try as I could (OK, I didn’t try verrry hard 😛) I couldn’t make this work correctly.

Then I found this handy package:

https://github.com/DoubleSymmetry/XNavigation

It made all of my navigation handling issues disappear! (Well, at least for now … I’ve only been using the package for about an hour …) It did make all of the scenarios I encountered (and had to find workarounds for so far) disappear. So I’m very thankful to the author since it makes navigation fun again for me 🙂

#iOS #Coding #SwiftUI #Navigation
1
0
4

@f Have you seen the Modern SwiftUI series from PointFree? That really cleared up for me how to do navigation well in plain SwiftUI apps.

1
0
0
@danhalliday Thanks, will give that a try and see if that helps 🙂

The issue that I ran into (which I probably didn’t explain properly in the previous post) was that I had a List cell which was enclosed in a NavigationLink but which also had a sub item in the cell with a different NavigationLink. Putting two NavigationLinks for the same list item didn’t appear to be supported … but I must confess that I didn’t dig too deep since I just wanted to get on with the project I was working on 😛

I did try using a sheet with the sub-item too and that would just do both navigations at once. But again, it might have been a bug and it is possible SwiftUI works as intended. I did intend to write a new post about this issue later today anyway and now you’ve actually motivated me to make sure that happens and maybe do a bit of digging into this issue too.

So thank you for that … I think 😛
1
0
0

@f If you put multiple buttons in a list row, by default they will all fire on a list row tap. You can add .buttonStyle(.plain) to fix that. Might be the same for NavigationLinks!

0
0
0