private async void OnSMSClicked(object sender, EventArgs e)
        {
            var messanger = CrossMessaging.Current.SmsMessenger;

            if (messanger.CanSendSms)
            {
                var config = new PromptConfig()
                {
                    OnTextChanged = args => {
                        args.IsValid = true;
                        args.Value   = "I need your help.";
                    },
                    OkText     = "Send",
                    CancelText = "Cancel",
                    Title      = Mechanic.Name,
                    Text       = "I need your help."
                };
                string messageToSend = string.Empty;
                using (UserDialogs.Instance.Prompt(config))
                {
                    messageToSend = config.Text;
                }

                messanger.SendSms(Mechanic.ContactNo, messageToSend);
            }
        }
        public async Task <(bool, string)> PromptAsync(
            string message,
            string title,
            string okText,
            string cancelText,
            string placeholder,
            string inputText       = null,
            int?maxLength          = null,
            bool inputTypePassword = false)
        {
            PromptConfig config = new PromptConfig
            {
                Message     = message,
                Title       = title,
                Text        = inputText,
                OkText      = okText,
                CancelText  = cancelText,
                Placeholder = placeholder,
                MaxLength   = maxLength,
                InputType   = inputTypePassword ? InputType.Password : InputType.Name,
            };
            var promtResult = await _dialogs.PromptAsync(config);

            var result = (promtResult.Ok, promtResult.Text);

            return(result);
        }
Example #3
0
        private void AddDebtBack()
        {
            PromptConfig config = new PromptConfig();

            config.SetAction((result) =>
            {
                if (!result.Ok || Debt == null || string.IsNullOrWhiteSpace(result.Value))
                {
                    return;
                }

                if (Debt.ValuesBack == null)
                {
                    Debt.ValuesBack = new List <DebtBack>();
                }

                Debt.ValuesBack.Add(new DebtBack()
                {
                    DebtId = Debt.Id,
                    Value  = Convert.ToDecimal(result.Value)
                });
                RaisePropertyChanged(() => Debt);
            });
            config.SetInputMode(InputType.Phone);
            config.SetMessage(ResourceService.GetString("setValue"));
            config.OkText     = ResourceService.GetString("ok");
            config.CancelText = ResourceService.GetString("cancel");
            UserDialogs.Instance.Prompt(config);
        }
Example #4
0
        public async Task <string> ShowPromt(string title)
        {
            try
            {
                PromptConfig config = new PromptConfig()
                {
                    CancelText    = "取消",
                    InputType     = InputType.Default,
                    IsCancellable = true,
                    OkText        = "确定",
                    Title         = title,
                    Text          = ""
                };
                var result = await UserDialogs.Instance.PromptAsync(config);

                if (result.Ok)
                {
                    return(result.Text);
                }
            }
            catch (Exception)
            {
            }
            return("Cancel");
        }
Example #5
0
        public async Task <(bool, string)> EnterStringAsync
        (
            string title,
            string message,
            string initialValue,
            int maxLength,
            Action <PromptTextChangedArgs> onTextChanged
        )
        {
            var config = new PromptConfig
            {
                Title         = title,
                Message       = message,
                Text          = initialValue,
                MaxLength     = maxLength,
                OnTextChanged = onTextChanged
            };
            var result = await UserDialogs.Instance.PromptAsync(config);

            if (result.Ok)
            {
                return(true, result.Text);
            }

            return(false, string.Empty);
        }
Example #6
0
        public void InputDialog(string message, string title, string okText, string cancelText, int styleId, Action <PromptResult> onAction)
        {
            PromptConfig p = new PromptConfig();

            p.InputType = InputType.Number;

            if (okText != null)
            {
                p.OkText = okText;
            }

            if (cancelText != null)
            {
                p.CancelText = cancelText;
            }

            p.Message  = message;
            p.Title    = title ?? "";
            p.OnAction = onAction;

            if (styleId > 0)
            {
                p.AndroidStyleId = styleId;
            }

            UserDialogs.Instance.Prompt(p);
        }
