0
votes

I'm trying to work out the correct way of structuring the navigation for my Xamarin.Forms application. Please note the LoginPage is currently set as the application's MainPage.

The intended (visual) structure is as follows:

CheckPermissionsPage ➜ LoginPage ➜ HomePage

I am following a MVVM structure, so my LoginPageViewModel is displaying a modal of CheckPermissionsPage within it's constructor as so:

await Application.Current.MainPage.Navigation.PushModalAsync(new CheckPermissionsPage());

The idea is that the check permissions page validates the application has permissions to specific services and if it does, the page automatically closes. The user must then login to the application, after which the HomePage is displayed.

How would I structure the LoginPage so that the CheckPermissionsPage modal can be displayed/hidden based on permissions state. Consequently, after a successful login, the HomePage is displayed (without an option to return to the LoginPage). Thanks!

1
you generally check permissions on demand, not all at once - Jason

1 Answers

0
votes

I ended up changing the application MainPage to navigate throughout the pages. So my initial application main page is now the CheckPermissionsPage. Should permissions be granted I then run Application.Current.MainPage = new NavigationPage(new LoginPage());. After logging in, the HomePage is displayed with Application.Current.MainPage = new NavigationPage(new HomePage());. This probably isn't the most ideal solution, but it does allow me to prevent back navigation for my LoginPage.