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); }
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(); }); }
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(); }); }
public override void Prompt(PromptConfig config) { Device.BeginInvokeOnMainThread(() => { 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 => { x.SecureTextEntry = config.IsSecure; x.Placeholder = config.Placeholder ?? String.Empty; txt = x; }); Present(dlg); } else { 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((nint)0); txt.SecureTextEntry = config.IsSecure; 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(); } }); }
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); }
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) { 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.InputType == InputType.Password; x.Placeholder = config.Placeholder ?? String.Empty; x.KeyboardType = Utils.GetKeyboardType(config.InputType); txt = x; }); this.Present(dlg); }
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.IsSecure ? UIAlertViewStyle.SecureTextInput : UIAlertViewStyle.PlainTextInput }; var txt = dlg.GetTextField(0); txt.SecureTextEntry = config.IsSecure; txt.Placeholder = config.Placeholder; dlg.Clicked += (s, e) => { result.Ok = (dlg.CancelButtonIndex != e.ButtonIndex); result.Text = txt.Text; config.OnResult(result); }; dlg.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(); }); }
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 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 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) { 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(); }); }