public void DestroyActionSheetButton_WithNoAction_DoNotThrowException() { var destroy = ActionSheetButton.CreateDestroyButton("Foo"); var ex = Record.Exception(() => destroy.PressButton()); Assert.Null(ex); }
private async void DisplayActionSheetDestruicao() { //Outra forma de gerenciar retorno de mensagens: //O legal disso é que podemos passar o ICommand como parâmetro e var opcaoA = ActionSheetButton.CreateButton("Opção A", new DelegateCommand(() => { this.OpcaoEscolhida = "A opção selecionada foi: Opção A"; })); var opcaoB = ActionSheetButton.CreateButton("Opção B", new DelegateCommand(() => { this.OpcaoEscolhida = "A opção selecionada foi: Opção B"; })); var opcaoC = ActionSheetButton.CreateButton("Opção B", new DelegateCommand(() => { this.OpcaoEscolhida = "A opção selecionada foi: Opção C"; })); var cancelar = ActionSheetButton.CreateCancelButton("Cancelar", new DelegateCommand(() => { this.OpcaoEscolhida = "A opção selecionada foi: Cancelar"; })); var excluir = ActionSheetButton.CreateDestroyButton("Excluir!!", new DelegateCommand(() => { this.OpcaoEscolhida = "A opção selecionada foi: Excluir!!"; })); await this._pageDialogService.DisplayActionSheetAsync("Prism", opcaoA, opcaoB, opcaoC, cancelar, excluir); }
public void CancelActionSheetButton_WithNoAction_DoNotThrowException() { var cancel = ActionSheetButton.CreateCancelButton("Foo"); var ex = Record.Exception(() => cancel.PressButton()); Assert.Null(ex); }
public void OnClicked() { var commandExecuterMock = new Mock <ICommandExecutor>(); var command = new Mock <ICommand>().Object; var commandParameter = new object(); var eventArgs = new EventArgs(); var eventArgsConverter = new Mock <IValueConverter>().Object; var eventArgsConverterParameter = new object(); var eventArgsPropertyPath = ""; var button = new ActionSheetButton() { CommandExecutor = commandExecuterMock.Object, Command = command, CommandParameter = commandParameter, EventArgsConverter = eventArgsConverter, EventArgsConverterParameter = eventArgsConverterParameter, EventArgsPropertyPath = eventArgsPropertyPath }; button.OnClicked(this, eventArgs); commandExecuterMock.Verify( executer => executer.Execute(command, commandParameter, eventArgs, eventArgsConverter, eventArgsConverterParameter, eventArgsPropertyPath), Times.Once); }
private async Task <bool> ExecuteValidateUserCityCommand() { var buttons = new List <IActionSheetButton> { ActionSheetButton.CreateButton("---Select city---", () => { UserCity.Value = "---Select city---"; }), ActionSheetButton.CreateCancelButton("Cancel", () => { UserCity.Value = "---Select city---"; }) }; foreach (var item in CityList) { buttons.Add(ActionSheetButton.CreateButton(item.CityName, () => { UserCity.Value = item.CityName; CurrentCity = item; })); } await PageDialogService.DisplayActionSheetAsync(null, buttons.ToArray()); if (!(UserCity.Value == "---Select city---")) { return(_userCity.Validate()); } else { return(_userCity.Validate()); } }
private void AddImage() { IActionSheetButton TakePicture = ActionSheetButton.CreateButton("Take Picture Form Camera", new DelegateCommand(ButtonTakePicter)); IActionSheetButton GetPicture = ActionSheetButton.CreateButton("Get Picture From Gallery", new DelegateCommand(ButtonGetPicture)); IActionSheetButton Cancel = ActionSheetButton.CreateCancelButton("Cancel", new DelegateCommand(() => { return; })); dialog.DisplayActionSheetAsync("What do you want to do with : ", Cancel, TakePicture, GetPicture); }
private async void ShowActions(AppointmentDTO appointmentDTO) { IActionSheetButton editAppointmentBtn = ActionSheetButton.CreateButton("Edit appointment", new DelegateCommand(() => { EditAppointment(appointmentDTO); })); IActionSheetButton deleteAppointmentBtn = ActionSheetButton.CreateButton("Delete appointment", new DelegateCommand(() => { DeleteAppointment(appointmentDTO.Id); })); IActionSheetButton callPatientBtn = ActionSheetButton.CreateButton("Call patient", new DelegateCommand(() => { CallPatient(appointmentDTO.Phone); })); await _dialogService.DisplayActionSheetAsync("Appointment actions", editAppointmentBtn, callPatientBtn, deleteAppointmentBtn); }
private async void ShowPatientActionsAsync() { IActionSheetButton editPatientBtn = ActionSheetButton.CreateButton("Edit patient", new DelegateCommand(() => { NavigateToPage("EditPatientPage"); })); IActionSheetButton callPatientBtn = ActionSheetButton.CreateButton("Call patient", new DelegateCommand(() => { CallPatient(); })); IActionSheetButton scheduleAppointmentBtn = ActionSheetButton.CreateButton("Schedule appointment", new DelegateCommand(() => { ScheduleAppointmentAsync(); })); await _dialogService.DisplayActionSheetAsync("Patient actions", editPatientBtn, callPatientBtn, scheduleAppointmentBtn); }
public void MessageProperty() { var actionSheetButton = new ActionSheetButton { Message = "Message" }; Assert.Equal("Message", actionSheetButton.Message); }
private async void DisplayActionSheetUsingActionSheetButtons() { var option1Action = ActionSheetButton.CreateButton("Option 1", new DelegateCommand(() => { Debug.WriteLine("Option 1"); })); var option2Action = ActionSheetButton.CreateButton("Option 2", new DelegateCommand(() => { Debug.WriteLine("Option 2"); })); var cancelAction = ActionSheetButton.CreateCancelButton("Cancel", new DelegateCommand(() => { Debug.WriteLine("Cancel"); })); var destroyAction = ActionSheetButton.CreateDestroyButton("Destroy", new DelegateCommand(() => { Debug.WriteLine("Destroy"); })); await _pageDialogService.DisplayActionSheetAsync("ActionSheet with ActionSheetButtons", option1Action, option2Action, cancelAction, destroyAction); }
private async void AddImage(object obj) { var list = new List <IActionSheetButton>(); list.Add(ActionSheetButton.CreateButton("Galeria", AddImageFromGallery)); list.Add(ActionSheetButton.CreateButton("Camara", AddImageFromCamera)); await _dialogService.DisplayActionSheetAsync("Añadir image", list.ToArray()); }
void ReleaseDesignerOutlets() { if (ActionSheetBottomButton != null) { ActionSheetBottomButton.Dispose(); ActionSheetBottomButton = null; } if (ActionSheetButton != null) { ActionSheetButton.Dispose(); ActionSheetButton = null; } if (AlertButton != null) { AlertButton.Dispose(); AlertButton = null; } if (ConfirmButton != null) { ConfirmButton.Dispose(); ConfirmButton = null; } if (DeleteButton != null) { DeleteButton.Dispose(); DeleteButton = null; } if (LoadingButton != null) { LoadingButton.Dispose(); LoadingButton = null; } if (PromptButton != null) { PromptButton.Dispose(); PromptButton = null; } if (SnackbarButton != null) { SnackbarButton.Dispose(); SnackbarButton = null; } if (ToastButton != null) { ToastButton.Dispose(); ToastButton = null; } }
public async Task DisplayActionSheet_OtherButtonPressed_UsingCommand() { var service = new PageDialogServiceMock("other", _applicationProvider); var buttonPressed = false; var command = new DelegateCommand(() => buttonPressed = true); var button = ActionSheetButton.CreateButton("other", command); await service.DisplayActionSheetAsync(null, button); Assert.True(buttonPressed); }
public async Task DisplayActionSheet_CancelButtonPressed() { var service = new PageDialogServiceMock("cancel"); var cancelButtonPressed = false; var cancelCommand = new DelegateCommand(() => cancelButtonPressed = true); var button = ActionSheetButton.CreateCancelButton("cancel", cancelCommand); await service.DisplayActionSheet(null, button); Assert.True(cancelButtonPressed); }
public async Task DisplayActionSheet_NullButtonAndOtherButtonPressed() { var service = new PageDialogServiceMock("other"); var buttonPressed = false; var command = new DelegateCommand(() => buttonPressed = true); var button = ActionSheetButton.CreateButton("other", command); await service.DisplayActionSheet(null, button, null); Assert.True(buttonPressed); }
private void PickStaffCommand(Offer obj) { IActionSheetButton Used = ActionSheetButton.CreateButton("Use Offer", new DelegateCommand(() => { })); IActionSheetButton Share = ActionSheetButton.CreateButton("Share Offer For Friend", new DelegateCommand <Offer>(ShareOffer)); IActionSheetButton Cancel = ActionSheetButton.CreateCancelButton("Cancel", new DelegateCommand(() => { })); IActionSheetButton Delete = ActionSheetButton.CreateDestroyButton("Delete", new DelegateCommand(() => { })); var title = obj.NameOffer; dialog.DisplayActionSheetAsync("What do you want to do with : " + title, Cancel, Used, Share, Delete); }
public void OnClicked_WhenInvokeAction() { var called = false; var action = new ActionSheetButton { Action = () => { called = true; } }; action.OnClicked(this, EventArgs.Empty); Assert.True(called); }
private void DisplayActionSheetUsingActionSheetButtons() { IActionSheetButton option1Action = ActionSheetButton.CreateButton("Option 1", new DelegateCommand(() => Debug.WriteLine("Option 1"))); IActionSheetButton option2Action = ActionSheetButton.CreateButton("Option 2", new DelegateCommand(() => Debug.WriteLine("Option 2"))); IActionSheetButton option3Action = ActionSheetButton.CreateButton("Option 3", new DelegateCommand(() => Debug.WriteLine("Option 3"))); IActionSheetButton option4Action = ActionSheetButton.CreateButton("Option 4", new DelegateCommand(() => Debug.WriteLine("Option 4"))); IActionSheetButton option5Action = ActionSheetButton.CreateButton("Option 5", new DelegateCommand(() => Debug.WriteLine("Option 5"))); IActionSheetButton option6Action = ActionSheetButton.CreateButton("Option 6", new DelegateCommand(() => Debug.WriteLine("Option 6"))); _pageDialogService.DisplayActionSheetAsync("ActionSheet with ActionSheetButtons", option1Action, option2Action, option3Action, option4Action, option5Action, option6Action); }
async void OnChangeColor() { var modelList = new List <IActionSheetButton>(); foreach (var model in SelectedListingItem.ListingModels.ListingModels) { modelList.Add(ActionSheetButton.CreateButton(model, () => OnModelSelected(model))); } await _dialogService.DisplayActionSheetAsync($"Select {SelectedListingItem.ListingModels.ModelType}", modelList.ToArray()); }
public void OnClicked_WhenInvokeAction_WithParameter() { var actual = "parameter"; string expected = null; var action = new ActionSheetButton <string> { Parameter = actual, Action = x => { expected = actual; } }; action.OnClicked(this, EventArgs.Empty); Assert.Equal(expected, actual); }
public async Task DisplayActionSheet_DestroyButtonPressed_UsingCommand() { var service = new PageDialogServiceMock("destroy", _applicationProvider); var destroyButtonPressed = false; var cancelCommand = new DelegateCommand(() => destroyButtonPressed = false); var button = ActionSheetButton.CreateCancelButton("cancel", cancelCommand); var destroyCommand = new DelegateCommand(() => destroyButtonPressed = true); var destroyButton = ActionSheetButton.CreateDestroyButton("destroy", destroyCommand); await service.DisplayActionSheetAsync(null, button, destroyButton); Assert.True(destroyButtonPressed); }
public async Task DisplayActionSheet_NoButtonPressed() { var service = new PageDialogServiceMock(null); var buttonPressed = false; var cancelCommand = new DelegateCommand(() => buttonPressed = true); var button = ActionSheetButton.CreateCancelButton("cancel", cancelCommand); var destroyCommand = new DelegateCommand(() => buttonPressed = true); var destroyButton = ActionSheetButton.CreateDestroyButton("destroy", destroyCommand); await service.DisplayActionSheet(null, button, destroyButton); Assert.False(buttonPressed); }
private async void DisplayActionSheetUsingActionSheetButtons() { var buttons = new IActionSheetButton[] { ActionSheetButton.CreateButton("Option 1", WriteLine, "Option 1"), ActionSheetButton.CreateButton("Option 2", WriteLine, "Option 2"), ActionSheetButton.CreateCancelButton("Cancel", WriteLine, "Cancel"), ActionSheetButton.CreateDestroyButton("Destroy", WriteLine, "Destroy") }; await _pageDialogService.DisplayActionSheetAsync("ActionSheet with ActionSheetButtons", buttons); }
private async Task SelectRoleCommandExecuteAsync() { List <IActionSheetButton> buttons = new List <IActionSheetButton>(); foreach (var item in AppRolesResult) { buttons.Add(ActionSheetButton.CreateButton(item.Name, new Action(() => { SelectedAppRole = item; }))); } await PageDialogService.DisplayActionSheetAsync("Select Option", buttons.ToArray()); }
private void ListItemTapped(ReminderItemDB param) { ReminderItemDB list = param as ReminderItemDB; IActionSheetButton cancelAction = ActionSheetButton.CreateCancelButton("Cancel", new DelegateCommand(() => { CancelListhighlight(); })); IActionSheetButton destroyAction = ActionSheetButton.CreateDestroyButton("Destroy", new DelegateCommand(() => { DeleteListItem(list); })); _pageDialogService.DisplayActionSheetAsync("My Action Sheet", cancelAction, destroyAction); }
private async void NotifyCar() { IsLoading = true; var notifyWithMessageCommand = new DelegateCommand <string>(NotifyWithTemplate); var actionSheetButtons = new List <IActionSheetButton>(); foreach (var message in TemplateConstants.TemplateMessageToName.Keys) { actionSheetButtons.Add(ActionSheetButton.CreateButton(message, notifyWithMessageCommand)); } await _pageDialogService.DisplayActionSheetAsync("What happend?", actionSheetButtons.ToArray()); IsLoading = false; }
public static async Task <T> PresentChoice <T>( this IPageDialogService pageDialogService, string title, ICollection <T> choices, Func <T, string> titleSelector, object anchor = null) { var choiceDict = choices.ToDictionary(titleSelector, c => c); var tcs = new TaskCompletionSource <T>(); var buttons = choiceDict.Select(x => ActionSheetButton.CreateButton(x.Key, () => tcs.TrySetResult(x.Value))).ToList(); var cancel = ActionSheetButton.CreateButton(CancelTitle, () => tcs.TrySetResult(default(T))); await pageDialogService.DisplayActionSheetAsync(title, buttons.Concat(new[] { cancel }).ToArray()); return(await tcs.Task); }
private void OnVideoTapped(YoutubeItem item) { // var navParams = new NavigationParameters(); //navParams.Add("videoKey", item); //_navigationService.NavigateAsync(nameof(VideoDetails), navParams); IActionSheetButton Yes = ActionSheetButton.CreateButton("Yes", new DelegateCommand(() => { Task.Run(() => { Device.OpenUri(new Uri(item.Url)); }); })); IActionSheetButton No = ActionSheetButton.CreateButton("No", new DelegateCommand(() => { Debug.WriteLine("No"); })); _page.DisplayActionSheetAsync("Using third party app for watching video!", Yes, No); Debug.WriteLine($"**** {this.GetType().Name}.{nameof(OnVideoTapped)}; {_videos}"); }
void SetWeightUnitsTapped() { var imperialPoundsAction = ActionSheetButton.CreateButton(WeightUnitEnum.ImperialPounds.ToSettingsName(), new DelegateCommand(() => { WeightUnitTypeSelected(WeightUnitEnum.ImperialPounds); })); var kilogramsAction = ActionSheetButton.CreateButton(WeightUnitEnum.Kilograms.ToSettingsName(), new DelegateCommand(() => { WeightUnitTypeSelected(WeightUnitEnum.Kilograms); })); var stonesPoundAction = ActionSheetButton.CreateButton(WeightUnitEnum.StonesAndPounds.ToSettingsName(), new DelegateCommand(() => { WeightUnitTypeSelected(WeightUnitEnum.StonesAndPounds); })); var cancelAction = ActionSheetButton.CreateCancelButton(Constants.Strings.Generic_Cancel, new DelegateCommand(() => { })); DialogService.DisplayActionSheetAsync(Constants.Strings.Settings_ChangeWeightUnitsActionSheet, imperialPoundsAction, kilogramsAction, stonesPoundAction, cancelAction); }
private IActionSheetButton[] CreateButtons() { var buttons = new List <IActionSheetButton>() { ActionSheetButton.CreateCancelButton("Cancel", () => Callback("Cancel")), ActionSheetButton.CreateDestroyButton("Destroy", () => Callback("Destroy")) }; foreach (var text in Actions) { buttons.Add(ActionSheetButton.CreateButton(text, () => Callback(text))); } return(buttons.ToArray()); }