Exemplo n.º 1
0
        public static IVisualElementRenderer GetOrCreateRenderer(this VisualElement bindable)
        {
            var renderer = XFPlatform.GetRenderer(bindable);

            if (renderer == null)
            {
                renderer = XFPlatform.CreateRenderer(bindable);
                XFPlatform.SetRenderer(bindable, renderer);
            }
            return(renderer);
        }
Exemplo n.º 2
0
        void OnDisplayPageModalRequested(object sender, ModalHostPage.DisplayPageModalRequestedEventArgs e)
        {
            e.PageToDisplay.Parent = this.Element;
            IVisualElementRenderer renderer = XFPlatform.GetRenderer(e.PageToDisplay);

            if (renderer == null)
            {
                renderer = XFPlatform.CreateRenderer(e.PageToDisplay);
                XFPlatform.SetRenderer(e.PageToDisplay, renderer);
            }

            // TODO: Now display our modal page.
            var modalElement = renderer.GetNativeElement();

            (Control as FormsLightNavigationPage)?.PushModal(modalElement, true);
        }
Exemplo n.º 3
0
        void LoadMaster()
        {
            if (_masterRenderer != null && _popup != null)
            {
                _popup.Child = null;
            }

            Page master = Element.Master;

            if (Platform.GetRenderer(master) == null)
            {
                Platform.SetRenderer(master, Platform.CreateRenderer(master));
            }

            _masterRenderer = Platform.GetRenderer(master);
            var control = _masterRenderer as Panel;

            if (control != null && master.BackgroundColor == Color.Default)
            {
                control.Background = Color.Black.ToBrush();
            }
        }
Exemplo n.º 4
0
        void LoadDetail()
        {
            if (_detailRenderer != null)
            {
                Children.Remove(_detailRenderer.ContainerElement);
            }

            Page detail = Element.Detail;

            if (Platform.GetRenderer(detail) == null)
            {
                Platform.SetRenderer(detail, Platform.CreateRenderer(detail));
            }

            _detailRenderer = Platform.GetRenderer(detail);

            Children.Clear();
            if (_detailRenderer != null)
            {
                Children.Add(_detailRenderer.ContainerElement);
            }
        }
Exemplo n.º 5
0
        void UpdateFooter()
        {
            var footer     = Element.FooterElement;
            var footerView = (VisualElement)footer;

            if (_footerRenderer is object)
            {
                Control.Children.Remove(_footerRenderer.GetNativeElement());
                _footerRenderer.Dispose();
            }

            if (footerView is null)
            {
                return;
            }

            _footerRenderer = Platform.CreateRenderer(footerView);
            Platform.SetRenderer(footerView, _footerRenderer);

            WGrid.SetRow(_footerRenderer.GetNativeElement(), 2);
            Control.Children.Add(_footerRenderer.GetNativeElement());
        }
Exemplo n.º 6
0
        void UpdateHeader()
        {
            var header     = Element.HeaderElement;
            var headerView = (VisualElement)header;

            if (_headerRenderer is object)
            {
                Control.Children.Remove(_headerRenderer.GetNativeElement());
                _headerRenderer.Dispose();
            }

            if (headerView is null)
            {
                return;
            }

            _headerRenderer = Platform.CreateRenderer(headerView);
            Platform.SetRenderer(headerView, _headerRenderer);

            WGrid.SetRow(_headerRenderer.GetNativeElement(), 0);
            Control.Children.Add(_headerRenderer.GetNativeElement());
        }
Exemplo n.º 7
0
            public WrapperControl(View view)
            {
                _view = view;
                _view.MeasureInvalidated += (sender, args) => InvalidateMeasure();

                IVisualElementRenderer visualElementRenderer = Platform.CreateRenderer(view);

                Platform.SetRenderer(view, visualElementRenderer);
                Content = visualElementRenderer.ContainerElement;

                // make sure we re-measure once the template is applied
                var frameworkElement = visualElementRenderer.ContainerElement as FrameworkElement;

                if (frameworkElement != null)
                {
                    frameworkElement.Loaded += (sender, args) =>
                    {
                        ((IVisualElementController)_view).InvalidateMeasure(InvalidationTrigger.MeasureChanged);
                        InvalidateMeasure();
                    };
                }
            }
Exemplo n.º 8
0
        void UpdateRootPage(IReadOnlyList <Page> stack)
        {
            Page first = stack.FirstOrDefault();

            if (first == _currentRoot)
            {
                return;
            }

            if (Children.Count > 0)
            {
                var renderer = Children[0] as IVisualElementRenderer;
                if (renderer != null)
                {
                    Children.RemoveAt(0);

                    var page = renderer.Element as Page;
                    if (page != null)
                    {
                        page.IgnoresContainerArea = false;
                    }

                    if (!stack.Contains(renderer.Element))
                    {
                        Platform.SetRenderer(renderer.Element, null);
                    }
                }
            }

            _currentRoot = first;

            if (first == null)
            {
                return;
            }

            first.IgnoresContainerArea = true;

            IVisualElementRenderer firstRenderer = Platform.GetRenderer(first);

            if (firstRenderer == null)
            {
                firstRenderer = Platform.CreateRenderer(first);
                Platform.SetRenderer(first, firstRenderer);
            }
            var    uiElement = (UIElement)firstRenderer;
            var    platform  = Element.Platform as Platform;
            Canvas canvas    = platform?.GetCanvas();

            //We could be swapping the visible page,
            //so let's make sure we remove it
            if (canvas.Children.Contains(uiElement))
            {
                canvas.Children.Remove(uiElement);
            }
            Children.Add(uiElement);

            // we removed the previous root page, and the new root page is the one being presented
            // at this time there's only 1 page now on the stack (the navigationpage with root)
            // we need to update the platform to set this root page as the visible again
            bool updateRoot = Element.CurrentPage == first && _isRemoving;

            if (updateRoot)
            {
                platform.SetCurrent(Element, false);
            }
        }
Exemplo n.º 9
0
 public static void SetRenderer(this VisualElement self, IVisualElementRenderer renderer)
 {
     Platform.SetRenderer(self, renderer);
 }