Example #7
0
        async void NewSoundDialog()
        {
            var newMicIdDialog = new PromptConfig();

            newMicIdDialog.SetInputMode(InputType.Default);
            newMicIdDialog.Title       = "Record a new sound";
            newMicIdDialog.Message     = "What is the name of this sound?";
            newMicIdDialog.OkText      = "NEXT";
            newMicIdDialog.CancelText  = "CANCEL";
            newMicIdDialog.Placeholder = "Doorbell";
            var micIdResponse = await UserDialogs.Instance.PromptAsync(newMicIdDialog);

            if (micIdResponse.Ok)
            {
                Regex r = new Regex("^[a-zA-Z0-9]*$");
                if (!r.IsMatch(micIdResponse.Text) || micIdResponse.Text == "")
                {
                    UserDialogs.Instance.Alert("Please use a different name.");
                }
                else
                {
                    var newDialog = new ConfirmConfig();
                    newDialog.Message = "Have your mic ready to record your sound, then press the record button. ";
                    newDialog.OkText  = "RECORD";
                    newDialog.Title   = "Record a new sound";

                    var recordResponse = await UserDialogs.Instance.ConfirmAsync(newDialog);

                    if (recordResponse)
                    {
                        AddNewSoundRequest(micIdResponse.Text);
                    }
                }
            }
        }
Example #8
0
        private void AddMail()
        {
            PromptConfig config = new PromptConfig();

            config.SetAction((result) =>
            {
                if (!result.Ok || Debtor == null || string.IsNullOrWhiteSpace(result.Value))
                {
                    return;
                }

                if (Debtor.Mails == null)
                {
                    Debtor.Mails = new MvxObservableCollection <Mail>();
                }

                Debtor.Mails.Add(new Mail()
                {
                    Address = result.Value
                });
                RaisePropertyChanged(() => Debtor);
            });
            config.SetInputMode(InputType.Email);
            config.SetMessage(ResourceService.GetString("setMailAddress"));
            UserDialogs.Instance.Prompt(config);
        }
Example #9
0
        private void EditMail(Mail mail)
        {
            if (mail == null)
            {
                return;
            }

            PromptConfig config = new PromptConfig();

            config.SetAction((result) =>
            {
                if (!result.Ok || Debtor == null || string.IsNullOrWhiteSpace(result.Value))
                {
                    return;
                }

                mail.Address = result.Value;
                RaisePropertyChanged(() => Debtor);
            });
            config.SetInputMode(InputType.Email);
            config.SetMessage(ResourceService.GetString("setMailAddress"));
            config.SetText(mail.Address);
            config.OkText     = ResourceService.GetString("ok");
            config.CancelText = ResourceService.GetString("cancel");
            UserDialogs.Instance.Prompt(config);
        }
Example #10
0
        private void AddPhone()
        {
            PromptConfig config = new PromptConfig();

            config.SetAction((result) =>
            {
                if (!result.Ok || Debtor == null || string.IsNullOrWhiteSpace(result.Value))
                {
                    return;
                }

                if (Debtor.Phones == null)
                {
                    Debtor.Phones = new MvxObservableCollection <Phone>();
                }

                Debtor.Phones.Add(new Phone()
                {
                    Number = result.Value,
                    Type   = PhoneNumberType.Mobile
                });
                RaisePropertyChanged(() => Debtor);
            });
            config.SetInputMode(InputType.Phone);
            config.SetMessage(ResourceService.GetString("setPhoneNumber"));
            config.OkText     = ResourceService.GetString("ok");
            config.CancelText = ResourceService.GetString("cancel");
            UserDialogs.Instance.Prompt(config);
        }
Example #11
0
        private void EditPhone(Phone phone)
        {
            if (phone == null)
            {
                return;
            }

            PromptConfig config = new PromptConfig();

            config.SetAction((result) =>
            {
                if (!result.Ok || Debtor == null || string.IsNullOrWhiteSpace(result.Value))
                {
                    return;
                }

                phone.Number = result.Value;
                RaisePropertyChanged(() => Debtor);
            });
            config.SetInputMode(InputType.Phone);
            config.SetMessage(ResourceService.GetString("setPhoneNumber"));
            config.SetText(phone.Number);
            config.OkText     = ResourceService.GetString("ok");
            config.CancelText = ResourceService.GetString("cancel");
            UserDialogs.Instance.Prompt(config);
        }
