public override IDisposable Prompt(PromptConfig config)
        {
            var         dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
            UITextField txt = null;

            if (config.IsCancellable)
            {
                dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Cancel, x =>
                                                   config.OnResult(new PromptResult(false, txt.Text.Trim())
                                                                   )));
            }
            dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x =>
                                               config.OnResult(new PromptResult(true, txt.Text.Trim())
                                                               )));
            dlg.AddTextField(x =>
            {
                this.SetInputType(x, config.InputType);
                x.Placeholder = config.Placeholder ?? String.Empty;
                if (config.Text != null)
                {
                    x.Text = config.Text;
                }

                txt = x;
            });
            return(this.Present(dlg));
        }
        protected virtual void ShowIOS8Prompt(PromptConfig config)
        {
            var         result = new PromptResult();
            var         dlg    = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
            UITextField txt    = null;

            if (config.IsCancellable)
            {
                dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Cancel, x => {
                    result.Ok   = false;
                    result.Text = txt.Text.Trim();
                    config.OnResult(result);
                }));
            }
            dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => {
                result.Ok   = true;
                result.Text = txt.Text.Trim();
                config.OnResult(result);
            }));
            dlg.AddTextField(x => {
                this.SetInputType(x, config.InputType);
                x.Placeholder = config.Placeholder ?? String.Empty;
                if (config.Text != null)
                {
                    x.Text = config.Text;
                }

                txt = x;
            });
            this.Present(dlg);
        }
        public override void Prompt(PromptConfig config)
        {
            UIApplication.SharedApplication.InvokeOnMainThread(() => {
                var result = new PromptResult();

                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    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 => {
                        Utils.SetInputType(x, config.InputType);
                        x.Placeholder = config.Placeholder ?? String.Empty;
                        txt           = x;
                    });
                    this.Present(dlg);
                }
                else
                {
                    var isPassword = config.InputType == InputType.Password;

                    var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, config.CancelText, config.OkText)
                    {
                        AlertViewStyle = isPassword
                            ? UIAlertViewStyle.SecureTextInput
                            : UIAlertViewStyle.PlainTextInput
                    };
                    var txt = dlg.GetTextField(0);
                    Utils.SetInputType(txt, config.InputType);
                    txt.Placeholder = config.Placeholder;

                    dlg.Clicked += (s, e) => {
                        result.Ok   = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex);
                        result.Text = txt.Text.Trim();
                        config.OnResult(result);
                    };
                    dlg.Show();
                }
            });
        }
示例#4
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 = this.GetInputScope(config.InputType);
            var txt        = new PhoneTextBox {
                PlaceholderText = 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);
        }
        protected virtual void ShowIOS7Prompt(PromptConfig config)
        {
            var result     = new PromptResult();
            var isPassword = (config.InputType == InputType.Password || config.InputType == InputType.NumericPassword);
            var cancelText = config.IsCancellable ? config.CancelText : null;

            var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, cancelText, config.OkText)
            {
                AlertViewStyle = isPassword
                                        ? UIAlertViewStyle.SecureTextInput
                                        : UIAlertViewStyle.PlainTextInput
            };
            var txt = dlg.GetTextField(0);

            this.SetInputType(txt, config.InputType);
            txt.Placeholder = config.Placeholder;
            if (config.Text != null)
            {
                txt.Text = config.Text;
            }

            dlg.Clicked += (s, e) => {
                result.Ok   = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex);
                result.Text = txt.Text.Trim();
                config.OnResult(result);
            };
            this.Present(dlg);
        }
示例#6
0
        public override void Prompt(PromptConfig config)
        {
            Utils.RequestMainThread(() => {
                var activity = this.getTopActivity();

                var txt = new EditText(activity)
                {
                    Hint = config.Placeholder
                };
                if (config.Text != null)
                {
                    txt.Text = config.Text;
                }

                this.SetInputType(txt, config.InputType);

                var builder = new AlertDialog
                              .Builder(activity)
                              .SetCancelable(false)
                              .SetMessage(config.Message)
                              .SetTitle(config.Title)
                              .SetView(txt)
                              .SetPositiveButton(config.OkText, (o, e) =>
                                                 config.OnResult(new PromptResult {
                    Ok   = true,
                    Text = txt.Text
                })
                                                 );

                if (config.IsCancellable)
                {
                    builder.SetNegativeButton(config.CancelText, (o, e) =>
                                              config.OnResult(new PromptResult {
                        Ok   = false,
                        Text = txt.Text
                    })
                                              );
                }

                var dialog = builder.Create();
                dialog.Window.SetSoftInputMode(SoftInput.StateVisible);
                dialog.Show();
            });
        }
