Exemple #1
0
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();

            bool layoutFlyout  = false;
            bool layoutDetails = false;

            if (Forms.IsiOS13OrNewer)
            {
                layoutFlyout  = _flyoutController?.View?.Superview != null;
                layoutDetails = _detailController?.View?.Superview != null;
            }
            else if (View.Subviews.Length < 2)
            {
                return;
            }
            else
            {
                layoutFlyout  = true;
                layoutDetails = true;
            }

            if (layoutFlyout)
            {
                var flyoutBounds = _flyoutController.View.Frame;

                if (Forms.IsiOS13OrNewer)
                {
                    _flyoutWidth = flyoutBounds.Width;
                }
                else
                {
                    _flyoutWidth = (nfloat)Math.Max(_flyoutWidth, flyoutBounds.Width);
                }

                if (!flyoutBounds.IsEmpty)
                {
                    FlyoutPage.FlyoutBounds = new Rectangle(0, 0, _flyoutWidth, flyoutBounds.Height);
                }
            }

            if (layoutDetails)
            {
                var detailsBounds = _detailController.View.Frame;
                if (!detailsBounds.IsEmpty)
                {
                    FlyoutPage.DetailBounds = new Rectangle(0, 0, detailsBounds.Width, detailsBounds.Height);
                }
            }

            if (_previousViewDidLayoutSize == CGSize.Empty)
            {
                _previousViewDidLayoutSize = View.Bounds.Size;
            }

            // Is this being called from a rotation
            if (_previousViewDidLayoutSize != View.Bounds.Size)
            {
                _previousViewDidLayoutSize = View.Bounds.Size;

                // make sure IsPresented matches state of Flyout View
                if (FlyoutPage.CanChangeIsPresented && FlyoutPage.IsPresented != IsFlyoutVisible)
                {
                    ElementController.SetValueFromRenderer(Xamarin.Forms.FlyoutPage.IsPresentedProperty, IsFlyoutVisible);
                }
            }

            if (_previousDisplayMode != PreferredDisplayMode)
            {
                _previousDisplayMode = PreferredDisplayMode;

                // make sure IsPresented matches state of Flyout View
                if (FlyoutPage.CanChangeIsPresented && FlyoutPage.IsPresented != IsFlyoutVisible)
                {
                    ElementController.SetValueFromRenderer(Xamarin.Forms.FlyoutPage.IsPresentedProperty, IsFlyoutVisible);
                }
            }
        }
Exemple #2
0
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();

            bool layoutMaster  = false;
            bool layoutDetails = false;

            if (System.Maui.Maui.IsiOS13OrNewer)
            {
                layoutMaster  = _masterController?.View?.Superview != null;
                layoutDetails = _detailController?.View?.Superview != null;
            }
            else if (View.Subviews.Length < 2)
            {
                return;
            }
            else
            {
                layoutMaster  = true;
                layoutDetails = true;
            }

            if (layoutMaster)
            {
                var masterBounds = _masterController.View.Frame;

                if (System.Maui.Maui.IsiOS13OrNewer)
                {
                    _masterWidth = masterBounds.Width;
                }
                else
                {
                    _masterWidth = (nfloat)Math.Max(_masterWidth, masterBounds.Width);
                }

                if (!masterBounds.IsEmpty)
                {
                    MasterDetailPage.MasterBounds = new Rectangle(0, 0, _masterWidth, masterBounds.Height);
                }
            }

            if (layoutDetails)
            {
                var detailsBounds = _detailController.View.Frame;
                if (!detailsBounds.IsEmpty)
                {
                    MasterDetailPage.DetailBounds = new Rectangle(0, 0, detailsBounds.Width, detailsBounds.Height);
                }
            }

            if (_previousViewDidLayoutSize == CGSize.Empty)
            {
                _previousViewDidLayoutSize = View.Bounds.Size;
            }

            // Is this being called from a rotation
            if (_previousViewDidLayoutSize != View.Bounds.Size)
            {
                _previousViewDidLayoutSize = View.Bounds.Size;

                // make sure IsPresented matches state of Master View
                if (MasterDetailPage.CanChangeIsPresented && MasterDetailPage.IsPresented != IsMasterVisible)
                {
                    ElementController.SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, IsMasterVisible);
                }
            }

            if (_previousDisplayMode != PreferredDisplayMode)
            {
                _previousDisplayMode = PreferredDisplayMode;

                // make sure IsPresented matches state of Master View
                if (MasterDetailPage.CanChangeIsPresented && MasterDetailPage.IsPresented != IsMasterVisible)
                {
                    ElementController.SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, IsMasterVisible);
                }
            }
        }