I'm using Xamarin Forms for Android and IOs app.
I have two pages, Login page and Main page. The logic I want to implement is: Check if user is Logged In, If no open "Login" page, if yes go to "Main" page.
I was trying to implement this using NavigationPage and Navigation.PushAsync method. But method not working without NavigationPage, and NavigatetionPage renders additional navigation bar at the top.
Now I'm using:
App.xaml.cs
public App()
{
InitializeComponent();
if (!isUserLoggedIn)
{
MainPage = new LoginPage();
}
else
{
MainPage = new MainPage();
}
}
LoginPage.xaml.cs
//When user authenticated
App.Current.MainPage = new MainPage();
This code works well, but I'm not sure if this is good and correct solution.
Is there any better way to implement same logic?