adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
586 stars 49 forks source link

Navigation: set main page? #56

Closed freever closed 1 year ago

freever commented 1 year ago

Hi again @adospace :)

Is there a way to set the application's main page?

Imagine this scenario: I open the app on a loading page that checks authentication, syncs data, and redirects either to the main application screen (if valid user) or the login screen. I usually handle this sort of thing by replacing the application's MainPage (eg Application.Current.MainPage = new LoginPage()) because I don't intend the user to be able to navigate back. I also don't want it to appear as Modal because once login is complete I want to replace the MainPage again with the full application window.

The INavigation abstraction allows me either to push a page to an existing NavigationPage ort to PushModal onto a new modal navigation stack, but there isn't a way to replace the current application root.

Do you think this is a valid use case, or am I doing it all wrong? And if it's valid, is there a way to do it using MauiReactor?

Thanks again

adospace commented 1 year ago

Well, you have a few of options here I guess: 1) Use the navigationpage/shell etc and disable the back button when showing the login page pushed on the stack or navigated to using shell 2) Using a navigation page and just replace the contained page (like I did in the KeeMind app https://github.com/adospace/kee-mind/blob/main/src/KeeMind/Pages/MainPage.cs) 3) Use the Window class as the root of the app and switch its content among your pages LoginPage/HomePage: https://adospace.gitbook.io/mauireactor/components/window

freever commented 1 year ago

Thank you, I think the Window-as-root option is closest to what I was looking for.