public static void DisposeModelAndChildrenRenderers(this VisualElement view)
        {
            IVisualElementRenderer renderer;

            foreach (var child in view.Descendants().OfType <VisualElement>())
            {
                renderer = XFPlatform.GetRenderer(child);
                XFPlatform.SetRenderer(child, null);

                if (renderer == null)
                {
                    continue;
                }

                renderer.NativeView.RemoveFromSuperview();
                renderer.Dispose();
            }

            renderer = XFPlatform.GetRenderer(view);
            if (renderer != null)
            {
                renderer.NativeView.RemoveFromSuperview();
                renderer.Dispose();
            }
            XFPlatform.SetRenderer(view, null);
        }
示例#2
0
        /// <summary>
        /// Updates the master detail containers.
        /// </summary>
        void UpdateMasterDetailContainers()
        {
            //((MasterDetailPage)Element).Master.PropertyChanged -= HandleMasterPropertyChanged;

            EmptyContainers();

            if (CurrentPlatform.GetRenderer(((MasterDetailPage)Element).Master) == null)
            {
                CurrentPlatform.SetRenderer(((MasterDetailPage)Element).Master, CurrentPlatform.CreateRenderer(((MasterDetailPage)Element).Master));
            }
            if (CurrentPlatform.GetRenderer(((MasterDetailPage)Element).Detail) == null)
            {
                CurrentPlatform.SetRenderer(((MasterDetailPage)Element).Detail, CurrentPlatform.CreateRenderer(((MasterDetailPage)Element).Detail));
            }

            var masterRenderer = CurrentPlatform.GetRenderer(((MasterDetailPage)Element).Master);
            var detailRenderer = CurrentPlatform.GetRenderer(((MasterDetailPage)Element).Detail);

            //((MasterDetailPage)Element).Master.PropertyChanged += HandleMasterPropertyChanged;

            this.MenuViewController.View.AddSubview(masterRenderer.NativeView);
            this.MenuViewController.AddChildViewController(masterRenderer.ViewController);

            this.RootViewController.View.AddSubview(detailRenderer.NativeView);
            this.RootViewController.AddChildViewController(detailRenderer.ViewController);

            SetNeedsStatusBarAppearanceUpdate();
        }
        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);
        }
示例#4
0
 public override UIViewController ChildViewControllerForStatusBarHidden()
 {
     if (((MasterDetailPage)Element).Detail != null)
     {
         return((UIViewController)CurrentPlatform.GetRenderer(((MasterDetailPage)Element).Detail));
     }
     else
     {
         return(base.ChildViewControllerForStatusBarHidden());
     }
 }
        void SetupPage(Page page, int index)
        {
            IVisualElementRenderer renderer = Platform.GetRenderer(page);

            if (renderer == null)
            {
                renderer = Platform.CreateRenderer(page);
                Platform.SetRenderer(page, renderer);
            }

            page.PropertyChanged -= OnPagePropertyChanged;
            page.PropertyChanged += OnPagePropertyChanged;
        }
示例#6
0
        public static UIViewController CreateViewController(this Page page)
        {
            if (!Forms.IsInitialized)
            {
                throw new InvalidOperationException("call Forms.Init() before this");
            }

            if (!(page.RealParent is Application))
            {
                Application app = new EmbeddedApplication();
                app.MainPage = page;
            }

            var result = new Platform.iOS.Platform();

            result.SetPage(page);
            return(result.ViewController);
        }
        void SetControllers()
        {
            var list   = new List <UIViewController>();
            var titles = new List <string>();

            for (var i = 0; i < Tabbed.Children.Count; i++)
            {
                var child = Tabbed.Children[i];
                //var width = DeviceDisplay.MainDisplayInfo.Width - 64;
                //child.WidthRequest = width;
                //var v = child as VisualElement;

                //if (v == null)
                //    continue;

                var renderer = Platform.GetRenderer(child);
                if (renderer == null)
                {
                    continue;
                }

                //var frameOld = renderer.ViewController.View.Frame;
                //frameOld.Width = (nfloat)width;
                //renderer.ViewController.View.Frame = frameOld;
                list.Add(renderer.ViewController);

                titles.Add(Tabbed.Children[i].Title);
            }
            ViewControllers = list.ToArray();
            var menuitems = Tabbed.Children.Select(x => new Shared.MenuItem()
            {
                Title           = x.Title,
                IconImageSource = x.IconImageSource
            }).ToList();

            TabBar.SetData(menuitems);
        }
        void TeardownPage(Page page, int index)
        {
            page.PropertyChanged -= OnPagePropertyChanged;

            Platform.SetRenderer(page, null);
        }
        UIViewController GetViewController(Page page)
        {
            var renderer = Platform.GetRenderer(page);

            return(renderer?.ViewController);
        }
示例#10
0
        public void SetElement(VisualElement element)
        {
            //--------------------------------------------
            //	Initialize vars
            //--------------------------------------------
            if (this._tracker == null)
            {
                _tracker = new VisualElementTracker(this);
            }

            if (this._events == null)
            {
                _events = new EventTracker(this);
                _events.LoadEvents(View);
            }

            //--------------------------------------------
            //	Reset the old element
            //--------------------------------------------
            var oldElement = this.Element;

            if (oldElement != null)
            {
                oldElement.SizeChanged     -= PageOnSizeChanged;
                oldElement.PropertyChanged -= HandlePropertyChanged;
            }

            //--------------------------------------------
            //	Assign the new element
            //--------------------------------------------

            this.Element                  = element;
            this.Element.SizeChanged     += PageOnSizeChanged;
            this.Element.PropertyChanged += HandlePropertyChanged;

            this.Presented = ((MasterDetailPage)Element).IsPresented;

            //--------------------------------------------
            //	Setup the root and menu view controller
            //--------------------------------------------

            this.RootViewController  = new ChildViewController();
            this.LeftViewController  = new ChildViewController();
            this.RightViewController = new ChildViewController();

            //--------------------------------------------
            //	Fire the element changed event
            //--------------------------------------------

            OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

            //--------------------------------------------
            //	Update the view
            //--------------------------------------------

            /* Master Detail Container */
            UpdateMasterDetailContainers();

            /* Background */
            UpdateBackground();

            /* Menu Background */
            UpdateMenuBackground();

            /* Menu Width */
            UpdateMenuWidth();

            /* Menu Presentation Style */
            UpdateMenuPresentationStyle();

            /* Swipe Range */
            UpdateSwipeRange();

            //--------------------------------------------
            //	Attempt to automatically create a menu click event
            //--------------------------------------------

            var detailRenderer = CurrentPlatform.GetRenderer((element as MasterDetailPage).Detail) as UINavigationController;

            if (detailRenderer != null)
            {
                UIViewController firstPage = detailRenderer?.ViewControllers.FirstOrDefault();
                firstPage.NavigationItem.LeftBarButtonItem.Clicked += HandleMenuIcon_Clicked;
            }

            //EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);

            //if (element != null)
            //	element.SendViewInitialized(NativeView);
        }