Example #1
0
        private async Task PresentModal(Page modal, bool animated)
        {
            IVisualElementRenderer renderer = Platform.GetRenderer((VisualElement)modal);

            if (renderer == null)
            {
                renderer = Platform.CreateRenderer((VisualElement)modal);
                Platform.SetRenderer((VisualElement)modal, renderer);
            }
            ModalWrapper wrapper = new ModalWrapper(renderer);

            if (this.modals.Count > 1)
            {
                var uiViewController = Platform.GetRenderer((VisualElement)this.modals [this.modals.Count - 2]) as NSViewController;
                if (uiViewController != null)
                {
                    uiViewController.PresentViewController((NSViewController)wrapper, null);
                    await Task.Delay(5);

                    return;
                }
            }

            this.renderer.PresentViewController((NSViewController)wrapper, null);
            await Task.Delay(5);
        }
Example #2
0
        internal void DisposeModelAndChildrenRenderers(Element view)
        {
            foreach (VisualElement bindable in view.Descendants())
            {
                IVisualElementRenderer renderer = Platform.GetRenderer(bindable);
                BindableProperty       property = Platform.RendererProperty;
                bindable.ClearValue(property);
                if (renderer != null)
                {
                    // ISSUE: reference to a compiler-generated method
                    renderer.NativeView.RemoveFromSuperview();
                    renderer.Dispose();
                }
            }
            IVisualElementRenderer renderer1 = Platform.GetRenderer((VisualElement)view);

            if (renderer1 != null)
            {
                if (renderer1.ViewController != null)
                {
                    ModalWrapper modalWrapper = renderer1.ViewController.ParentViewController as ModalWrapper;

                    // Not required for Mac
                    //if (modalWrapper != null)
                    //    modalWrapper.Dispose ();
                }

                renderer1.NativeView.RemoveFromSuperview();
                renderer1.Dispose();
            }
            view.ClearValue(Platform.RendererProperty);
        }