Esempio n. 1
0
        async void userTapped(PersonBasicWebModel person, bool justRegistered)
        {
            if (string.IsNullOrEmpty(person.Name))
            {
                return;
            }
            if (this.alertAboutSettingsIfNecessary())
            {
                return;
            }

            if (person == personA)
            {
                this.activePlayerStatus = ActivePlayerStatusEnum.PlayerA;
                this.fillPickingAthletesPanel();
                return;
            }

            if (person == personB)
            {
                this.activePlayerStatus = ActivePlayerStatusEnum.PlayerB;
                this.fillPickingAthletesPanel();
                return;
            }

            if (justRegistered)
            {
                this.takePerson(person);
                return;
            }

            this.labelTitle.Text = "Please wait...";
            bool?hasPin = await App.WebService.HasPin(person.ID);

            this.labelTitle.Text = "";

            if (hasPin == false)
            {
                await this.DisplayAlert(person.Name, "This account does not have a PIN yet. Set the PIN in the 'Snooker Byb' app on your personal mobile device (under the 'Profile' page). Meanwhile you can proceed without the PIN.", "OK");

                this.takePerson(person);
                return;
            }

            if (hasPin == null)
            {
                await this.DisplayAlert("Byb", "No internet connection?", "OK");

                return;
            }

            EnterPinPage enterPinPage = new EnterPinPage(true);

            enterPinPage.TheTitle = person.Name;
            await this.Navigation.PushModalAsync(enterPinPage);

            enterPinPage.UserClickedCancel += () =>
            {
                this.Navigation.PopModalAsync();
            };
            enterPinPage.UserEnteredPin += async() =>
            {
                await this.Navigation.PopModalAsync();

                if (enterPinPage.IsPinOk == false)
                {
                    return;
                }

                this.labelTitle.Text = "Please wait...";
                bool?verified = await App.WebService.VerifyPin(person.ID, enterPinPage.Pin);

                this.labelTitle.Text = "";
                if (verified == false)
                {
                    await this.DisplayAlert("Byb", "Incorrect PIN", "OK");
                }
                else if (verified == null && App.WebService.IsLastExceptionDueToInternetIssues)
                {
                    await this.DisplayAlert("Byb", "Couldn't verify the PIN. Internet connection issues.", "OK");
                }
                else if (verified == null)
                {
                    await this.DisplayAlert("Byb", "Couldn't verify the PIN. Unspecified error.", "OK");
                }
                else
                {
                    this.takePerson(person);
                }
            };
        }
Esempio n. 2
0
        public void AskUserToEnterPin(bool asModal, bool isBlack, Action <string> onDone, Action onCanceled)
        {
            var pagePin = new EnterPinPage(isBlack)
            {
                TheTitle            = "Set Your PIN",
                IsLabelBelowVisible = true
            };

            pagePin.UserClickedCancel += async() =>
            {
                if (asModal)
                {
                    await App.Navigator.NavPage.Navigation.PopModalAsync();
                }
                else
                {
                    await App.Navigator.NavPage.PopAsync();
                }
                onCanceled();
            };
            pagePin.UserEnteredPin += () =>
            {
                // validate PIN
                var pagePin2 = new EnterPinPage(isBlack)
                {
                    TheTitle            = "Re-Enter Your PIN",
                    IsLabelBelowVisible = false
                };
                pagePin2.UserClickedCancel += async() =>
                {
                    // close both pages
                    if (asModal)
                    {
                        await App.Navigator.NavPage.Navigation.PopModalAsync();

                        await App.Navigator.NavPage.Navigation.PopModalAsync();
                    }
                    else
                    {
                        await App.Navigator.NavPage.PopAsync();

                        await App.Navigator.NavPage.PopAsync();
                    }
                    onCanceled();
                };
                pagePin2.UserEnteredPin += async() =>
                {
                    // are the pins the same?
                    string pin = pagePin.Pin;
                    if (pagePin2.Pin != pin)
                    {
                        pagePin.ClearPin();
                        if (asModal)
                        {
                            await App.Navigator.NavPage.Navigation.PopModalAsync();
                        }
                        else
                        {
                            await App.Navigator.NavPage.PopAsync();
                        }
                        await App.Navigator.NavPage.DisplayAlert("Byb", "PINs are different. Please re-enter the PIN.", "OK");

                        return;
                    }

                    // close both pages
                    if (asModal)
                    {
                        await App.Navigator.NavPage.Navigation.PopModalAsync();

                        await App.Navigator.NavPage.Navigation.PopModalAsync();
                    }
                    else
                    {
                        await App.Navigator.NavPage.PopAsync();

                        await App.Navigator.NavPage.PopAsync();
                    }

                    onDone(pin);
                };
                if (asModal)
                {
                    App.Navigator.NavPage.Navigation.PushModalAsync(pagePin2);
                }
                else
                {
                    App.Navigator.NavPage.PushAsync(pagePin2);
                }
            };
            if (asModal)
            {
                App.Navigator.NavPage.Navigation.PushModalAsync(pagePin);
            }
            else
            {
                App.Navigator.NavPage.PushAsync(pagePin);
            }
        }