static partial void ProcessAutoPackage(Maui.IElement element) { if (element.Handler is not IPlatformViewHandler nvh || nvh.ContainerView is not Panel panel) { return; } panel.Children.Clear(); if (element is not IVisualTreeElement vte) { return; } var mauiContext = element?.Handler?.MauiContext; if (mauiContext == null) { return; } foreach (var child in vte.GetVisualChildren()) { if (child is Maui.IElement childElement) { panel.Children.Add(childElement.ToPlatform(mauiContext)); } } }
public override void SetVirtualView(Maui.IElement view) { if (_shellSection != null) { ((IShellSectionController)_shellSection).NavigationRequested -= OnNavigationRequested; ((IShellController)_shellSection.FindParentOfType <Shell>() !).RemoveAppearanceObserver(this); } // If we've already connected to the navigation manager // then we need to make sure to disconnect and connect up to // the new incoming virtual view if (_navigationManager?.NavigationView != null && _navigationManager.NavigationView != view) { _navigationManager.Disconnect(_navigationManager.NavigationView, PlatformView); if (view is IStackNavigation stackNavigation) { _navigationManager.Connect(stackNavigation, PlatformView); } } base.SetVirtualView(view); _shellSection = (ShellSection)view; if (_shellSection != null) { ((IShellSectionController)_shellSection).NavigationRequested += OnNavigationRequested; ((IShellController)_shellSection.FindParentOfType <Shell>() !).AddAppearanceObserver(this, _shellSection); } }
static partial void ProcessAutoPackage(Maui.IElement element) { if (element?.Handler?.PlatformView is not AViewGroup viewGroup) { return; } viewGroup.RemoveAllViews(); if (element is not IVisualTreeElement vte) { return; } var mauiContext = element?.Handler?.MauiContext; if (mauiContext == null) { return; } foreach (var child in vte.GetVisualChildren()) { if (child is Maui.IElement childElement) { viewGroup.AddView(childElement.ToPlatform(mauiContext)); } } }
public void SetVirtualView( Maui.IElement view, Action <ElementChangedEventArgs <TElement> > onElementChanged, bool autoPackage) { #if WINDOWS VisualElementRenderer <TElement, TNativeElement> .SetVirtualView(view, _viewHandler, onElementChanged, ref _element, ref _mapper, _defaultMapper, autoPackage); #else VisualElementRenderer <TElement> .SetVirtualView(view, _viewHandler, onElementChanged, ref _element, ref _mapper, _defaultMapper, autoPackage); #endif }
public void SetVirtualView( Maui.IElement view, Action <VisualElementChangedEventArgs> onElementChanged, bool autoPackage) { SetVirtualView(view, ElementChanged, false); void ElementChanged(ElementChangedEventArgs <TElement> e) { onElementChanged(new VisualElementChangedEventArgs( e.OldElement as VisualElement, e.NewElement as VisualElement)); } }
public override void SetVirtualView(Maui.IElement view) { if (_shellSection != null) { ((IShellSectionController)_shellSection).NavigationRequested -= OnNavigationRequested; } base.SetVirtualView(view); _shellSection = (ShellSection)view; if (_shellSection != null) { ((IShellSectionController)_shellSection).NavigationRequested += OnNavigationRequested; } }
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (_shellContent != null) { _page = ((IShellContentController)_shellContent).GetOrCreateContent(); } _root = inflater.Inflate(Controls.Resource.Layout.shellcontent, null).JavaCast <CoordinatorLayout>(); var shellContentMauiContext = MauiContext.MakeScoped(layoutInflater: inflater, fragmentManager: ChildFragmentManager); Maui.IElement parentElement = (_shellContent as Maui.IElement) ?? _page; var shellToolbar = new Toolbar(parentElement); ShellToolbarTracker.ApplyToolbarChanges(_shellContext.Shell.Toolbar, shellToolbar); _toolbar = (AToolbar)shellToolbar.ToPlatform(shellContentMauiContext); var appBar = _root.FindViewById <AppBarLayout>(Resource.Id.shellcontent_appbar); appBar.AddView(_toolbar); _viewhandler = _page.ToHandler(shellContentMauiContext); _shellPageContainer = new ShellPageContainer(Context, _viewhandler); if (_root is ViewGroup vg) { vg.AddView(_shellPageContainer); } _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar); _toolbarTracker.SetToolbar(shellToolbar); _toolbarTracker.Page = _page; // this is probably not the most ideal way to do that _toolbarTracker.CanNavigateBack = _shellContent == null; _appearanceTracker = _shellContext.CreateToolbarAppearanceTracker(); ((IShellController)_shellContext.Shell).AddAppearanceObserver(this, _page); if (_shellPageContainer.LayoutParameters is CoordinatorLayout.LayoutParams layoutParams) { layoutParams.Behavior = new AppBarLayout.ScrollingViewBehavior(); } return(_root); }
internal static void DisposeModalAndChildHandlers(this Maui.IElement view) { IPlatformViewHandler renderer; foreach (Element child in ((Element)view).Descendants()) { if (child is VisualElement ve) { ve.Handler?.DisconnectHandler(); if (ve.Handler is IDisposable disposable) { disposable.Dispose(); } } } if (view is VisualElement visualElement) { renderer = (visualElement.Handler as IPlatformViewHandler); if (renderer != null) { if (renderer.ViewController != null) { if (renderer.ViewController.ParentViewController is Platform.ModalWrapper modalWrapper) { modalWrapper.Dispose(); } } renderer.PlatformView?.RemoveFromSuperview(); if (view.Handler is IDisposable disposable) { disposable.Dispose(); } } } }
public override void SetVirtualView(Maui.IElement view) { if (view.Parent is IShellController controller) { if (_shellItem != null) { controller.RemoveAppearanceObserver(this); } _shellItem = (ShellItem)view; base.SetVirtualView(view); if (_shellItem != null) { controller.AddAppearanceObserver(this, _shellItem); } } else { base.SetVirtualView(view); } }
public Toolbar(Maui.IElement parent) { _parent = parent; }
protected override void SetHandler( Maui.IElement element, List <(string Name, MenuBarHandlerUpdate?Args)> events)
public Toolbar(Maui.IElement parent) { _parent = parent; _toolbarTracker.CollectionChanged += (_, __) => ToolbarItems = _toolbarTracker.ToolbarItems; }
protected abstract void SetHandler( Maui.IElement element, List <(string Name, THandlerUpdate?Args)> events);