コード例 #1
0
        public SheetPageViewModel()
        {
            OpenSheetCommand = new Command(() => IsSheetOpen = true);
            OnOpenCommand    = new Command <string>(SheetOpened);
            OnCloseCommand   = new Command <string>(SheetClosed);
            CancelCommand    = new CancelSheetCommand(() =>
            {
                //Do any logic that should get executed regardless of the canCloseSheet logic.
            },
                                                      () =>
            {
                return(true);
            }, async() =>
            {
                //Do logic to determine if the sheet should close
                return(await Application.Current.MainPage.DisplayAlert("Are you sure?",
                                                                       "Do you want to close the sheet view?", "Yes", "No"));
            });

            ActionCommand = new Command(
                () =>
            {
                //Do work when action is pressed
            });

            InitCommand = new Command(async() => await Init());

            m_sheetViewModel = new InsideSheetViewModel();
        }
コード例 #2
0
        public async Task CanCloseSheet_CanCloseSheetIsNull_ShouldReturnTrue()
        {
            var cancelSheetCommand = new CancelSheetCommand(s => { }, s => true);

            var canCloseSheet = await cancelSheetCommand.CanCloseSheet(null);

            canCloseSheet.Should().BeTrue();
        }
コード例 #3
0
        public async Task CanCloseSheet_CanCloseSheetSet_ShouldReturnCorrect(bool canClose)
        {
            var cancelSheetCommand = new CancelSheetCommand(o => { }, o => true, o => canClose);

            var canCloseSheet = await cancelSheetCommand.CanCloseSheet(null);

            canCloseSheet.Should().Be(canClose);
        }
コード例 #4
0
        public async Task CanCloseSheet_WithGeneric_CanCloseSheetSet_ShouldReturnCorrect(bool canClose)
        {
            var cancelSheetCommand = new CancelSheetCommand <string>(s => { }, s => true, s => canClose);

            var canCloseSheet = await cancelSheetCommand.CanCloseSheet(null);

            canCloseSheet.Should().Be(canClose);
        }
コード例 #5
0
        public async Task CanCloseSheet_AsyncCanCloseSheetSet_ShouldReturnCorrect(bool canClose)
        {
            var cancelSheetCommand = new CancelSheetCommand(o => { }, o => true, async o =>
            {
                await Task.Delay(100);
                return(canClose);
            });

            var canCloseSheet = await cancelSheetCommand.CanCloseSheet(null);

            canCloseSheet.Should().Be(canClose);
        }
コード例 #6
0
        public SheetPageViewModel()
        {
            OpenSheetCommand = new Command(() => IsSheetOpen = true);
            OnOpenCommand    = new Command <string>(SheetOpened);
            OnCloseCommand   = new Command <string>(SheetClosed);
            CancelCommand    = new CancelSheetCommand(
                () =>
            {
            },
                () =>
            {
                return(true);
            }, () =>
            {
                //Do logic to determine if the sheet should close
                return(true);
            });

            ActionCommand = new Command(
                () =>
            {
                //Do work when action is pressed
            });
        }