Beispiel #1
0
        private async Task checkLoggedIn()
        {
            ClientInitializor.username = Xamarin.Essentials.Preferences.Get("username", "null");
            ClientInitializor.password = Xamarin.Essentials.Preferences.Get("password", "null");

            Device.BeginInvokeOnMainThread(() =>
            {
                indicator.IsVisible = true;
                indicator.IsEnabled = true;
                indicator.IsRunning = true;
            });

            if (ClientInitializor.username != "null")
            {
                await DataFetcher.AttemptLogIn();

                if (DataFetcher.loggedIn)
                {
                    LoggedIn = true;
                    if (Device.RuntimePlatform == Device.iOS)
                    {
                        await Navigation.PopToRootAsync();
                    }

                    Device.BeginInvokeOnMainThread(() => {
                        Application.Current.MainPage = new NavigationPage(new GradesPage());
                        ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = g1;
                    });
                    //Application.Current.MainPage = new NavigationPage(new GradesPage());
                    //await Navigation.PushModalAsync(new GradesPage());
                    //((NavigationPage)Application.Current.MainPage).BarBackgroundColor = g1;
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        usnHolder.Hint         = "Incorrect Username or Password";
                        usnHolder.FocusedColor = Color.Red;
                        usnHolder.Focus();
                        pwd.Text              = "";
                        usn.Text              = "";
                        acceptTOS.IsChecked   = false;
                        LoginButton.IsEnabled = true;
                        LoginButton.FadeTo(1, 300);

                        LoginButton.IsVisible = true;

                        indicator.IsVisible = false;
                        indicator.IsEnabled = false;
                        indicator.IsRunning = false;
                    });
                }
            }
        }
Beispiel #2
0
 private async Task DoLogin()
 {
     await DataFetcher.AttemptLogIn();
 }