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());
            }
        }
Пример #2
0
        public void CancelActionSheetButton_WithNoAction_DoNotThrowException()
        {
            var cancel = ActionSheetButton.CreateCancelButton("Foo");
            var ex     = Record.Exception(() => cancel.PressButton());

            Assert.Null(ex);
        }
Пример #3
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);
        }
Пример #4
0
        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);
        }
Пример #5
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);
        }
        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);
        }
Пример #7
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);
        }
Пример #11
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);
        }
        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());
        }
Пример #14
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);
        }
Пример #15
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);
        }
Пример #16
0
 private async Task ExecuteImageTappedClickCommandAsync(ComplaintImagesDTO complaintImagesDTO)
 {
     List <IActionSheetButton> buttons = new List <IActionSheetButton>()
     {
         ActionSheetButton.CreateButton("View file", new Action(async() =>
         {
             await ViewFile(complaintImagesDTO);
         })),
         ActionSheetButton.CreateButton("Delete file", new Action(async() =>
         {
             await DeleteFile(complaintImagesDTO);
         })),
         ActionSheetButton.CreateCancelButton("Cancel", new Action(() => { }))
     };
     await PageDialogService.DisplayActionSheetAsync("Select Option", buttons.ToArray());
 }
Пример #17
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
        }
Пример #18
0
        private async Task <bool> ExecuteSpeciesCommandAsync()
        {
            var buttons = new List <IActionSheetButton>()
            {
                ActionSheetButton.CreateButton("---Select species---", WriteLine, "Select option"),

                ActionSheetButton.CreateCancelButton("Cancel", WriteLine, "Cancel")
            };
            var Species = await _complaintService.GetAllSpecies(_settings.UserId);

            foreach (var item in Species)
            {
                buttons.Add(ActionSheetButton.CreateButton(item.SpeciesName, WriteLine, item.SpeciesName));
            }
            await PageDialogService.DisplayActionSheetAsync("Select species", buttons.ToArray());

            return(_species.Validate());
        }
        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;
            }
        }
Пример #21
0
        private async Task ExecuteUploadimagecommandAsync()
        {
            try
            {
                var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <CameraPermission>();

                var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <StoragePermission>();

                var status = await CrossPermissions.Current.CheckPermissionStatusAsync <MediaLibraryPermission>();

                if (status != PermissionStatus.Granted)
                {
                    if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.MediaLibrary))
                    {
                        await PageDialogService.DisplayAlertAsync(null, "App needs permission to access the media library.", "OK");
                    }
                    status = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>();
                }
                if (status == PermissionStatus.Granted)
                {
                }
                if (cameraStatus != PermissionStatus.Granted)
                {
                    if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Camera))
                    {
                        await PageDialogService.DisplayAlertAsync(null, "App needs permission to access the camera.", "OK");
                    }


                    cameraStatus = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>();
                }

                if (storageStatus != PermissionStatus.Granted)
                {
                    if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage))
                    {
                        await PageDialogService.DisplayAlertAsync(null, "App needs permission to access the phone's local storage.", "OK");
                    }

                    storageStatus = await CrossPermissions.Current.RequestPermissionAsync <StoragePermission>();
                }

                if (status == PermissionStatus.Granted && cameraStatus == PermissionStatus.Granted)
                {
                    List <IActionSheetButton> buttons = new List <IActionSheetButton>()
                    {
                        ActionSheetButton.CreateButton("Gallery", new Action(async() =>
                        {
                            await UplaodImageFromGallery();
                        })),
                        ActionSheetButton.CreateButton("Camera", new Action(async() =>
                        {
                            await UplaodImageFromCamera();
                        })),
                        ActionSheetButton.CreateCancelButton("Cancel", new Action(() => { }))
                    };
                    await PageDialogService.DisplayActionSheetAsync("Select Option", buttons.ToArray());
                }
                else
                {
                    await PageDialogService.DisplayAlertAsync(null, "Sorry, permission is not granted to use the media library.", "OK");
                }
            }
            catch (Exception ex)
            {
                string st = ex.ToString();
            }
        }
        async void WeightUnitTypeSelected(WeightUnitEnum newUnits)
        {
            // already using this same setting, just return
            if (newUnits == SettingsService.WeightUnit)
            {
                return;
            }

            // see if there are existing weight entries not of this type
            IList <WeightEntry> allEntries = null;

            try
            {
                IncrementPendingRequestCount();
                allEntries = await DataService.GetAllWeightEntries();

                var weightsWithDifferentUnits = allEntries.Where(w => w.WeightUnit != newUnits);
                if (!weightsWithDifferentUnits.Any())
                {
                    var currentGoal = await DataService.GetGoal();

                    if (currentGoal == null)
                    {
                        SettingsService.WeightUnit = newUnits; // nothing to change, so just change the setting and return
                        SetupMenu();                           // refresh the menu to show the new setting
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                AnalyticsService.TrackFatalError($"{nameof(WeightUnitTypeSelected)} - an exception occurred getting all weights", ex);
                await DialogService.DisplayAlertAsync(Constants.Strings.Settings_ChangeWeightUnits_GetWeightsError_Title,
                                                      Constants.Strings.Settings_ChangeWeightUnits_GetWeightsError_Message,
                                                      Constants.Strings.Generic_OK);
            }
            finally
            {
                DecrementPendingRequestCount();
            }

            // if they are switching between pounds and stones/pounds we don't need to ask them how to convert as the data is stored
            // the same either way (just changes how presented), so just go straight to the conversion in this case
            if ((newUnits == WeightUnitEnum.ImperialPounds && SettingsService.WeightUnit == WeightUnitEnum.StonesAndPounds) ||
                (newUnits == WeightUnitEnum.StonesAndPounds && SettingsService.WeightUnit == WeightUnitEnum.ImperialPounds))
            {
                UpdateWeightEntriesAndGoalUnits(newUnits, false);
                return;
            }

            // show warning of needing to convert these values
            var convertAction = ActionSheetButton.CreateButton(Constants.Strings.Settings_ChangeWeightUnits_ConvertWarning_ConvertWeightValues,
                                                               new DelegateCommand(() => { UpdateWeightEntriesAndGoalUnits(newUnits, true); }));
            var changeUnitAction = ActionSheetButton.CreateButton(Constants.Strings.Settings_ChangeWeightUnits_ConvertWarning_ChangeUnits,
                                                                  new DelegateCommand(() => { UpdateWeightEntriesAndGoalUnits(newUnits, false); }));
            var cancelAction = ActionSheetButton.CreateCancelButton(Constants.Strings.Generic_Cancel,
                                                                    new DelegateCommand(() => { }));

            await DialogService.DisplayActionSheetAsync(Constants.Strings.Settings_ChangeWeightUnits_ConvertWarning,
                                                        convertAction, changeUnitAction, cancelAction);
        }