Example #12
0
        async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
        {
            var evento = args.SelectedItem as Wifi;

            if (evento == null)
            {
                return;
            }
            viewModel.SelectedNetwork = evento;
            if (evento.SecurityType != WifiSecurityType.NONE)
            {
                PromptConfig config = new PromptConfig();
                config.InputType     = InputType.Password;
                config.IsCancellable = true;
                config.SetTitle("Ingrese password");
                config.SetMessage("Ingrese el password de la red wifi " + evento.Ssid);
                PromptResult result = await UserDialogs.Instance.PromptAsync(config);

                if (result.Ok)
                {
                    evento.Password = result.Text;
                }
                else
                {
                    WifisListView.SelectedItem = null;
                    return;
                }
            }
            viewModel.ConnectToNetworkCommand.Execute(evento);
            viewModel.GetConnectedNetworkCommand.Execute(null);
            WifisListView.SelectedItem = null;
        }
Example #13
0
        async Task ExecuteAddWasteCommand()
        {
            var promptConfig = new PromptConfig();

            promptConfig.Title       = "Add to Wasted Food Count";
            promptConfig.OkText      = "Add";
            promptConfig.Placeholder = "Quantity (lbs)";
            var response = await UserDialogs.Instance.PromptAsync(promptConfig);

            int?amount = ProcessInput(response);

            if (amount.HasValue)
            {
                var result = await wasteRep.CreateWaste(amount.Value);

                if (!result)
                {
                    UserDialogs.Instance.Alert("Something went wrong.\nPlease try again later.");
                }
                else
                {
                    yearWasted += amount.Value;
                    OnPropertyChanged("YearWasted");
                    Model = GeneratePlotModel();
                    OnPropertyChanged("Model");
                }
            }
        }
Example #14
0
        public static AppCompatAlertDialog.Builder Build(AppCompatActivity activity, PromptConfig config)
        {
            var txt = new EditText(activity)
            {
                Hint = config.Placeholder
            };

            if (config.Text != null)
            {
                txt.Text = config.Text;
            }

            SetInputType(txt, config.InputType);

            var builder = new AppCompatAlertDialog
                          .Builder(activity)
                          .SetCancelable(false)
                          .SetMessage(config.Message)
                          .SetTitle(config.Title)
                          .SetView(txt)
                          .SetPositiveButton(config.OkText, (s, a) =>
                                             config.OnResult(new PromptResult(true, txt.Text.Trim()))
                                             );

            if (config.IsCancellable)
            {
                builder.SetNegativeButton(config.CancelText, (s, a) =>
                                          config.OnResult(new PromptResult(false, txt.Text.Trim()))
                                          );
            }
            return(builder);
        }
        async void NewMicDialog()
        {
            var newMicIdDialog = new PromptConfig();

            newMicIdDialog.SetInputMode(InputType.Default);
            newMicIdDialog.Title       = "Add a new mic";
            newMicIdDialog.OkText      = "NEXT";
            newMicIdDialog.CancelText  = "CANCEL";
            newMicIdDialog.Placeholder = "Mic ID";
            var micIdResponse = await UserDialogs.Instance.PromptAsync(newMicIdDialog);

            if (micIdResponse.Ok)
            {
                Regex r = new Regex("^[a-zA-Z0-9]*$");
                if (!r.IsMatch(micIdResponse.Text) || micIdResponse.Text == "")
                {
                    UserDialogs.Instance.Alert("Please enter a valid Mic ID!");
                }
                else
                {
                    var newMicNameDialog = new PromptConfig();
                    newMicNameDialog.SetInputMode(InputType.Name);
                    newMicIdDialog.Title       = "Would you like to name your mic?";
                    newMicIdDialog.OkText      = "ADD";
                    newMicIdDialog.CancelText  = "CANCEL";
                    newMicIdDialog.Placeholder = "Mic Name (Optional)";
                    var micNameResponse = await UserDialogs.Instance.PromptAsync(newMicIdDialog);

                    if (micNameResponse.Ok)
                    {
                        AddNewMic(micIdResponse.Text, micNameResponse.Text);
                    }
                }
            }
        }
