Esempio n. 1
0
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (Element != null)
                {
                    Element.OpenRequested  -= OnOpenRequested;
                    Element.CloseRequested -= OnCloseRequested;
                }

                if (_scrollParent != null)
                {
                    if (_scrollParent is ScrollView scrollView)
                    {
                        scrollView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is ListView listView)
                    {
                        listView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is System.Maui.CollectionView collectionView)
                    {
                        collectionView.Scrolled -= OnParentScrolled;
                    }
                }

                if (_contentView != null)
                {
                    _contentView.RemoveFromParent();
                    _contentView.Dispose();
                    _contentView = null;
                }

                if (_actionView != null)
                {
                    _actionView.RemoveFromParent();
                    _actionView.Dispose();
                    _actionView = null;
                }

                if (_initialPoint != null)
                {
                    _initialPoint.Dispose();
                    _initialPoint = null;
                }
            }

            _isDisposed = true;

            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (Element != null)
                {
                    Element.CloseRequested -= OnCloseRequested;
                }

                if (_detector != null)
                {
                    _detector.Dispose();
                    _detector = null;
                }

                if (_scrollParent != null)
                {
                    if (_scrollParent is ScrollView scrollView)
                    {
                        scrollView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is ListView listView)
                    {
                        listView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is Xamarin.Forms.CollectionView collectionView)
                    {
                        collectionView.Scrolled -= OnParentScrolled;
                    }
                }

                if (_contentView != null)
                {
                    _contentView.RemoveFromParent();
                    _contentView.Dispose();
                    _contentView = null;
                }

                if (_actionView != null)
                {
                    _actionView.RemoveFromParent();
                    _actionView.Dispose();
                    _actionView = null;
                }
            }

            _isDisposed = true;

            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (Element != null)
                {
                    Element.CloseRequested -= OnCloseRequested;
                }

                if (_detector != null)
                {
                    _detector.Dispose();
                    _detector = null;
                }

                if (_scrollParent != null)
                {
                    if (_scrollParent is AbsListView listView)
                    {
                        listView.ScrollStateChanged += OnParentScrollStateChanged;
                    }
                    else
                    {
                        _scrollParent.ScrollChange -= OnParentScrollChange;
                    }

                    _scrollParent = null;
                }

                if (_contentView != null)
                {
                    _contentView.RemoveFromParent();
                    _contentView.Dispose();
                    _contentView = null;
                }

                if (_actionView != null)
                {
                    _actionView.RemoveFromParent();
                    _actionView.Dispose();
                    _actionView = null;
                }
            }

            _isDisposed = true;

            base.Dispose(disposing);
        }
Esempio n. 4
0
        void LayoutAsFlyout()
        {
            var flyoutView = _flyoutView;

            if (MauiContext == null || _navigationRoot == null || flyoutView == null)
            {
                return;
            }

            _sideBySideView?.RemoveAllViews();
            _sideBySideView?.RemoveFromParent();

            if (_navigationRoot.Parent != PlatformView)
            {
                _navigationRoot.RemoveFromParent();

                var layoutParameters =
                    new LinearLayoutCompat.LayoutParams(
                        LinearLayoutCompat.LayoutParams.MatchParent,
                        LinearLayoutCompat.LayoutParams.MatchParent);

                DrawerLayout.AddView(_navigationRoot, 0, layoutParameters);
            }

            UpdateDetailsFragmentView();

            if (flyoutView.Parent != PlatformView)
            {
                flyoutView.RemoveFromParent();

                var layoutParameters =
                    new DrawerLayout.LayoutParams(
                        (int)FlyoutWidth,
                        DrawerLayout.LayoutParams.MatchParent,
                        (int)GravityFlags.Start);

                // Flyout has to get added after the content otherwise clicking anywhere
                // on the flyout will cause it to close and gesture
                // recognizers inside the flyout won't fire
                DrawerLayout.AddView(flyoutView, layoutParameters);
            }

            DrawerLayout.CloseDrawer(flyoutView);

            if (VirtualView is IToolbarElement te && te.Toolbar?.Handler is ToolbarHandler th)
            {
                th.SetupWithDrawerLayout(DrawerLayout);
            }
        }