コード例 #1
0
        public async Task ShellPartWithPopToRoot()
        {
            Shell shell = new Shell();
            var   item  = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);
            ShellLifeCycleState lifeCycleState = new ShellLifeCycleState(item);

            shell.Items.Add(item);

            lifeCycleState.AllTrue();

            await shell.Navigation.PushAsync(new ContentPage());

            await shell.Navigation.PushAsync(new ContentPage());

            await shell.Navigation.PushAsync(new ContentPage());

            await shell.Navigation.PushAsync(new ContentPage());

            Assert.IsFalse(lifeCycleState.PageAppearing);
            Assert.IsFalse(lifeCycleState.ContentAppearing);
            Assert.IsTrue(lifeCycleState.SectionAppearing);
            Assert.IsTrue(lifeCycleState.ItemAppearing);

            await shell.Navigation.PopToRootAsync();

            lifeCycleState.AllTrue();
        }
コード例 #2
0
        public async Task PagePushModal()
        {
            Shell shell = new Shell();
            var   item  = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);
            ShellLifeCycleState lifeCycleState = new ShellLifeCycleState(item);

            shell.Items.Add(item);

            ContentPage page = new ContentPage();

            bool appearing = false;

            page.Appearing    += (_, __) => appearing = true;
            page.Disappearing += (_, __) => appearing = false;

            await shell.Navigation.PushModalAsync(page);

            Assert.IsTrue(appearing);
            lifeCycleState.AllFalse();

            await shell.Navigation.PopModalAsync();

            Assert.IsFalse(appearing);
            lifeCycleState.AllTrue();
        }
コード例 #3
0
        public async Task ShellPartWithPagePush()
        {
            Shell shell = new Shell();
            var   item  = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);
            ShellLifeCycleState lifeCycleState = new ShellLifeCycleState(item);

            shell.Items.Add(item);

            lifeCycleState.AllTrue();

            await shell.Navigation.PushAsync(new ContentPage());

            //if you're just pushing a page then the section and item are still visible but the content is not
            Assert.IsFalse(lifeCycleState.PageAppearing);
            Assert.IsFalse(lifeCycleState.ContentAppearing);
            Assert.IsTrue(lifeCycleState.SectionAppearing);
            Assert.IsTrue(lifeCycleState.ItemAppearing);

            await shell.Navigation.PushAsync(new ContentPage());

            Assert.IsFalse(lifeCycleState.PageAppearing);
            Assert.IsFalse(lifeCycleState.ContentAppearing);
            Assert.IsTrue(lifeCycleState.SectionAppearing);
            Assert.IsTrue(lifeCycleState.ItemAppearing);

            await shell.Navigation.PopAsync();

            Assert.IsFalse(lifeCycleState.PageAppearing);
            Assert.IsFalse(lifeCycleState.ContentAppearing);
            Assert.IsTrue(lifeCycleState.SectionAppearing);
            Assert.IsTrue(lifeCycleState.ItemAppearing);
            await shell.Navigation.PopAsync();

            lifeCycleState.AllTrue();
        }
コード例 #4
0
        public void AppearingOnShellItemChanged()
        {
            Shell shell = new Shell();
            var   item  = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);
            var   item2 = CreateShellItem();

            shell.Items.Add(item2);
            shell.Items.Add(item);
            ShellLifeCycleState state = new ShellLifeCycleState(shell);

            state.AllFalse();

            Assert.AreEqual(shell.CurrentItem, item2);
            Assert.AreNotEqual(shell.CurrentItem, item);

            shell.CurrentItem = item;

            Assert.IsTrue(state.ItemAppearing);
            Assert.IsTrue(state.SectionAppearing);
            Assert.IsTrue(state.ContentAppearing);

            shell.CurrentItem = item2;

            Assert.IsFalse(state.ItemAppearing);
            Assert.IsFalse(state.SectionAppearing);
            Assert.IsFalse(state.ContentAppearing);
        }
コード例 #5
0
        public void AppearingOnShellSectionChanged()
        {
            Shell shell      = new Shell();
            var   item       = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);
            var   section    = item.SearchForRoute <ShellSection>(SectionRoute);
            var   newSection = CreateShellSection();

            item.Items.Insert(0, newSection);
            item.CurrentItem = newSection;
            shell.Items.Add(item);
            ShellLifeCycleState state = new ShellLifeCycleState(shell);

            state.AllFalse();


            Assert.AreEqual(newSection, item.CurrentItem);
            Assert.AreNotEqual(section, item.CurrentItem);

            item.CurrentItem = section;

            Assert.IsTrue(state.SectionAppearing);
            Assert.IsTrue(state.ContentAppearing);

            item.CurrentItem = newSection;

            Assert.IsFalse(state.SectionAppearing);
            Assert.IsFalse(state.ContentAppearing);
        }
コード例 #6
0
        public void AppearingOnShellContentChanged()
        {
            Shell shell   = new Shell();
            var   item    = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);
            var   section = item.SearchForRoute <ShellSection>(SectionRoute);

            var content = new ShellContent();

            section.Items.Insert(0, content);
            section.CurrentItem = content;
            shell.Items.Add(item);
            ShellLifeCycleState state = new ShellLifeCycleState(shell);

            state.AllFalse();

            Assert.AreEqual(content, section.CurrentItem);

            section.CurrentItem = shell.SearchForRoute <ShellContent>(ContentRoute);

            Assert.IsTrue(state.ContentAppearing);

            section.CurrentItem = content;

            Assert.IsFalse(state.ContentAppearing);
        }
コード例 #7
0
        public async Task ShellPartWithModalPush()
        {
            Shell shell = new Shell();
            var   item  = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);
            ShellLifeCycleState lifeCycleState = new ShellLifeCycleState(item);

            shell.Items.Add(item);

            lifeCycleState.AllTrue();

            ContentPage page = new ContentPage();
            await shell.Navigation.PushModalAsync(page);

            lifeCycleState.AllFalse();
            await shell.Navigation.PopModalAsync();

            lifeCycleState.AllTrue();
        }