1
votes

for an application that will have multi pages (looks like the image added), is it better to use StackView or Loader. Please note that, pages should not be closed and when they are opened again, they need to continue from the state they were closed. As far as I've searched, both of them have their disadvantage: Loader: 1 loader will not be enough for multi page. For every other page there must be a loader. That looks unnecessary. Also, for each time loader will destroy and open a new page. That makes it harder to open page as it was closed.

StackView: Stackview looks like useful for nested situations. But in the app, there will also be branches. In that case, people say it might cause memory leak etc.

Pages

1
Do you have a model to store the page states? If yes you could use that maybe, but otherwise I would definitely go with the StackView, it even has supporting transitions to give a sense where you are in the tree if you implement it right - Amfasis
@Amfasis I think I will go with StackView. But for branches, if I open the pages in these order: Page1 and pop Page 2 and pop, page3 and pop and then lets say I pushed page 2 again. Now the stack order will be messed up. Would it cause a problem? - Günkut Ağabeyoğlu
I think that StackView is definitely preferable since it's designed exactly for such purposes. - folibis
@GünkutAğabeyoğlu if you push and pop, the stack is back to initialItem, I don't think that would cause a problem... one thing to note btw, is that the state of page1, page2 and page3 might have been lost in that case (the garbage collector clears out the unused pages from StackView every now and then) - Amfasis

1 Answers

1
votes

You likely want to combine StackView and StackLayout.

A StackView manages a stack of views (usually instances of Page). This is a simple push and pop stack. Based on your diagram, there does not seem to be shared paths between each flow of Pages. I.e. they are all separate flows.

A StackLayout manages a collection of child views by showing just one of them at a time. It's usually used in combination with a tab selection widget of some sort.

Usually this pattern is implemented as a tab view controlling a stack layout of multiple stack views. You would have a Toolbar at the bottom with ToolButtons, and a StackLayout above it. The StackLayout would have 4 StackViews, one for each path in your diagram. When you click on each button in the tool bar, it switches the StackLayout to the corresponding StackView.

This approach is a commonly seen pattern in iOS applications.