public async Task <MyDataModel> OpenMultipleDataInputAlertDialog(string title1Text, string title2Text, string entry1PlaceholderValue, string entry2PlaceholderValue, double sliderMinValue, double sliderMaxValue, string saveButtonText, string cancelButtonText) { // create the TextInputView var inputView = new MultipleDataInputView(title1Text, title2Text, entry1PlaceholderValue, entry2PlaceholderValue, sliderMinValue, sliderMaxValue, saveButtonText, cancelButtonText); // create the Transparent Popup Page // of type string since we need a string return var popup = new InputAlertDialogBase <MyDataModel>(inputView); // subscribe to the TextInputView's Button click event inputView.SaveButtonEventHandler += (sender, obj) => { // handle validations if (string.IsNullOrEmpty(((MultipleDataInputView)sender).MultipleDataResult.FirstName)) { ((MultipleDataInputView)sender).ValidationLabelText = "Ops! You need to enter the First name!"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } if (string.IsNullOrEmpty(((MultipleDataInputView)sender).MultipleDataResult.LastName)) { ((MultipleDataInputView)sender).ValidationLabelText = "Ops! You need to enter the Last name!"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } if (((MultipleDataInputView)sender).MultipleDataResult.Age < 18) { ((MultipleDataInputView)sender).ValidationLabelText = "Ops! You need to be over 18 years of Age!"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } // if all good then set the Result ((MultipleDataInputView)sender).IsValidationLabelVisible = false; popup.PageClosedTaskCompletionSource.SetResult(((MultipleDataInputView)sender).MultipleDataResult); }; // 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)); }
private async Task <MyDataModel> OpenMultipleDataInputAlertDialog() { // create the TextInputView var inputView = new MultipleDataInputView( "What's your Name?", "What's your Age?", "First Name", "Last Name", 0, 40, "Save", "Cancel"); // create the Transparent Popup Page // of type string since we need a string return var popup = new InputAlertDialogBase <MyDataModel>(inputView); // subscribe to the TextInputView's Button click event inputView.SaveButtonEventHandler += (sender, obj) => { // handle validations if (string.IsNullOrEmpty(((MultipleDataInputView)sender).MultipleDataResult.FirstName)) { ((MultipleDataInputView)sender).ValidationLabelText = "Ops! You need to enter the First name!"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } if (string.IsNullOrEmpty(((MultipleDataInputView)sender).MultipleDataResult.LastName)) { ((MultipleDataInputView)sender).ValidationLabelText = "Ops! You need to enter the Last name!"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } if (((MultipleDataInputView)sender).MultipleDataResult.Age < 18) { ((MultipleDataInputView)sender).ValidationLabelText = "Ops! You need to be over 18 years of Age!"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } // if all good then set the Result ((MultipleDataInputView)sender).IsValidationLabelVisible = false; popup.PageClosedTaskCompletionSource.SetResult(((MultipleDataInputView)sender).MultipleDataResult); }; // 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); }
private async Task <MyDataModel> OpenMultipleDataInputAlertDialog(List <TblInventory> LstInv, List <InventorySearch> LstDisc) { //string NmBrg = autoComplete.Text; // create the TextInputView var inputView = new MultipleDataInputView(LstDisc, LstInv[0].NM_BRG, LstInv[0].HRG_JUAL.ToString(), LstInv[0].HRG_MODAL.ToString(), LstInv[0].SATUAN, LstInv[0].SATUAN_JUAL.ToString(), LstInv[0].SATUAN_JUAL, LstInv[0].STOK, "Add To Cart", "Cancel"); // create the Transparent Popup Page // of type string since we need a string return var popup = new InputAlertDialogBase <MyDataModel>(inputView); // subscribe to the TextInputView's Button click event inputView.SaveButtonEventHandler += (sender, obj) => { // handle validations if (((MultipleDataInputView)sender).MultipleDataResult.Qty == 0) { ((MultipleDataInputView)sender).ValidationLabelText = "QTY tidak boleh 0"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } if (LstInv[0].SATUAN == "Gr") { if (((MultipleDataInputView)sender).MultipleDataResult.Qty % LstInv[0].SATUAN_JUAL != 0) { ((MultipleDataInputView)sender).ValidationLabelText = "Pembelian harus / " + LstInv[0].SATUAN_JUAL.ToString() + " Gr"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } if (((MultipleDataInputView)sender).MultipleDataResult.Qty < 10) { ((MultipleDataInputView)sender).ValidationLabelText = "Minimum pembelian 10 Gr"; ((MultipleDataInputView)sender).IsValidationLabelVisible = true; return; } } // if all good then set the Result ((MultipleDataInputView)sender).IsValidationLabelVisible = false; popup.PageClosedTaskCompletionSource.SetResult(((MultipleDataInputView)sender).MultipleDataResult); }; // 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 Navigation.PushPopupAsync(popup); // await for the user to enter the text input var result = await popup.PageClosedTask; // Pop the page from Navigation Stack //await PopupNavigation.PopAsync(); await Navigation.PopAsync(); // return user inserted text value return(result); }