Exemple #1
0
        public void FlyoutItemDefaultTemplates()
        {
            Shell            shell = new Shell();
            IShellController sc    = (IShellController)shell;

            shell.MenuItemTemplate = new DataTemplate(() => new Label()
            {
                Text = "MenuItemTemplate"
            });
            shell.ItemTemplate = new DataTemplate(() => new Label()
            {
                Text = "ItemTemplate"
            });

            var shellItem = CreateShellItem();
            var menuItem  = new MenuShellItem(new MenuItem());

            shell.Items.Add(shellItem);
            shell.Items.Add(menuItem);


            DataTemplate triggerDefault = shell.ItemTemplate;

            triggerDefault = shell.MenuItemTemplate;

            Assert.AreEqual("ItemTemplate", GetFlyoutItemDataTemplateElement <Label>(shell, shellItem).Text);
            Assert.AreEqual("MenuItemTemplate", GetFlyoutItemDataTemplateElement <Label>(shell, menuItem).Text);
            Assert.AreEqual("MenuItemTemplate", GetFlyoutItemDataTemplateElement <Label>(shell, menuItem.MenuItem).Text);
        }
        public async Task NavigationBetweenFlyoutItemsRetainsQueryString()
        {
            var testPage1 = new ShellTestPage();
            var testPage2 = new ShellTestPage();

            var flyoutItem1 = CreateShellItem <FlyoutItem>(testPage1, shellItemRoute: "flyoutItem1");
            var flyoutItem2 = CreateShellItem <FlyoutItem>(testPage2, shellItemRoute: "flyoutItem2");

            var shell            = new TestShell(flyoutItem1, flyoutItem2);
            var complexParameter = new object();

            IShellController shellController = shell;
            await shell.GoToAsync(new ShellNavigationState($"//flyoutItem2?{nameof(ShellTestPage.SomeQueryParameter)}=1234"), false,
                                  new Dictionary <string, object>()
            {
                { nameof(ShellTestPage.ComplexObject), complexParameter }
            });

            Assert.AreEqual("1234", testPage2.SomeQueryParameter);
            Assert.AreEqual(complexParameter, testPage2.ComplexObject);
            await shellController.OnFlyoutItemSelectedAsync(flyoutItem1);

            await shellController.OnFlyoutItemSelectedAsync(flyoutItem2);

            Assert.AreEqual("1234", testPage2.SomeQueryParameter);
            Assert.AreEqual(complexParameter, testPage2.ComplexObject);
        }
Exemple #3
0
        public void FlyoutCreatesCorrectNumberOfGroupsForAsSingleItem()
        {
            var shell     = new Shell();
            var shellItem = new ShellItem()
            {
                FlyoutDisplayOptions = FlyoutDisplayOptions.AsSingleItem,
            };
            var shellItem2 = new ShellItem()
            {
                FlyoutDisplayOptions = FlyoutDisplayOptions.AsSingleItem,
            };

            shellItem.Items.Add(CreateShellSection());
            shellItem.Items.Add(CreateShellSection());
            shellItem2.Items.Add(CreateShellContent());
            shellItem2.Items.Add(CreateShellSection());


            shell.Items.Add(shellItem);
            shell.Items.Add(shellItem2);
            IShellController shellController = shell;
            var groups = shellController.GenerateFlyoutGrouping();

            Assert.AreEqual(groups.Count, 1);
            Assert.AreEqual(groups[0].Count, 2);
        }
Exemple #4
0
        public override bool ShouldSelectItem(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var row  = indexPath.Row;
            var item = ShellSectionController.GetItems()[row];
            IShellController shellController = _shellContext.Shell;

            if (item == ShellSection.CurrentItem)
            {
                return(true);
            }
            return(shellController.ProposeNavigation(ShellNavigationSource.ShellContentChanged, (ShellItem)ShellSection.Parent, ShellSection, item, ShellSection.Stack, true));
        }
Exemple #5
0
        public LocalServerListControl(IKernel kernel)
            : base(kernel)
        {
            _shellController        = kernel.Get <IShellController>();
            _siteService            = kernel.Get <ISiteService>();
            _editLocalServerControl = kernel.Get <EditLocalServerControl>();

            _addLocalServerButton        = new ArrowButton();
            _addLocalServerButton.Text   = "Add Local Server";
            _addLocalServerButton.Click += addLocalServerButton_Click;

            InitializeComponent();
        }
        public LocalServerListControl(IKernel kernel)
            : base(kernel)
        {
            _shellController = kernel.Get<IShellController>();
            _siteService = kernel.Get<ISiteService>();
            _editLocalServerControl = kernel.Get<EditLocalServerControl>();

            _addLocalServerButton = new ArrowButton();
            _addLocalServerButton.Text = "Add Local Server";
            _addLocalServerButton.Click += addLocalServerButton_Click;

            InitializeComponent();
        }
