Exemplo n.º 1
0
        private void LoginTxtView_Click(object sender, System.EventArgs e)
        {
            var phInfo   = JsonConvert.SerializeObject(phoneInfo);
            var fragment = new PhoneNumberVerificationFragment();
            var bundle   = new Bundle();

            bundle.PutString("phoneInfo", phInfo);
            fragment.Arguments = bundle;


            var alertDialogBuilder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity, Resource.Style.AppTheme)
                                     .SetTitle("Phone Number Verification")
                                     .SetMessage($"We shall be verifying the phone Number {string.Concat(phoneInfo.CountryCode, phoneInfo.PhoneNumber)} by sending an SMS with a verification Code. Press Yes to continue or No modify the Phone Number")
                                     .SetNegativeButton("No", (s, arg) => { Dispose(); })
                                     .SetPositiveButton("Yes", ((s, args) =>
            {
                var transaction = FragmentManager.BeginTransaction();
                transaction.SetCustomAnimations(Resource.Animation.anim_enter, Resource.Animation.anim_exit)
                .Replace(Resource.Id.authorizationContainer, fragment)
                .AddToBackStack(null)
                .Commit();
            }))
                                     .Create();

            alertDialogBuilder.Window.SetLayout(1000, 450);
            alertDialogBuilder.Show();
        }
Exemplo n.º 2
0
        private async void TxtView_Click(object sender, EventArgs e)
        {
            var isValid = dataForm.Validate() && dataForm2.Validate();

            if (!isValid)
            {
                return;
            }
            if (!isChecked)
            {
                Toast.MakeText(Context.ApplicationContext, "Accept the terms of use", ToastLength.Short).Show();
            }
            else
            {
                if (!CrossConnectivity.Current.IsConnected)
                {
                    Toast.MakeText(Context.ApplicationContext, "No Internet Connection", ToastLength.Short).Show();
                }
                else
                {
                    dataForm.Commit();
                    dataForm2.Commit();

                    var sfBsyIndicator = new SfBusyIndicator(Context.ApplicationContext);
                    sfBsyIndicator.AnimationType  = AnimationTypes.Ball;
                    sfBsyIndicator.TitlePlacement = TitlePlacement.Top;
                    sfBsyIndicator.TextColor      = Color.Purple;
                    sfBsyIndicator.ViewBoxHeight  = 100;
                    sfBsyIndicator.ViewBoxWidth   = 100;
                    sfBsyIndicator.IsBusy         = true;
                    sfBsyIndicator.SecondaryColor = Color.Purple;
                    sfBsyIndicator.SetBackgroundResource(Color.Transparent);

                    var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity,
                                                          Resource.Style.AlertDialogTheme);
                    var alertDialog = builder.SetView(sfBsyIndicator).Create();
                    alertDialog.SetCanceledOnTouchOutside(false);
                    alertDialog.Show();
                    alertDialog.Window.SetLayout(1000, 300);

                    var phoneNumber = string.Concat(phoneInfo.CountryCode, phoneInfo.PhoneNumber);
                    var httpClient  = new HttpClient();
                    var funcUri     =
                        $"https://e-spafunctions.azurewebsites.net/api/UserExistence?code=FvvkqYX9HQxJsr4AliXfv6jqZ3uttw8wzUNezzKiXHowx4EwUVdqdQ==&phoneNo={phoneNumber}";
                    var response = await httpClient.GetAsync(funcUri);

                    alertDialog.Cancel();


                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        Toast.MakeText(Context.ApplicationContext,
                                       "An Account is already associated with that phoneNumber", ToastLength.Long).Show();
                        var str = await response.Content.ReadAsStringAsync();

                        client = JsonConvert.DeserializeObject <Client>(str);
                    }
                    else
                    {
                        var fragment = new PhoneNumberVerificationFragment();
                        var phInfo   = JsonConvert.SerializeObject(phoneInfo);
                        var usInfo   = JsonConvert.SerializeObject(userInfo);

                        var bundle = new Bundle();
                        bundle.PutString("phoneInfo", phInfo);
                        bundle.PutString("userInfo", usInfo);
                        fragment.Arguments = bundle;


                        var alertDialogBuilder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity, Resource.Style.AppTheme)
                                                 .SetTitle("Phone Number Verification")
                                                 .SetMessage($"We shall be verifying the phone Number {string.Concat(phoneInfo.CountryCode,phoneInfo.PhoneNumber)} by sending an SMS with a verification Code. Press Yes to continue or No modify the Phone Number")
                                                 .SetNegativeButton("No", (s, arg) => { Dispose(); })
                                                 .SetPositiveButton("Yes", ((s, args) =>
                        {
                            var transaction = FragmentManager.BeginTransaction();
                            transaction.SetCustomAnimations(Resource.Animation.anim_enter, Resource.Animation.anim_exit)
                            .Replace(Resource.Id.authorizationContainer, fragment)
                            .AddToBackStack("RegisterNewUser")
                            .Commit();
                        }))
                                                 .Create();
                        alertDialogBuilder.Window.SetLayout(1000, 450);
                        alertDialogBuilder.Show();
                    }
                }
            }
        }