void UpdateFlyoutPageContainers()
        {
            ((FlyoutPage)Element).Flyout.PropertyChanged -= HandleFlyoutPropertyChanged;

            EmptyContainers();

            if (Platform.GetRenderer(((FlyoutPage)Element).Flyout) == null)
            {
                Platform.SetRenderer(((FlyoutPage)Element).Flyout, Platform.CreateRenderer(((FlyoutPage)Element).Flyout));
            }
            if (Platform.GetRenderer(((FlyoutPage)Element).Detail) == null)
            {
                Platform.SetRenderer(((FlyoutPage)Element).Detail, Platform.CreateRenderer(((FlyoutPage)Element).Detail));
            }

            var flyoutRenderer = Platform.GetRenderer(((FlyoutPage)Element).Flyout);
            var detailRenderer = Platform.GetRenderer(((FlyoutPage)Element).Detail);

            ((FlyoutPage)Element).Flyout.PropertyChanged += HandleFlyoutPropertyChanged;

            UIView flyoutView = flyoutRenderer.NativeView;

            _flyoutController.View.AddSubview(flyoutView);
            _flyoutController.AddChildViewController(flyoutRenderer.ViewController);

            UIView detailView = detailRenderer.NativeView;

            _detailController.View.AddSubview(detailView);
            _detailController.AddChildViewController(detailRenderer.ViewController);

            SetNeedsStatusBarAppearanceUpdate();
            if (Forms.RespondsToSetNeedsUpdateOfHomeIndicatorAutoHidden)
            {
                SetNeedsUpdateOfHomeIndicatorAutoHidden();
            }

            detailRenderer.ViewController.View.Superview.BackgroundColor = Microsoft.Maui.Graphics.Colors.Black.ToUIColor();

            ToggleAccessibilityElementsHidden();
        }
Beispiel #2
0
        internal void Disconnect(Shell shell = null, bool keepRenderer = false)
        {
            ViewMeasureInvalidated   = null;
            View.MeasureInvalidated -= MeasureInvalidated;
            if (_bindingContext != null && _bindingContext is BaseShellItem baseShell)
            {
                baseShell.PropertyChanged -= OnElementPropertyChanged;
            }

            _bindingContext = null;

            if (!keepRenderer)
            {
                Platform.SetRenderer(View, null);
            }

            if (shell != null)
            {
                shell.RemoveLogicalChild(shell);
            }

            View      = null;
            TableView = null;
        }
Beispiel #3
0
        internal UIContainerCell(string cellId, View view, Shell shell, object context) : base(UITableViewCellStyle.Default, cellId)
        {
            View = view;
            View.MeasureInvalidated += MeasureInvalidated;
            SelectionStyle           = UITableViewCellSelectionStyle.None;

            _renderer = Platform.GetRenderer(view);

            if (_renderer == null)
            {
                _renderer = Platform.CreateRenderer(view);
                Platform.SetRenderer(view, _renderer);
            }

            ContentView.AddSubview(_renderer.NativeView);
            _renderer.NativeView.ClipsToBounds = true;
            ContentView.ClipsToBounds          = true;

            BindingContext = context;
            if (shell != null)
            {
                shell.AddLogicalChild(View);
            }
        }
Beispiel #4
0
        void Controls.Platform.Compatibility.IDisconnectable.Disconnect()
        {
            if (_shellSection != null)
            {
                ((IShellSectionController)_shellSection).RemoveContentInsetObserver(this);
                _shellSection = null;
            }

            if (Element != null)
            {
                Element.PropertyChanged -= OnHandlePropertyChanged;
                Platform.SetRenderer(Element, null);

                if (_appeared)
                {
                    Page.SendDisappearing();
                }

                Element = null;
            }

            _packager?.Disconnect();
            _tracker?.Disconnect();
        }
Beispiel #5
0
        void TeardownPage(Page page, int index)
        {
            page.PropertyChanged -= OnPagePropertyChanged;

            Platform.SetRenderer(page, null);
        }
        public void SetCustomContent(View content)
        {
            if (content == Content)
            {
                return;
            }

            removeScolledEvent?.Invoke();
            removeScolledEvent = null;

            if (Content != null)
            {
                var oldRenderer    = Platform.GetRenderer(Content);
                var oldContentView = ContentView;
                var oldContent     = Content;

                Content     = null;
                ContentView = null;
                oldContent.ClearValue(Platform.RendererProperty);
                oldContentView?.RemoveFromSuperview();
                oldRenderer?.Dispose();
            }
            // If the user hasn't defined custom content then only the ContentView is set
            else if (ContentView != null)
            {
                var oldContentView = ContentView;
                ContentView = null;
                oldContentView.RemoveFromSuperview();
            }

            Content = content;
            if (Content != null)
            {
                var renderer = Platform.CreateRenderer(Content);
                ContentView = renderer.NativeView;
                Platform.SetRenderer(Content, renderer);
                ContentView.ClipsToBounds = true;

                // not sure if there's a more efficient way to do this
                // I can test the native control to see if it inherits from UIScrollView
                // But the CollectionViewRenderer doesn't inherit from UIScrollView
                if (Content is ScrollView sv)
                {
                    sv.Scrolled       += ScrollViewScrolled;
                    removeScolledEvent = () => sv.Scrolled -= ScrollViewScrolled;
                    void ScrollViewScrolled(object sender, ScrolledEventArgs e) =>
                    OnScrolled((nfloat)sv.ScrollY);
                }
                else if (Content is CollectionView cv)
                {
                    cv.Scrolled       += CollectionViewScrolled;
                    removeScolledEvent = () => cv.Scrolled -= CollectionViewScrolled;
                    void CollectionViewScrolled(object sender, ItemsViewScrolledEventArgs e) =>
                    OnScrolled((nfloat)e.VerticalOffset);
                }
                else if (Content is ListView lv)
                {
                    lv.Scrolled       += ListViewScrolled;
                    removeScolledEvent = () => lv.Scrolled -= ListViewScrolled;
                    void ListViewScrolled(object sender, ScrolledEventArgs e) =>
                    OnScrolled((nfloat)e.ScrollY);
                }
            }
        }