Exemple #7
0
        public void MenuItemGeneratesForShellContent()
        {
            var shell = new TestShell();

            var shellContent = CreateShellContent();

            shellContent.MenuItems.Add(new MenuItem());
            shell.Items.Add(shellContent);

            IShellController shellController = (IShellController)shell;
            var groups = shellController.GenerateFlyoutGrouping();

            Assert.AreEqual(groups.SelectMany(x => x.OfType <IMenuItemController>()).Count(), 1);
        }
Exemple #8
0
        public void FlyoutItemVisibleWorksForMenuItemsAddedAsShellContent()
        {
            var shell = new TestShell();

            var shellContent = CreateShellContent();

            shellContent.MenuItems.Add(CreateNonVisibleMenuItem());
            shell.Items.Add(shellContent);

            IShellController shellController = (IShellController)shell;
            var groups = shellController.GenerateFlyoutGrouping();

            Assert.AreEqual(groups.SelectMany(x => x.OfType <IMenuItemController>()).Count(), 0);
        }
Exemple #9
0
        public static BaseShellItem SearchForPart(this IShellController shell, Func <BaseShellItem, bool> searchBy)
        {
            var items = shell.GetItems();

            for (var i = 0; i < items.Count; i++)
            {
                var result = SearchForPart(items[i], searchBy);
                if (result != null)
                {
                    return(result);
                }
            }

            return(null);
        }
Exemple #10
0
        public void MenuItemGeneratesForShellSection()
        {
            var shell = new TestShell();

            var shellSection = CreateShellSection <Tab>();

            shellSection.CurrentItem.MenuItems.Add(new MenuItem());
            shellSection.FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems;
            shell.Items.Add(shellSection);

            IShellController shellController = (IShellController)shell;
            var groups = shellController.GenerateFlyoutGrouping();

            Assert.AreEqual(1, groups.SelectMany(x => x.OfType <IMenuItemController>()).Count());
        }
Exemple #11
0
        public void FlyoutItemNotVisibleWhenShellContentSetToNotVisible()
        {
            var shell        = new TestShell();
            var shellSection = CreateShellSection();

            shellSection.FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems;
            shellSection.Items.Add(CreateShellContent());
            shellSection.Items[0].IsVisible = false;
            shell.Items.Add(shellSection);

            IShellController shellController = (IShellController)shell;
            var groups = shellController.GenerateFlyoutGrouping();

            Assert.AreEqual(1, groups.Count);
            Assert.AreEqual(1, groups[0].Count);
        }
Exemple #12
0
        public NavigationControl(IKernel kernel)
            : this()
        {
            Asserter.AssertIsNotNull(kernel, "kernel");

            _kernel          = kernel;
            _shellController = _kernel.Get <IShellController>();
            _storageService  = _kernel.Get <IStorageService>();

            Asserter.AssertIsNotNull(_shellController, "_shell");
            Asserter.AssertIsNotNull(_storageService, "_storageService");

            _shellController.CurrentViewChanged += new EventHandler(shellController_CurrentViewChanged);

            serverListsGroupControl.SelectPublicServers();
        }
        public NavigationControl(IKernel kernel)
            : this()
        {
            Asserter.AssertIsNotNull(kernel, "kernel");

            _kernel = kernel;
            _shellController = _kernel.Get<IShellController>();
            _storageService = _kernel.Get<IStorageService>();

            Asserter.AssertIsNotNull(_shellController, "_shell");
            Asserter.AssertIsNotNull(_storageService, "_storageService");

            _shellController.CurrentViewChanged += new EventHandler(shellController_CurrentViewChanged);

            serverListsGroupControl.SelectPublicServers();
        }
Exemple #14
0
        public void FlyoutItemVisibleWorksForMenuItemsTabAsMultipleItems()
        {
            var shell = new TestShell();

            var flyoutItem = CreateShellItem <FlyoutItem>();

            flyoutItem.FlyoutDisplayOptions             = FlyoutDisplayOptions.AsMultipleItems;
            flyoutItem.CurrentItem.FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems;
            flyoutItem.CurrentItem.CurrentItem.MenuItems.Add(CreateNonVisibleMenuItem());
            shell.Items.Add(flyoutItem);

            IShellController shellController = (IShellController)shell;
            var groups = shellController.GenerateFlyoutGrouping();

            Assert.AreEqual(0, groups.SelectMany(x => x.OfType <IMenuItemController>()).Count());
        }