Example #16
0
        async void CmdSignupExecute(object obj)
        {
            try
            {
                using (UserDialogs.Instance.Loading("Please wait..."))
                {
                    await _services.Authentication.SignupCognito(username, password, email);
                }

                PromptConfig pc = new PromptConfig
                {
                    Title = "Check your email for the verification code!",
                };

                PromptResult pr = await UserDialogs.Instance.PromptAsync(pc);

                using (UserDialogs.Instance.Loading("Confirming verification code..."))
                {
                    await _services.Authentication.VerifyUserCognito(username, pr.Text);
                }

                using (UserDialogs.Instance.Loading("Logging in..."))
                {
                    await _services.Authentication.LoginCognito(username, password);
                }

                //SUCCESS
                _services.Navigation.GoToUserPagesPage(_services.Authentication.CurrentUser, true);
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.Alert(ex.Message, "Signup error");
            }
        }
        private async void createAlbum()
        {
            PromptConfig prompt = new PromptConfig();

            prompt.SetCancelText("Cancel");
            prompt.SetOkText("Create");
            prompt.SetMessage("Create New Album");
            prompt.SetInputMode(InputType.Default);

            PromptResult promptResult = await UserDialogs.Instance.PromptAsync(prompt);

            if (!promptResult.Ok)
            {
                return;
            }

            if (FSManager.albumExists(promptResult.Text))
            {
                await DisplayAlert("Notice", "Album name already exists", "OK");
            }
            else
            {
                Dir newAlbum = await FSManager.addNewAlbumAsync(promptResult.Text);

                this.albumsToDisplay.Add(newAlbum);
            }
        }
Example #18
0
        public async Task <PromptResult> InputDialogAsync(string message, string title, string okText, string cancelText, InputType inputType, int styleId, string text)
        {
            PromptConfig p = new PromptConfig();

            p.InputType = inputType;

            if (okText != null)
            {
                p.OkText = okText;
            }

            if (cancelText != null)
            {
                p.CancelText = cancelText;
            }

            p.Message = message;
            p.Title   = title ?? "";

            if (!string.IsNullOrEmpty(text))
            {
                p.Text = text;
            }

            if (styleId > 0)
            {
                p.AndroidStyleId = styleId;
            }

            return(await UserDialogs.Instance.PromptAsync(p));
        }
Example #19
0
 public override void Prompt(PromptConfig config)
 {
     Utils.RequestMainThread(() => {
         var txt = new EditText(Utils.GetActivityContext())
         {
             Hint = config.Placeholder
         };
         txt.SetMaxLines(1);
         if (config.IsSecure)
         {
             txt.TransformationMethod = PasswordTransformationMethod.Instance;
             txt.InputType            = InputTypes.ClassText | InputTypes.TextVariationPassword;
         }
         new AlertDialog
         .Builder(Utils.GetActivityContext())
         .SetMessage(config.Message)
         .SetTitle(config.Title)
         .SetView(txt)
         .SetPositiveButton(config.OkText, (o, e) =>
                            config.OnResult(new PromptResult {
             Ok   = true,
             Text = txt.Text
         })
                            )
         .SetNegativeButton(config.CancelText, (o, e) =>
                            config.OnResult(new PromptResult {
             Ok   = false,
             Text = txt.Text
         })
                            )
         .Show();
     });
 }
