Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Navigation: login pages

$
0
0

Dear all,

I followed the instructions and I can make a nice tabbed navigation. Now I'd like to move to something fancier, but I have some doubts.

The target is this: when the app starts, it must check if I have saved some credentials, and if it has saved them, switch to a profile page profile. But if it doesn't have credential, it should show a simple page with a button notloggedin. The button will pop up a new page loginpage with a Facebook login (or another oauth method). Upon cancelling or logging in, the loginpage must disappear, and either the notloggedin or profile pages will be shown.

When starting an app, I set MainPage to the tabbed page I've created. But here what will the ManPage be? And when logged in, should I change the MainPage to the profile?

I've tried to do something like this:

public class App : Application
{
    static NavigationPage _NavPage;

    public App ()
    {
        _NavPage = new NavigationPage ();

        _NavPage.PushAsync (new BaseContentPage ()); // empty page

        MainPage = _NavPage.CurrentPage;

        var account = AccountStore.Create ().FindAccountsForService (App.AppName).FirstOrDefault ();
        var p = (account != null) ? account.Properties ["token"] : null;

        Log ("credentials: " + (p == null ? "null" : p.ToString ()));

        if (p != null)
        {
            Log ("previous login is successful");

            // profile
            MainPage = new ProfilePage ();
        }
        else
        {
            Log ("No previous token present");

            // not logged in
            _NavPage.PushAsync (new notloggedPage ());
        }
    }

But something is wrong: the empty page is always there, and the notloggedin page isn't shown, but the constructor is called.

Can anyone suggest me some solutions?

Thanks!


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>