Exemple #15
0
        public void FlyoutItemVisibleWorksForMenuItemsAddedAsShellItem()
        {
            var shell = new TestShell();
            var item  = new MenuShellItem(CreateNonVisibleMenuItem());

            shell.Items.Add(item);

            var itemsAreEquals = item.Equals(shell.Items[0]);

            Assert.IsTrue(itemsAreEquals);

            IShellController shellController = (IShellController)shell;
            var groups = shellController.GenerateFlyoutGrouping();

            var r = groups.SelectMany(x => x.OfType <IMenuItemController>());

            Assert.AreEqual(r.Count(), 0);
        }
Exemple #16
0
        public async Task FlyoutNavigateToImplicitContentPage()
        {
            var shell     = new Shell();
            var shellITem = new ShellItem()
            {
                FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems,
            };
            var shellSection = new ShellSection()
            {
                Title = "can navigate to"
            };

            shellSection.Items.Add(new ContentPage());

            var shellSection2 = new ShellSection()
            {
                Title = "can navigate to"
            };

            shellSection2.Items.Add(new ContentPage());

            var implicitSection = CreateShellSection(new ContentPage(), asImplicit: true);

            shellITem.Items.Add(shellSection);
            shellITem.Items.Add(shellSection2);
            shellITem.Items.Add(implicitSection);

            shell.Items.Add(shellITem);
            IShellController shellController = (IShellController)shell;

            await shellController.OnFlyoutItemSelectedAsync(shellSection2);

            Assert.AreEqual(shellSection2, shell.CurrentItem.CurrentItem);

            await shellController.OnFlyoutItemSelectedAsync(shellSection);

            Assert.AreEqual(shellSection, shell.CurrentItem.CurrentItem);

            await shellController.OnFlyoutItemSelectedAsync(implicitSection);

            Assert.AreEqual(implicitSection, shell.CurrentItem.CurrentItem);
        }
