Any examples of using a swiftui tabview with the decompose router?
a
Arkadii Ivanov
03/31/2022, 4:37 PM
I'm not aware of any such examples yet, but would like to see!
i
iamsteveholmes
03/31/2022, 5:07 PM
One thought I had was just using a single component within each tabbed view. In my case they are related. I suppose in that case I wouldn’t necessarily need the router.
As I’m thinking about it I don’t know if using the router makes sense as the Tabview has to be attached to Views. Whereas when I’m using the router the view is determined by the state of the router configuration.
a
Arkadii Ivanov
03/31/2022, 5:10 PM
Does it mean that TabView controls its views on its own? I would expect it to be just simple togglable buttons.
i
iamsteveholmes
03/31/2022, 10:26 PM
If you look at how it works the tabview is essentially the parent and each view a child. I think if you wanted to have something that works with the router you might build a custom toolbar that calls the router when each item is clicked. In that case the toolbar would have to be included in each view that displays it.
I’m fairly green with swiftui so someone with more experience might have a better solution.
a
Arkadii Ivanov
03/31/2022, 10:36 PM
Not necessarily. The toolbar (tab view) could be at the parent level. Clicking on a button would trigger the router and the child view would be replaced.
I would try implementing custom TabView, just a row of buttons.