protected override void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { var viewsToLookAt = new FormsStack <NSView>(Subviews); while (viewsToLookAt.Count > 0) { var view = viewsToLookAt.Pop(); var viewCellRenderer = view as ViewCellNSView; if (viewCellRenderer != null) { viewCellRenderer.RemoveFromSuperview(); viewCellRenderer.Dispose(); } else { foreach (var child in view.Subviews) { viewsToLookAt.Push(child); } } } } _disposed = true; base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { if (NavigationController != null) { NavigationController.PushRequested -= OnPushRequested; NavigationController.PopRequested -= OnPopRequested; NavigationController.PopToRootRequested -= OnPopToRootRequested; NavigationController.RemovePageRequested -= OnRemovedPageRequested; NavigationController.InsertPageBeforeRequested -= OnInsertPageBeforeRequested; } _toolbarTracker = null; if (_currentPage != null) { _currentPage.PropertyChanged -= OnCurrentPagePropertyChanged; _currentPage = null; } if (_currentStack != null) { _currentStack.ForEach(s => s.Dispose()); _currentStack = null; } } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing && _insetTracker != null) { _insetTracker.Dispose(); _insetTracker = null; var viewsToLookAt = new FormsStack <UIView>(Subviews); while (viewsToLookAt.Count > 0) { var view = viewsToLookAt.Pop(); var viewCellRenderer = view as ViewCellRenderer.ViewTableCell; if (viewCellRenderer != null) { viewCellRenderer.Dispose(); } else { foreach (var child in view.Subviews) { viewsToLookAt.Push(child); } } } } base.Dispose(disposing); }
void ClearChildren(ViewGroup group) { if (group == null) { return; } int count = group.ChildCount; for (var i = 0; i < count; i++) { AView child = group.GetChildAt(i); var g = child as ViewGroup; if (g != null) { ClearChildren(g); } Type childType = child.GetType(); FormsStack <AView> stack; if (!_freeViews.TryGetValue(childType, out stack)) { _freeViews[childType] = stack = new FormsStack <AView>(); } stack.Push(child); } group.RemoveAllViews(); }
void InsertPageBefore(Page page, Page before) { if (before == null) { throw new ArgumentNullException(nameof(before)); } if (page == null) { throw new ArgumentNullException(nameof(page)); } var currentList = _currentStack.Reverse().ToList(); var beforePageIndex = currentList.IndexOf(p => p.Page == before); var pageWrapper = new NavigationChildPageWrapper(page); currentList.Insert(beforePageIndex, pageWrapper); _currentStack = new FormsStack <NavigationChildPageWrapper>(currentList); var vc = CreateViewControllerForPage(page); vc.SetElementSize(new Size(View.Bounds.Width, View.Bounds.Height)); page.Layout(new Rectangle(0, 0, View.Bounds.Width, View.Frame.Height)); vc.NativeView.WantsLayer = true; var beforeRenderer = Platform.GetRenderer(before); var beforeControllerIndex = ChildViewControllers.IndexOf(beforeRenderer.ViewController); InsertChildViewController(vc.ViewController, beforeControllerIndex); View.AddSubview(vc.NativeView, NSWindowOrderingMode.Below, beforeRenderer.NativeView); }
void PushRenderer(IVisualElementRenderer renderer) { var reflectableType = renderer as System.Reflection.IReflectableType; var rendererType = reflectableType != null?reflectableType.GetTypeInfo().AsType() : renderer.GetType(); FormsStack <IVisualElementRenderer> renderers; if (!_freeRenderers.TryGetValue(rendererType, out renderers)) { _freeRenderers[rendererType] = renderers = new FormsStack <IVisualElementRenderer>(); } renderers.Push(renderer); }
void RemovePage(Page page, bool removeFromStack) { page?.SendDisappearing(); var target = Platform.GetRenderer(page); target?.NativeView?.RemoveFromSuperview(); target?.ViewController?.RemoveFromParentViewController(); target?.Dispose(); if (removeFromStack) { var newSource = _currentStack.Reverse().Where(w => w.Page != page); _currentStack = new FormsStack <NavigationChildPageWrapper>(newSource); } }
protected override void Dispose(bool disposing) { if (!_disposed && disposing) { if (Element != null) { if (NavigationPage != null) { NavigationPage.PushRequested -= OnPushRequested; NavigationPage.PopRequested -= OnPopRequested; NavigationPage.PopToRootRequested -= OnPopToRootRequested; NavigationPage.RemovePageRequested -= OnRemovedPageRequested; NavigationPage.InsertPageBeforeRequested -= OnInsertPageBeforeRequested; NavigationPage.Popped -= OnPopped; NavigationPage.PoppedToRoot -= OnPoppedToRoot; NavigationPage.SendDisappearing(); } ((Element as IPageContainer <Page>)?.CurrentPage as Page)?.SendDisappearing(); Element.PropertyChanged -= OnElementPropertyChanged; Platform.SetRenderer(Element, null); Element = null; } _tracker?.Dispose(); _tracker = null; _events?.Dispose(); _events = null; if (_currentStack != null) { foreach (var childPageWrapper in _currentStack) { childPageWrapper.Dispose(); } _currentStack.Clear(); _currentStack = null; } Platform.NativeToolbarTracker.Navigation = null; _disposed = true; } base.Dispose(disposing); }
public NavigationPageRenderer() { _currentStack = new FormsStack <NavigationChildPage>(); _toolbarTracker = new GtkToolbarTracker(); }