Beispiel #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            #region Designer Stuff

            SetContentView(this.ContentLayout);

            UINavigationBar.Appearance.BarTintColor = ViewBuilder.ColorFromARGB(AppController.Colors.AndroidGreen);
            UINavigationBar.Appearance.TintColor    = ViewBuilder.ColorFromARGB(AppController.Colors.White);
            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes {
                TextColor = ViewBuilder.ColorFromARGB(AppController.Colors.White)
            });

            #endregion

            this.LoadLayout.UserInteractionEnabled = true;
            this.LoadLayout.Hidden = true;

            bool isResuming = this.ContentController.ViewControllers.Length > 0;
            if (!isResuming)
            {
                this.ContentController.PushViewController(new LoginViewController(), false);

                _userRestored = this.Arguments.GetBoolean("UserRestored");
                if (_userRestored)
                {
                    var c = new GimmicksViewController();
                    this.ContentController.PushViewController(c, false);
                }
            }
        }
Beispiel #2
0
        private void LoginUser()
        {
            if (ValidateInput())
            {
                if (_isLogginUser)
                {
                    return;
                }

                _isLogginUser = true;

                _email    = this.EmailText.Text;
                _password = this.PasswordText.Text;

                // Prevent user form tapping views while logging
                ((MainViewController)this.MainViewController).BlockUI();

                // Create a new cancellation token for this request
                _cts1 = new CancellationTokenSource();
                AppController.LoginUser(_cts1, _email, _password,
                                        // Service call success
                                        (data) =>
                {
                    AppController.Settings.LastLoginUserIdUsed   = data.UserId;
                    AppController.Settings.LastLoginUsernameUsed = _email;
                    AppController.Settings.AuthAccessToken       = data.AuthAccessToken;
                    AppController.Settings.AuthExpirationDate    = data.AuthExpirationDate.GetValueOrDefault().ToLocalTime();
                    AppController.Settings.GoogleSignedIn        = false;

                    var c = new GimmicksViewController();
                    this.NavigationController.PushViewController(c, true);
                },
                                        // Service call error
                                        (error) =>
                {
                    if (error.Contains("confirm"))
                    {
                        this.VerifyButton.Hidden = false;
                    }

                    UIToast.MakeText(error, UIToastLength.Long).Show();
                },
                                        // Service call finished
                                        () =>
                {
                    _isLogginUser = false;

                    // Allow user to tap views
                    ((MainViewController)this.MainViewController).UnblockUI();
                });
            }
        }
Beispiel #3
0
        public void DidSignIn(SignIn signIn, GoogleUser user, NSError error)
        {
            try
            {
                string gClientId = AppController.Globals.GoogleClientId_iOS;
                string gEmail    = user.Profile.Email;
                string gToken    = user.Authentication.IdToken;

                _cts0 = new CancellationTokenSource();
                AppController.LoginUser(_cts0, gClientId, gEmail, gToken,
                                        (d) =>
                {
                    AppController.Settings.LastLoginUserIdUsed   = d.UserId;
                    AppController.Settings.LastLoginUsernameUsed = _email;
                    AppController.Settings.AuthAccessToken       = d.AuthAccessToken;
                    AppController.Settings.AuthExpirationDate    = d.AuthExpirationDate.GetValueOrDefault().ToLocalTime();
                    AppController.Settings.GoogleSignedIn        = true;

                    var c = new GimmicksViewController();
                    this.NavigationController.PushViewController(c, true);
                },
                                        (err) =>
                {
                    UIToast.MakeText(err, UIToastLength.Long).Show();
                },
                                        () =>
                {
                    ((MainViewController)this.MainViewController).UnblockUI();
                });
            }
            catch (Exception ex)
            {
                ((MainViewController)this.MainViewController).UnblockUI();

                UIToast.MakeText("Error logging with Google!", UIToastLength.Long).Show();
            }
            finally
            {
                // Do nothing...
            }
        }