Ejemplo n.º 1
0
        public void DestroyActionSheetButton_WithNoAction_DoNotThrowException()
        {
            var destroy = ActionSheetButton.CreateDestroyButton("Foo");
            var ex      = Record.Exception(() => destroy.PressButton());

            Assert.Null(ex);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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 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);
        }
        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);
        }
Ejemplo n.º 8
0
        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 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());
        }
Ejemplo n.º 10
0
        public async override void DeleteSettings()
        {
            var buttons = new IActionSheetButton[]
            {
                ActionSheetButton.CreateCancelButton(
                    ResourceService.GetString("ActionSheetButton_Cancel")),
                ActionSheetButton.CreateDestroyButton(
                    ResourceService.GetString("ActionSheetButton_Delete"),
                    DeleteAction)
            };

            await _pageDialogService.DisplayActionSheetAsync(
                ResourceService.GetString("LoginSettingsPage_ActionSheet_Title"),
                buttons);
        }
Ejemplo n.º 11
0
        public async Task ShowDialogs()
        {
            await _dialogService?.DisplayAlertAsync("Display Alert", "This is a Display Alert made with Prism", "OK");

            await _dialogService.DisplayActionSheetAsync("ActionSheet", "Cancel", "Destroy", "Button01", "Button02", "Button03");

            IActionSheetButton b1 = ActionSheetButton.CreateButton("Button1",
                                                                   async delegate { await _dialogService?.DisplayAlertAsync("Display Alert", "Button 1 Pressed", "OK"); });
            IActionSheetButton b2 = ActionSheetButton.CreateCancelButton("Cancel",
                                                                         async delegate { await _dialogService?.DisplayAlertAsync("Display Alert", "Cancel Pressed", "OK"); });
            IActionSheetButton b3 = ActionSheetButton.CreateDestroyButton("Destroy",
                                                                          async delegate { await _dialogService?.DisplayAlertAsync("Display Alert", "Destroy Pressed", "OK"); });

            await _dialogService.DisplayActionSheetAsync("ActionSheet with IActionSheetButton", b1, b2, b3);
        }
Ejemplo n.º 12
0
        private async void DisplayActionSheetUsingActionSheetButtons()
        {
            IActionSheetButton option1Action = ActionSheetButton.CreateButton("Option 1", () =>
            {
                //Adding button with multi-line lambda Action
                int optionValue = 1;
                Debug.WriteLine($"Option {optionValue}");
            });
            IActionSheetButton option2Action = ActionSheetButton.CreateButton("Option 2", () => Debug.WriteLine("Option 2")); //Button with simple one-line lambda Action
            IActionSheetButton cancelAction  = ActionSheetButton.CreateCancelButton("Cancel", WriteResponse, "Cancel");       //Using Action<string> to call a method

            await _pageDialogService.DisplayActionSheetAsync("ActionSheet with ActionSheetButtons",
                                                             option1Action,
                                                             option2Action,
                                                             cancelAction,
                                                             ActionSheetButton.CreateDestroyButton("Destroy", WriteResponse, "Destroy")); //Inline button creation
        }
        private async Task DisplayActionSheet_PressButton_UsingGenericAction(string text)
        {
            var service            = new PageDialogServiceMock(text, _applicationProvider);
            var cancelButtonModel  = new ButtonModel();
            var destroyButtonModel = new ButtonModel();
            var otherButtonModel   = new ButtonModel();
            var btns = new IActionSheetButton[]
            {
                ActionSheetButton.CreateButton("other", OnButtonPressed, otherButtonModel),
                ActionSheetButton.CreateCancelButton("cancel", OnButtonPressed, cancelButtonModel),
                ActionSheetButton.CreateDestroyButton("destroy", OnButtonPressed, destroyButtonModel)
            };
            await service.DisplayActionSheetAsync(null, btns);

            switch (text)
            {
            case "other":
                Assert.True(otherButtonModel.ButtonPressed);
                Assert.False(cancelButtonModel.ButtonPressed);
                Assert.False(destroyButtonModel.ButtonPressed);
                break;

            case "cancel":
                Assert.False(otherButtonModel.ButtonPressed);
                Assert.True(cancelButtonModel.ButtonPressed);
                Assert.False(destroyButtonModel.ButtonPressed);
                break;

            case "destroy":
                Assert.False(otherButtonModel.ButtonPressed);
                Assert.False(cancelButtonModel.ButtonPressed);
                Assert.True(destroyButtonModel.ButtonPressed);
                break;

            default:
                Assert.False(otherButtonModel.ButtonPressed);
                Assert.False(cancelButtonModel.ButtonPressed);
                Assert.False(destroyButtonModel.ButtonPressed);
                break;
            }
        }
#pragma warning restore CS0618 // Type or member is obsolete

        #endregion Obsolete ActionSheetButton using Commands

        private async Task DisplayActionSheet_PressButton_UsingAction(string text)
        {
            var  service              = new PageDialogServiceMock(text, _applicationProvider);
            bool cancelButtonPressed  = false;
            bool destroyButtonPressed = false;
            bool otherButtonPressed   = false;
            var  btns = new IActionSheetButton[]
            {
                ActionSheetButton.CreateButton("other", () => otherButtonPressed            = true),
                ActionSheetButton.CreateCancelButton("cancel", () => cancelButtonPressed    = true),
                ActionSheetButton.CreateDestroyButton("destroy", () => destroyButtonPressed = true)
            };
            await service.DisplayActionSheetAsync(null, btns);

            switch (text)
            {
            case "other":
                Assert.True(otherButtonPressed);
                Assert.False(cancelButtonPressed);
                Assert.False(destroyButtonPressed);
                break;

            case "cancel":
                Assert.False(otherButtonPressed);
                Assert.True(cancelButtonPressed);
                Assert.False(destroyButtonPressed);
                break;

            case "destroy":
                Assert.False(otherButtonPressed);
                Assert.False(cancelButtonPressed);
                Assert.True(destroyButtonPressed);
                break;

            default:
                Assert.False(otherButtonPressed);
                Assert.False(cancelButtonPressed);
                Assert.False(destroyButtonPressed);
                break;
            }
        }