Example #20
0
        public override void Prompt(PromptConfig config)
        {
            var prompt = new CustomMessageBox {
                Caption            = config.Title,
                Message            = config.Message,
                LeftButtonContent  = config.OkText,
                RightButtonContent = config.CancelText
            };

            var password   = new PasswordBox();
            var inputScope = GetInputScope(config.InputType);
            var txt        = new PhoneTextBox {
                Hint = config.Placeholder, InputScope = inputScope
            };
            var isSecure = config.InputType == InputType.Password;

            if (isSecure)
            {
                prompt.Content = password;
            }
            else
            {
                prompt.Content = txt;
            }

            prompt.Dismissed += (sender, args) => config.OnResult(new PromptResult {
                Ok   = args.Result == CustomMessageBoxResult.LeftButton,
                Text = isSecure
                    ? password.Password
                    : txt.Text.Trim()
            });
            this.Dispatch(prompt.Show);
        }
Example #21
0
        private async Task EditList(TodoList todoList)
        {
            try
            {
                PromptConfig PromptConfig = new PromptConfig {
                    Message = "Please enter the new title", Title = "Editing", OkText = "Save", InputType = InputType.Default, Text = todoList.Title
                };
                PromptResult promptResult = await this._userDialogs.PromptAsync(PromptConfig).ConfigureAwait(false);

                if (promptResult.Ok)
                {
                    todoList.Title = promptResult.Value;
                    if (await this._todoListUseCase.EditTodoList(todoList))
                    {
                        this._userDialogs.Toast("Done!!");
                        this.TodoLists.Remove(todoList);
                        this.TodoLists.Add(todoList);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.ProcessException(ex, this._userDialogs);
            }
            finally
            {
                this.IsBusy = false;
            }
        }
Example #22
0
        public static async Task <string> ShowInputPrompt(string Ok, string Cancel, string Title, string subTitle, string inputText, InputType type)
        {
            PromptConfig t_config = new PromptConfig();

            t_config.SetCancelText(Cancel);
            t_config.SetOkText(Ok);
            t_config.SetTitle(Title);
            t_config.SetInputMode(type);
            t_config.SetText(inputText);
            t_config.SetMessage(subTitle);

            PromptResult tm = await UserDialogs.Instance.PromptAsync(t_config);

            if (tm.Ok)
            {
                return(tm.Text);
            }

            if (tm.Text.Length > 0)   // Work around for IOS
            {
                return(tm.Text);
            }

            return(null);
        }
        public IObservable <string> Question(PromptConfig config) => Observable.FromAsync <string>(async ct =>
        {
            this.tts.Speak(config.Message, cancelToken: ct);

            var promptTask = this.dialogs.PromptAsync(config, ct);
            var speechTask = this.speech
                             .ListenUntilPause()
                             .ToTask(ct);

            var finishTask = await Task.WhenAny(promptTask, speechTask);
            if (ct.IsCancellationRequested)
            {
                return(null);
            }

            if (finishTask == promptTask)
            {
                return(promptTask.Result.Text);
            }

            if (finishTask == speechTask)
            {
                return(speechTask.Result);
            }

            return(null);
        });
        private async void createCard_Clicked(object sender, EventArgs e)
        {
            PromptConfig prompt = new PromptConfig();

            prompt.SetCancelText("Cancel");
            prompt.SetOkText("Create");
            prompt.SetMessage("Name Card");
            prompt.SetInputMode(InputType.Default);

            PromptResult promptResult = await UserDialogs.Instance.PromptAsync(prompt);

            if (promptResult.Ok)
            {
                Card newCard = await FSManager.addNewCardAsync(promptResult.Text);

                allCardsToDisplay.Add(newCard);

                if (mediasToAdd != null)
                {
                    addMediaToCard(newCard);
                }
            }

            // Resort cards
            allCardsToDisplay = new ObservableCollection <Card>(FSManager.getAllCards());
            cardsHeaderView.updateDataSet(allCardsToDisplay);
        }
Example #25
0
        public override void Prompt(PromptConfig config)
        {
            Utils.RequestMainThread(() => {
                var txt = new EditText(Utils.GetActivityContext())
                {
                    Hint = config.Placeholder
                };

                if (config.InputType != InputType.Default)
                {
                    txt.SetMaxLines(1);
                }

                SetInputType(txt, config.InputType);

                new AlertDialog
                .Builder(Utils.GetActivityContext())
                .SetMessage(config.Message)
                .SetTitle(config.Title)
                .SetView(txt)
                .SetPositiveButton(config.OkText, (o, e) =>
                                   config.OnResult(new PromptResult {
                    Ok   = true,
                    Text = txt.Text
                })
                                   )
                .SetNegativeButton(config.CancelText, (o, e) =>
                                   config.OnResult(new PromptResult {
                    Ok   = false,
                    Text = txt.Text
                })
                                   )
                .Show();
            });
        }
Example #26
0
        protected void SignUp_Clicked(object sender, EventArgs e)
        {
            var    communityEvent = this.BindingContext as CommunityEvent;
            string username       = string.Empty;

            if (Application.Current.Properties.ContainsKey("username"))
            {
                username = Application.Current.Properties["username"] as string;
            }

            if (string.IsNullOrEmpty(username) && communityEvent != null)
            {
                var promptConfig = new PromptConfig {
                    CancelText    = "Cancel",
                    IsCancellable = true,
                    OkText        = "OK",
                    Message       = "this will be saved to the application preferences which will be used on your next sign up",
                    Title         = "Signup Name",
                    InputType     = InputType.Default,
                    Placeholder   = "Your Name",
                    OnResult      = this.OnSignUp
                };
                UserDialogs.Instance.Prompt(promptConfig);
            }
            else
            {
                this.SignUp(username);
            }
        }
Example #27
0
        public static Task <string> AskForPassword(string message, string title)
        {
            var task         = new TaskCompletionSource <string>();
            var promptConfig = new PromptConfig()
                               .SetCancellable(true)
                               .SetOkText(AppResources.OK)
                               .SetCancelText(AppResources.CANCEL)
                               .SetMessage(message)
                               .SetTitle(title)
                               .SetPlaceholder(AppResources.PASSWORD)
                               .SetInputMode(InputType.Password);

            promptConfig.OnAction = entrada =>
            {
                if (entrada.Ok)
                {
                    task.SetResult(entrada.Value);
                }
                else
                {
                    task.SetCanceled();
                }
            };

            UserDialogs.Instance.Prompt(promptConfig);
            return(task.Task);
        }
Example #28
0
        public async Task <UserPromptResult> ShowPromptAsync(UserPromptConfig config)
        {
            UserPromptResult retInput = null;
            var          notificator  = UserDialogs.Instance;
            PromptConfig pConfig      = new PromptConfig
            {
                Message       = config.Message,
                InputType     = InputType.Default,
                Title         = config.Caption,
                Placeholder   = config.LabelText,
                Text          = config.DefaultInput,
                IsCancellable = config.CanCancel,
                OkText        = config.OkText,
                CancelText    = config.CancelText
            };

            if (config.InputCompulsory)
            {
                pConfig.OnTextChanged = args =>
                {
                    args.IsValid = !string.IsNullOrWhiteSpace(args.Value);
                };
            }

            PromptResult promptResult = await notificator.PromptAsync(pConfig);

            retInput = new UserPromptResult
            {
                Cancelled = !promptResult.Ok,
                InputText = promptResult.Text
            };

            return(retInput);
        }
Example #29
0
        public async void OnSaleSelected(object sender, SelectedItemChangedEventArgs args)
        {
            var item = args.SelectedItem as WatchItem;

            if (item == null)
            {
                return;
            }
            PromptConfig config = new PromptConfig
            {
                Title       = "Update",
                Message     = "Update Watch Item",
                Placeholder = "Watch Item",
                OkText      = "Save",
                Text        = item.Name
            };
            var dialog = await UserDialogs.Instance.PromptAsync(config);

            var       itemName   = dialog.Value;
            WatchItem updateItem = new WatchItem
            {
                Id   = item.Id,
                Name = itemName
            };
            await viewModel.WatchItemStore.UpdateItemAsync(updateItem);

            WatchItemListView.SelectedItem = null;
            //TODO: add INotify
        }
Example #30
0
        private async Task ReadUserInput()
        {
            PromptConfig userInput = new PromptConfig
            {
                Message = "Please enter a write value"
            };

            message = await UserDialogs.Instance.PromptAsync(userInput);
        }
        public override void Prompt(PromptConfig config) {
            this.Dispatch(() =>  {
                var result = new PromptResult();
                var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, config.CancelText, config.OkText) {
                    AlertViewStyle = config.InputType == InputType.Password
                        ? UIAlertViewStyle.SecureTextInput
                        : UIAlertViewStyle.PlainTextInput
                };
                var txt = dlg.GetTextField(0);
                txt.SecureTextEntry = config.InputType == InputType.Password;
                txt.Placeholder = config.Placeholder;
                txt.KeyboardType = Utils.GetKeyboardType(config.InputType);

                dlg.Clicked += (s, e) => {
                    result.Ok = (dlg.CancelButtonIndex != e.ButtonIndex);
                    result.Text = txt.Text;
                    config.OnResult(result);
                };
                dlg.Show();
            });
        }
        public override void Prompt(PromptConfig config) {
            var prompt = new CustomMessageBox {
                Caption = config.Title,
                Message = config.Message,
                LeftButtonContent = config.OkText,
                RightButtonContent = config.CancelText
            };

            var password = new PasswordBox();
            var txt = new PhoneTextBox { Hint = config.Placeholder };
            if (config.IsSecure)
                prompt.Content = password;
            else 
                prompt.Content = txt;

            prompt.Dismissed += (sender, args) => config.OnResult(new PromptResult {
                Ok = args.Result == CustomMessageBoxResult.LeftButton,
                Text = config.IsSecure
                    ? password.Password
                    : txt.Text.Trim()
            });
            this.Dispatch(prompt.Show);
        }
        public override void Prompt(PromptConfig config)
        {
            var result = new PromptResult();
            var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
            UITextField txt = null;

            dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => {
                result.Ok = true;
                result.Text = txt.Text.Trim();
                config.OnResult(result);
            }));
            dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => {
                result.Ok = false;
                result.Text = txt.Text.Trim();
                config.OnResult(result);
            }));
            dlg.AddTextField(x => {
                x.SecureTextEntry = config.IsSecure;
                x.Placeholder = config.Placeholder ?? String.Empty;
                txt = x;
            });
            this.Present(dlg);
        }
        public override void Prompt(PromptConfig config) {
            Utils.RequestMainThread(() => {
                var txt = new EditText(Utils.GetActivityContext()) {
                    Hint = config.Placeholder
                };

                if (config.InputType != InputType.Default) 
					txt.SetMaxLines(1);

                SetInputType(txt, config.InputType);

                new AlertDialog
                    .Builder(Utils.GetActivityContext())
                    .SetMessage(config.Message)
                    .SetCancelable(false)
                    .SetTitle(config.Title)
                    .SetView(txt)
                    .SetPositiveButton(config.OkText, (o, e) =>
                        config.OnResult(new PromptResult {
                            Ok = true, 
                            Text = txt.Text
                        })
                    )
                    .SetNegativeButton(config.CancelText, (o, e) => 
                        config.OnResult(new PromptResult {
                            Ok = false, 
                            Text = txt.Text
                        })
                    )
                    .Show();
            });
        }
        //public override void DateTimePrompt(DateTimePromptConfig config) {
        //    var date = DateTime.Now;
        //    switch (config.SelectionType) {
                
        //        case DateTimeSelectionType.DateTime: // TODO
        //        case DateTimeSelectionType.Date:
        //            var datePicker = new DatePickerDialog(Utils.GetActivityContext(), (sender, args) => {
        //                date = args.Date;
        //            }, 1900, 1, 1);
        //            //picker.CancelEvent
        //            datePicker.DismissEvent += (sender, args) => config.OnResult(new DateTimePromptResult(date));
        //            datePicker.SetTitle(config.Title);
        //            datePicker.Show();
                    
        //            break;

        //        case DateTimeSelectionType.Time:
        //            var timePicker = new TimePickerDialog(Utils.GetActivityContext(), (sender, args) => {
        //                date = new DateTime(
        //                    date.Year,
        //                    date.Month,
        //                    date.Day,
        //                    args.HourOfDay,
        //                    args.Minute,
        //                    0
        //                );
        //            }, 0, 0, false); // takes 24 hour arg
        //            timePicker.DismissEvent += (sender, args) => config.OnResult(new DateTimePromptResult(date));
        //            timePicker.SetTitle(config.Title);
        //            timePicker.Show();
        //            break;
        //    }
        //}


        //public override void DurationPrompt(DurationPromptConfig config) {
        //    // TODO
        //    throw new NotImplementedException();
        //}


        public override void Prompt(PromptConfig config) {
            Utils.RequestMainThread(() => {
                var txt = new EditText(Utils.GetActivityContext()) {
                    Hint = config.Placeholder
                };
                if (config.IsSecure)
                    //txt.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword;
                    txt.TransformationMethod = PasswordTransformationMethod.Instance;

                new AlertDialog
                    .Builder(Utils.GetActivityContext())
                    .SetMessage(config.Message)
                    .SetTitle(config.Title)
                    .SetView(txt)
                    .SetPositiveButton(config.OkText, (o, e) =>
                        config.OnResult(new PromptResult {
                            Ok = true, 
                            Text = txt.Text
                        })
                    )
                    .SetNegativeButton(config.CancelText, (o, e) => 
                        config.OnResult(new PromptResult {
                            Ok = false, 
                            Text = txt.Text
                        })
                    )
                    .Show();
            });
        }
        //public override void DateTimePrompt(DateTimePromptConfig config) {
        //    var sheet = new ActionSheetDatePicker {
        //        Title = config.Title,
        //        DoneText = config.OkText
        //    };

        //    switch (config.SelectionType) {
                
        //        case DateTimeSelectionType.Date:
        //            sheet.DatePicker.Mode = UIDatePickerMode.Date;
        //            break;

        //        case DateTimeSelectionType.Time:
        //            sheet.DatePicker.Mode = UIDatePickerMode.Time;
        //            break;

        //        case DateTimeSelectionType.DateTime:
        //            sheet.DatePicker.Mode = UIDatePickerMode.DateAndTime;
        //            break;
        //    }
            
        //    if (config.MinValue != null)
        //        sheet.DatePicker.MinimumDate = config.MinValue.Value;

        //    if (config.MaxValue != null)
        //        sheet.DatePicker.MaximumDate = config.MaxValue.Value;

        //    sheet.DateTimeSelected += (sender, args) => {
        //        // TODO: stop adjusting date/time
        //        config.OnResult(new DateTimePromptResult(sheet.DatePicker.Date));
        //    };

        //    var top = Utils.GetTopView();
        //    sheet.Show(top);
        //    //sheet.DatePicker.MinuteInterval
        //}


        //public override void DurationPrompt(DurationPromptConfig config) {
        //    var sheet = new ActionSheetDatePicker {
        //        Title = config.Title,
        //        DoneText = config.OkText
        //    };
        //    sheet.DatePicker.Mode = UIDatePickerMode.CountDownTimer;

        //    sheet.DateTimeSelected += (sender, args) => config.OnResult(new DurationPromptResult(args.TimeOfDay));

        //    var top = Utils.GetTopView();
        //    sheet.Show(top);
        //}


        public override void Prompt(PromptConfig config) {
            Device.BeginInvokeOnMainThread(() => {
                var result = new PromptResult();
                var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, config.CancelText, config.OkText) {
                    AlertViewStyle = config.IsSecure
                        ? UIAlertViewStyle.SecureTextInput 
                        : UIAlertViewStyle.PlainTextInput
                };
                var txt = dlg.GetTextField(0);
                txt.SecureTextEntry = config.IsSecure;
                txt.Placeholder = config.Placeholder;

                //UITextView = editable
                dlg.Clicked += (s, e) => {
                    result.Ok = (dlg.CancelButtonIndex != e.ButtonIndex);
                    result.Text = txt.Text;
                    config.OnResult(result);
                };
                dlg.Show();
            });
        }