示例#7
0
        public override void Prompt(PromptConfig config)
        {
            Utils.RequestMainThread(() => {
                var activity = this.GetTopActivity();

                var txt = new EditText(activity)
                {
                    Hint = config.Placeholder
                };

                EventHandler <View.KeyEventArgs> keyHandler = null;
                var successFunc = new Action <bool>(success =>
                {
                    if (keyHandler != null)
                    {
                        txt.KeyPress -= keyHandler;
                    }

                    config.OnResult(new PromptResult {
                        Ok   = success,
                        Text = txt.Text
                    });
                });
                if (config.Text != null)
                {
                    txt.Text = config.Text;
                }

                this.SetInputType(txt, config.InputType);

                var builder = new AlertDialog
                              .Builder(activity)
                              .SetCancelable(false)
                              .SetMessage(config.Message)
                              .SetTitle(config.Title)
                              .SetView(txt)
                              .SetPositiveButton(config.OkText, (s, a) => successFunc(true));

                if (config.IsCancellable)
                {
                    builder.SetNegativeButton(config.CancelText, (s, a) => successFunc(false));
                }

                var dialog = builder.ShowExt();
                keyHandler = new EventHandler <View.KeyEventArgs>((sender, e) =>
                {
                    if (e.KeyCode == Keycode.Enter ||
                        e.KeyCode == Keycode.NumpadEnter)
                    {
                        successFunc(true);
                        dialog.Dismiss();
                    }
                });
                txt.KeyPress += keyHandler;
            });
        }
        public override IDisposable Prompt(PromptConfig config)
        {
            var prompt = new CustomMessageBox
            {
                Caption           = config.Title,
                Message           = config.Message,
                LeftButtonContent = config.OkText
            };

            if (config.IsCancellable)
            {
                prompt.RightButtonContent = config.CancelText;
            }

            var password   = new PasswordBox();
            var inputScope = this.GetInputScope(config.InputType);
            var txt        = new PhoneTextBox
            {
                InputScope = inputScope
            };

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

            var isSecure = (config.InputType == InputType.NumericPassword || config.InputType == InputType.Password);

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

            prompt.Dismissed += (sender, args) =>
            {
                var ok   = args.Result == CustomMessageBoxResult.LeftButton;
                var text = isSecure ? password.Password : txt.Text.Trim();
                config.OnResult(new PromptResult(ok, text));
            };
            return(this.DispatchWithDispose(prompt.Show, prompt.Dismiss));
        }
示例#9
0
        protected virtual void ShowIOS8Prompt(PromptConfig config)
        {
            var result = new PromptResult();
            var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
            UITextField txt = null;

            if (config.IsCancellable) {
                dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Cancel, x => {
                    result.Ok = false;
                    result.Text = txt.Text.Trim();
                    config.OnResult(result);
                }));
            }
            dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => {
                result.Ok = true;
                result.Text = txt.Text.Trim();
                config.OnResult(result);
            }));
            dlg.AddTextField(x => {
                this.SetInputType(x, config.InputType);
                x.Placeholder = config.Placeholder ?? String.Empty;
                if (config.Text != null)
                    x.Text = config.Text;

                txt = x;
            });
            this.Present(dlg);
        }
示例#10
0
        protected virtual void ShowIOS7Prompt(PromptConfig config)
        {
            var result = new PromptResult();
            var isPassword = (config.InputType == InputType.Password || config.InputType == InputType.NumericPassword);
            var cancelText = config.IsCancellable ? config.CancelText : null;

            var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, cancelText, config.OkText) {
                AlertViewStyle = isPassword
                    ? UIAlertViewStyle.SecureTextInput
                    : UIAlertViewStyle.PlainTextInput
            };
            var txt = dlg.GetTextField(0);
            this.SetInputType(txt, config.InputType);
            txt.Placeholder = config.Placeholder;
            if (config.Text != null)
                txt.Text = config.Text;

            dlg.Clicked += (s, e) => {
                result.Ok = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex);
                result.Text = txt.Text.Trim();
                config.OnResult(result);
            };
            this.Present(dlg);
        }
示例#11
0
        public override void Prompt(PromptConfig config)
        {
            var prompt = new CustomMessageBox {
                Caption = config.Title,
                Message = config.Message,
                LeftButtonContent = config.OkText
            };
            if (config.IsCancellable)
                prompt.RightButtonContent = config.CancelText;

            var password = new PasswordBox();
            var inputScope = this.GetInputScope(config.InputType);
            var txt = new PhoneTextBox {
                //PlaceholderText = config.Placeholder,
                InputScope = inputScope
            };
            if (config.Text != null)
                txt.Text = config.Text;

            var isSecure = (config.InputType == InputType.NumericPassword || 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);
        }
示例#12
0
        public override void Prompt(PromptConfig config)
        {
            Utils.RequestMainThread(() => {
                var activity = this.getTopActivity();

                var txt = new EditText(activity) {
                    Hint = config.Placeholder
                };
                if (config.Text != null)
                    txt.Text = config.Text;

                this.SetInputType(txt, config.InputType);

                var builder = new AlertDialog
                    .Builder(activity)
                    .SetCancelable(false)
                    .SetMessage(config.Message)
                    .SetTitle(config.Title)
                    .SetView(txt)
                    .SetPositiveButton(config.OkText, (o, e) =>
                        config.OnResult(new PromptResult {
                            Ok = true,
                            Text = txt.Text
                        })
                    );

                if (config.IsCancellable) {
                    builder.SetNegativeButton(config.CancelText, (o, e) =>
                        config.OnResult(new PromptResult {
                            Ok = false,
                            Text = txt.Text
                        })
                    );
                }

                var dialog = builder.Create();
                dialog.Window.SetSoftInputMode(SoftInput.StateVisible);
                dialog.Show();
            });
        }