Exemple #17
0
        public async Task NavigatedFiresAfterSwitchingFlyoutItems()
        {
            SetupBuilder();

            var shellContent1 = new ShellContent()
            {
                Content = new ContentPage()
            };
            var shellContent2 = new ShellContent()
            {
                Content = new ContentPage()
            };

            var shell = await CreateShellAsync((shell) =>
            {
                shell.Items.Add(shellContent1);
                shell.Items.Add(shellContent2);
            });

            await CreateHandlerAndAddToWindow <ShellHandler>(shell, async (handler) =>
            {
                IShellController shellController = shell;
                var currentItem = shell.CurrentItem;
                // For now on iOS/Android we're just making sure nothing crashes
#if WINDOWS
                Assert.NotNull(currentItem.Handler);
#endif

                await shellController.OnFlyoutItemSelectedAsync(shellContent2);
                await shell.Navigation.PushAsync(new ContentPage());
                await shell.GoToAsync("..");

#if WINDOWS
                Assert.NotNull(shell.Handler);
                Assert.NotNull(shell.CurrentItem.Handler);
                Assert.NotNull(shell.CurrentItem.CurrentItem.Handler);
                Assert.Null(currentItem.Handler);
                Assert.Null(currentItem.CurrentItem.Handler);
#endif
            });
        }
        public ApplicationController(Lazy <ShellViewModel> shellViewModelLazy,
                                     Lazy <SettingsViewModel> settingsViewModelLazy,
                                     Lazy <AboutViewModel> aboutViewModelLazy, Lazy <HelpViewModel> helpViewModelLazy,
                                     Lazy <LogViewModel> logViewModelLazy,
                                     Lazy <ShellService> shellServiceLazy, CompositionContainer compositionContainer,
                                     Lazy <IAccountAuthenticationService> accountAuthenticationServiceLazy, IShellController shellController,
                                     Lazy <SystemTrayNotifierViewModel> lazySystemTrayNotifierViewModel,
                                     IGuiInteractionService guiInteractionService, ILogController logController)
        {
            //ViewModels
            _shellViewModel              = shellViewModelLazy.Value;
            _settingsViewModel           = settingsViewModelLazy.Value;
            _aboutViewModel              = aboutViewModelLazy.Value;
            _helpViewModel               = helpViewModelLazy.Value;
            _logViewModel                = logViewModelLazy.Value;
            _systemTrayNotifierViewModel = lazySystemTrayNotifierViewModel.Value;
            //Commands
            _shellViewModel.Closing += ShellViewModelClosing;
            _exitCommand             = new DelegateCommand(Close);

            //Services
            AccountAuthenticationService = accountAuthenticationServiceLazy.Value;

            _shellService              = shellServiceLazy.Value;
            _shellService.ShellView    = _shellViewModel.View;
            _shellService.SettingsView = _settingsViewModel.View;
            _shellService.AboutView    = _aboutViewModel.View;
            _shellService.HelpView     = _helpViewModel.View;
            _shellService.LogView      = _logViewModel.View;
            _shellController           = shellController;
            _guiInteractionService     = guiInteractionService;
            _logController             = logController;
            if (_shellViewModel.IsSettingsVisible)
            {
                _settingsViewModel.Load();
            }
        }
        public ApplicationController(Lazy<ShellViewModel> shellViewModelLazy,
            Lazy<SettingsViewModel> settingsViewModelLazy,
            Lazy<AboutViewModel> aboutViewModelLazy, Lazy<HelpViewModel> helpViewModelLazy,
            Lazy<LogViewModel> logViewModelLazy,
            Lazy<ShellService> shellServiceLazy, CompositionContainer compositionContainer,
            Lazy<IAccountAuthenticationService> accountAuthenticationServiceLazy, IShellController shellController,
            Lazy<SystemTrayNotifierViewModel> lazySystemTrayNotifierViewModel,
            IGuiInteractionService guiInteractionService, ILogController logController)
        {
            //ViewModels
            _shellViewModel = shellViewModelLazy.Value;
            _settingsViewModel = settingsViewModelLazy.Value;
            _aboutViewModel = aboutViewModelLazy.Value;
            _helpViewModel = helpViewModelLazy.Value;
            _logViewModel = logViewModelLazy.Value;
            _systemTrayNotifierViewModel = lazySystemTrayNotifierViewModel.Value;
            //Commands
            _shellViewModel.Closing += ShellViewModelClosing;
            _exitCommand = new DelegateCommand(Close);

            //Services
            AccountAuthenticationService = accountAuthenticationServiceLazy.Value;

            _shellService = shellServiceLazy.Value;
            _shellService.ShellView = _shellViewModel.View;
            _shellService.SettingsView = _settingsViewModel.View;
            _shellService.AboutView = _aboutViewModel.View;
            _shellService.HelpView = _helpViewModel.View;
            _shellService.LogView = _logViewModel.View;
            _shellController = shellController;
            _guiInteractionService = guiInteractionService;
            _logController = logController;
            if (_shellViewModel.IsSettingsVisible)
            {
                _settingsViewModel.Load();
            }
        }
        public async Task NavigationBetweenFlyoutItemWithPushedPageRetainsQueryString()
        {
            var testPage1 = new ShellTestPage();
            var testPage2 = new ShellTestPage();

            var flyoutItem1 = CreateShellItem <FlyoutItem>(testPage1, shellItemRoute: "flyoutItem1");
            var flyoutItem2 = CreateShellItem <FlyoutItem>(testPage2, shellItemRoute: "flyoutItem2");

            Routing.RegisterRoute("details", typeof(ShellTestPage));


            var shell = new TestShell(flyoutItem1, flyoutItem2);

            IShellController shellController = shell;
            await shell.GoToAsync(new ShellNavigationState($"//flyoutItem2/details?{nameof(ShellTestPage.SomeQueryParameter)}=1234"));

            await shellController.OnFlyoutItemSelectedAsync(flyoutItem1);

            await shellController.OnFlyoutItemSelectedAsync(flyoutItem2);

            var testPage = (shell.CurrentItem.CurrentItem as IShellSectionController).PresentedPage as ShellTestPage;

            Assert.AreEqual("1234", testPage.SomeQueryParameter);
        }
Exemple #21
0
        public async Task NavigatedFiresAfterSwitchingFlyoutItemsBothWithPushedPages()
        {
            var shellContent1 = new ShellContent()
            {
                Content = new ContentPage()
            };
            var shellContent2 = new ShellContent()
            {
                Content = new ContentPage()
            };

            var shell = new TestShell(shellContent1, shellContent2);
            IShellController shellController = shell;
            await shell.Navigation.PushAsync(new ContentPage());

            await shellController.OnFlyoutItemSelectedAsync(shellContent2);

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

            await shellController.OnFlyoutItemSelectedAsync(shellContent1);

            Assert.AreEqual(2, shell.Items[0].Items[0].Navigation.NavigationStack.Count);
            Assert.AreEqual(2, shell.Items[1].Items[0].Navigation.NavigationStack.Count);
        }
Exemple #22
0
 public WorkflowButtonsPresenter([CreateNew] IShellController controller)
 {
     _controller = controller;
 }