public override IDisposable PromptMultiInputs(PromptConfigMultiInput config) { return(this.Present(() => { var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert); NSMutableArray txts = new NSMutableArray(); if (config.IsCancellable) { dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Cancel, x => config.OnAction?.Invoke(new PromptResultMultiInput(false, config.Inputs) ))); } var btnOk = UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => ExecutePromptResultMultiInput(config, txts) ); dlg.AddAction(btnOk); dlg.AddTextField(x => { for (int i = 0; i < config.Inputs.Count - 1; i++) { UITextField txtFiled = new UITextField(); txtFiled = x; txts.Add(txtFiled); PromptInput pInput = config.Inputs[(int)i]; if (pInput.MaxLength != -1) { txtFiled.ShouldChangeCharacters = (field, replacePosition, replacement) => { var updatedText = new StringBuilder(field.Text); updatedText.Remove((int)replacePosition.Location, (int)replacePosition.Length); updatedText.Insert((int)replacePosition.Location, replacement); return updatedText.ToString().Length <= pInput.MaxLength; }; } if (config.OnTextChanged != null) { txtFiled.Ended += (sender, e) => { var args = new PromptTextChangedArgs { Value = txtFiled.Text }; config.OnTextChanged(args); btnOk.Enabled = args.IsValid; if (!txtFiled.Text.Equals(args.Value)) { txtFiled.Text = args.Value; } }; } this.SetInputType(txtFiled, pInput.InputType); txtFiled.Placeholder = pInput.Placeholder ?? String.Empty; } }); return dlg; })); }
public PromptConfigMultiInput SetInputMode(PromptInput promptInput) { this.Inputs.Add(promptInput); return(this); }