public async Task <Tuple <string, PopupResultEnum> > OpenCancellableTextInputAlertDialog(string inputText) { // create the TextInputView var inputView = new TextInputCancellableView( "Nom de la liste ?", "Nouveau nom...", inputText, "Enregistrer", "Annuler", "Supprimer", "Le nom ne peut pas être vide."); // create the Transparent Popup Page // of type string since we need a string return var popup = new InputAlertDialogBase <Tuple <string, PopupResultEnum> >(inputView); // subscribe to the TextInputView's Button click event inputView.SaveButtonEventHandler += (sender, obj) => { if (!string.IsNullOrEmpty(((TextInputCancellableView)sender).TextInputResult)) { ((TextInputCancellableView)sender).IsValidationLabelVisible = false; popup.PageClosedTaskCompletionSource.SetResult(new Tuple <string, PopupResultEnum>(((TextInputCancellableView)sender).TextInputResult, PopupResultEnum.Save)); } else { ((TextInputCancellableView)sender).IsValidationLabelVisible = true; } }; // subscribe to the TextInputView's Button click event inputView.CancelButtonEventHandler += (sender, obj) => { popup.PageClosedTaskCompletionSource.SetResult(new Tuple <string, PopupResultEnum>(null, PopupResultEnum.Cancel)); }; inputView.DeleteButtonEventHandler += (sender, obj) => { popup.PageClosedTaskCompletionSource.SetResult(new Tuple <string, PopupResultEnum>(null, PopupResultEnum.Delete)); }; // Push the page to Navigation Stack await PopupNavigation.Instance.PushAsync(popup, true); // await for the user to enter the text input var result = await popup.PageClosedTask; // Pop the page from Navigation Stack await PopupNavigation.Instance.PopAsync(); // return user inserted text value return(result); }
private async Task <string> OpenCancellableTextInputAlertDialog() { // create the TextInputView var inputView = new TextInputCancellableView( "How's your day mate?", "enter here...", "Save", "Cancel", "Ops! Can't leave this empty!"); // create the Transparent Popup Page // of type string since we need a string return var popup = new InputAlertDialogBase <string>(inputView); // subscribe to the TextInputView's Button click event inputView.SaveButtonEventHandler += (sender, obj) => { if (!string.IsNullOrEmpty(((TextInputCancellableView)sender).TextInputResult)) { ((TextInputCancellableView)sender).IsValidationLabelVisible = false; popup.PageClosedTaskCompletionSource.SetResult(((TextInputCancellableView)sender).TextInputResult); } else { ((TextInputCancellableView)sender).IsValidationLabelVisible = true; } }; // subscribe to the TextInputView's Button click event inputView.CancelButtonEventHandler += (sender, obj) => { popup.PageClosedTaskCompletionSource.SetResult(null); }; // Push the page to Navigation Stack await PopupNavigation.PushAsync(popup); // await for the user to enter the text input var result = await popup.PageClosedTask; // Pop the page from Navigation Stack await PopupNavigation.PopAsync(); // return user inserted text value return(result); }
public async Task <string> OpenCancellableTextInputAlertDialog(string titleText, string placeHolderText, string saveButtonText, string cancelButtonText, string validationText) { // create the TextInputView var inputView = new TextInputCancellableView(titleText, placeHolderText, saveButtonText, cancelButtonText, validationText); // create the Transparent Popup Page // of type string since we need a string return var popup = new InputAlertDialogBase <string>(inputView); // subscribe to the TextInputView's Button click event inputView.SaveButtonEventHandler += (sender, obj) => { if (!string.IsNullOrEmpty(((TextInputCancellableView)sender).TextInputResult)) { ((TextInputCancellableView)sender).IsValidationLabelVisible = false; popup.PageClosedTaskCompletionSource.SetResult(((TextInputCancellableView)sender).TextInputResult); } else { ((TextInputCancellableView)sender).IsValidationLabelVisible = true; } }; // subscribe to the TextInputView's Button click event inputView.CancelButtonEventHandler += (sender, obj) => { popup.PageClosedTaskCompletionSource.SetResult(null); }; // return user inserted text value return(await Navigate(popup)); }