"logout" from MasterDetailPage

Good morning,

I'm following the pattern from the master detail page tutorial, implementing the whole "hamburger menu", etc.

My question: In the navigation page, I need to add a "logout". The only way I can think of doing it is by adding another view called "logout" and by setting "App.Content.MainPage" to my LoginPag(). Please see my code:

    protected override void OnAppearing()
    {
        App.DAUtil.DeleteUser();
        App.IsUserLoggedIn = false;

        App.Current.MainPage = new NavigationPage(new LoginPage());
    }

Is this the correct methodology to integrate logout / login w/in a master detail page?

Thanks

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    I do this

    App.Current.MainPage = new LoginPage();
  • Question: what is the difference in using new NavigationPage(new LoginPage()) vs new LoginPage()?

  • CharwakaCharwaka INMember ✭✭✭
    edited November 9

    HI @juggernaut3000sd

    new LoginPage()

    Directly setting LoginPage as Startup Page

    NavigationPage(new LoginPage())

    where the next page slide in(Adding to top of stack)

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    The difference is that I think you should not add your login page to a navigation stack. You don need to go back to a login page pressing a back button...
Sign In or Register to comment.