public TestShellSection(ShellContent shellContent) { Items.Add(shellContent); }
public ShellFragmentContainer(ShellContent shellContent) : base() { ShellContentTab = shellContent; }
protected virtual void OnShellSectionPropertyChanged(object sender, PropertyChangedEventArgs e) { if (_isDisposed) { return; } if (e.PropertyName == ShellSection.CurrentItemProperty.PropertyName) { var newContent = ShellSection.CurrentItem; var oldContent = _currentContent; if (newContent == null) { return; } if (_currentContent == null) { _currentContent = newContent; _currentIndex = ShellSectionController.GetItems().IndexOf(_currentContent); _tracker.Page = ((IShellContentController)newContent).Page; return; } var items = ShellSectionController.GetItems(); if (items.Count == 0) { return; } var oldIndex = _currentIndex; var newIndex = items.IndexOf(newContent); var oldRenderer = _renderers[oldContent]; // this means the currently visible item has been removed if (oldIndex == -1 && _currentIndex <= newIndex) { newIndex++; } _currentContent = newContent; _currentIndex = newIndex; if (!_renderers.ContainsKey(newContent)) { return; } var currentRenderer = _renderers[newContent]; _isAnimatingOut = oldRenderer; _pageAnimation?.StopAnimation(true); _pageAnimation = null; _pageAnimation = CreateContentAnimator(oldRenderer, currentRenderer, oldIndex, newIndex, _containerArea); if (_pageAnimation != null) { _pageAnimation.AddCompletion((p) => { if (_isDisposed) { return; } if (p == UIViewAnimatingPosition.End) { RemoveNonVisibleRenderers(); } }); _pageAnimation.StartAnimation(); } else { RemoveNonVisibleRenderers(); } } }
public ShellFragmentContainer(ShellContent shellContent, IMauiContext mauiContext) { ShellContentTab = shellContent; _mauiContext = mauiContext; }
public ShellContentRenderer(ShellContent content) { ShellContent = content; NativeView = GetNativeView(content); }
public ShellContentFragment(IShellContext shellContext, ShellContent shellContent) { _shellContext = shellContext; _shellContent = shellContent; }
static EvasObject GetNativeView(ShellContent content) { var page = (content as IShellContentController).GetOrCreateContent(); return(Platform.GetOrCreateRenderer(page).NativeView); }
internal void NavigateToContent(ShellNavigationSource source, ShellContent shellContent, Page page, bool animate = true) { Page nextPage = null; if (source == ShellNavigationSource.PopToRoot) { nextPage = (shellContent as IShellContentController).GetOrCreateContent(); } else { nextPage = (ShellSection as IShellSectionController) .PresentedPage ?? ((IShellContentController)shellContent)?.GetOrCreateContent(); } if (CurrentContent != null && Page != null) { Page.PropertyChanged -= OnPagePropertyChanged; ((IShellContentController)CurrentContent).RecyclePage(Page); } CurrentContent = shellContent; if (nextPage != null) { Page = nextPage; Page.PropertyChanged += OnPagePropertyChanged; switch (source) { case ShellNavigationSource.Insert: { var pageIndex = ShellSection.Stack.ToList().IndexOf(page); if (pageIndex == Frame.BackStack.Count - 1) { Frame.Navigate(typeof(ShellPageWrapper), GetTransitionInfo(source)); } else { Frame.BackStack.Insert(pageIndex, new PageStackEntry(typeof(ShellPageWrapper), null, GetTransitionInfo(source))); } break; } case ShellNavigationSource.Pop: Frame.GoBack(GetTransitionInfo(source)); break; case ShellNavigationSource.Unknown: break; case ShellNavigationSource.Push: Frame.Navigate(typeof(ShellPageWrapper), GetTransitionInfo(source)); break; case ShellNavigationSource.PopToRoot: while (Frame.BackStackDepth > 2) { Frame.BackStack.RemoveAt(1); } Frame.GoBack(GetTransitionInfo(source)); break; case ShellNavigationSource.Remove: { var pageIndex = FormsNavigationStack.IndexOf(page); if (pageIndex == Frame.BackStack.Count - 1) { Frame.GoBack(GetTransitionInfo(source)); } else { Frame.BackStack.RemoveAt(pageIndex); } break; } case ShellNavigationSource.ShellItemChanged: break; case ShellNavigationSource.ShellSectionChanged: Frame.Navigate(typeof(ShellPageWrapper), GetTransitionInfo(source)); break; case ShellNavigationSource.ShellContentChanged: break; } UpdateSearchHandler(Shell.GetSearchHandler(Page)); var wrapper = (ShellPageWrapper)(Frame.Content); if (wrapper.Page == null) { wrapper.Page = Page; } wrapper.LoadPage(); FormsNavigationStack = ShellSection.Stack.ToList(); } }
public virtual IShellItemRenderer CreateItemRenderer(ShellContent item) { return(new ShellContentRenderer(item)); }
public async Task SelectedItemOnShellViewCorrectWithImplictFlyoutItem() { SetupBuilder(); var page1 = new ContentPage(); var page2 = new ContentPage(); var page3 = new ContentPage(); var flyoutItem1 = new FlyoutItem() { Items = { new ShellContent() { Content = page1, Title = "Content 1" }, } }; var flyoutItem2ShellSection = new ShellSection() { Items = { new ShellContent() { Content = page2, Title = "Content 2" }, } }; var flyoutItem3ShellContent = new ShellContent() { Content = page3, Title = "Content 3" }; var shell = await CreateShellAsync((shell) => { shell.Items.Add(flyoutItem1); shell.Items.Add(flyoutItem2ShellSection); }); await CreateHandlerAndAddToWindow <ShellHandler>(shell, async (handler) => { var navigationView = handler.PlatformView as MauiNavigationView; var menuItems = navigationView.MenuItemsSource as IList <NavigationViewItemViewModel>; Assert.Equal(flyoutItem1, navigationView.SelectedItem); // Switch to Shell Section shell.CurrentItem = flyoutItem2ShellSection; await OnLoadedAsync(page2); Assert.Equal(flyoutItem2ShellSection, navigationView.SelectedItem); // Switch to Shell Content shell.CurrentItem = flyoutItem3ShellContent; await OnLoadedAsync(page3); Assert.Equal(flyoutItem3ShellContent, navigationView.SelectedItem); }); }
internal void NavigateToContent(ShellNavigationSource source, ShellContent shellContent, Page page, bool animate = true) { Page nextPage = (ShellSection as IShellSectionController) .PresentedPage ?? ((IShellContentController)shellContent)?.GetOrCreateContent(); if (CurrentContent != null && Page != null) { Page.PropertyChanged -= OnPagePropertyChanged; ((IShellContentController)CurrentContent).RecyclePage(Page); } CurrentContent = shellContent; if (nextPage != null) { Page = nextPage; Page.PropertyChanged += OnPagePropertyChanged; switch (source) { case ShellNavigationSource.Insert: break; case ShellNavigationSource.Pop: Frame.GoBack(GetTransitionInfo(source)); break; case ShellNavigationSource.Unknown: break; case ShellNavigationSource.Push: Frame.Navigate(typeof(ShellPageWrapper), GetTransitionInfo(source)); break; case ShellNavigationSource.PopToRoot: while (Frame.BackStackDepth > 1) { Frame.GoBack(GetTransitionInfo(source)); } break; case ShellNavigationSource.Remove: break; case ShellNavigationSource.ShellItemChanged: break; case ShellNavigationSource.ShellSectionChanged: Frame.Navigate(typeof(ShellPageWrapper), GetTransitionInfo(source)); break; case ShellNavigationSource.ShellContentChanged: break; } UpdateSearchHandler(Shell.GetSearchHandler(Page)); var wrapper = (ShellPageWrapper)(Frame.Content); if (wrapper.Page == null) { wrapper.Page = Page; } wrapper.LoadPage(); } }