Folks,
I’m trying to navigate through a tree using … well, some SwiftUI widget. I've tried OutlineGroup and it works, but the big drawback is that you can’t lazily download the tree, since there is no state variable of sorts that informs you when a disclosure sign > is pressed. So you have to download the whole tree at once, including items that you’re likely no to view ever.
I tried the new NavigationStack, with that sort of idea:
NavigationStack {
RecursiveView (rootItemList)
}
struct RecursiveView (itemList) {
List {
ForEach (item in itemList) {
if item.isLeaf {
someView (item)
} else {
NavigationLink (destination: RecursiveView(childList))
}
}
}
Well, it does work up to one level of recursion. Afterwards, it stops working and I get these messages:
onChange(of: UpdateTrigger) action tried to update multiple times per frame
or/and:
Only root-level navigation destinations are effective for a navigation stack with a homogeneous path.
So I suppose this widget is not fit for that kind of navigation. Does anyone have a better idea?
3
1
2.3k