示例#1
0
        protected virtual void UpdateFlyoutFooter()
        {
            if (_footerView != null)
            {
                var oldFooterView = _footerView;
                _rootView.RemoveView(_footerView.PlatformView);
                _footerView = null;
                oldFooterView.TearDown();
            }

            var footer = ((IShellController)_shellContext.Shell).FlyoutFooter;

            if (footer == null)
            {
                return;
            }

            _footerView = new ShellViewRenderer(_shellContext.AndroidContext, footer, MauiContext);

            _rootView.AddView(_footerView.PlatformView);

            if (_footerView.PlatformView.LayoutParameters is CoordinatorLayout.LayoutParams cl)
            {
                cl.Gravity = (int)(GravityFlags.Bottom | GravityFlags.End);
            }

            UpdateFooterLayout();
            UpdateContentLayout();
            UpdateContentBottomMargin();
        }
示例#2
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                _shellContext.Shell.PropertyChanged -= OnShellPropertyChanged;

                if (_flyoutHeader != null)
                {
                    _flyoutHeader.MeasureInvalidated -= OnFlyoutHeaderMeasureInvalidated;
                }

                if (_appBar != null)
                {
                    _appBar.RemoveOnOffsetChangedListener(this);
                    _appBar.RemoveView(_headerView);
                }

                if (_rootView != null && _footerView?.PlatformView != null)
                {
                    _rootView.RemoveView(_footerView.PlatformView);
                }

                if (View != null && View is ShellFlyoutLayout sfl)
                {
                    sfl.LayoutChanging -= OnFlyoutViewLayoutChanged;
                }

                _contentView?.TearDown();
                _flyoutContentView?.Dispose();
                _headerView.Dispose();
                _footerView?.TearDown();
                _rootView.Dispose();
                _defaultBackgroundColor?.Dispose();
                _bgImage?.Dispose();

                _contentView            = null;
                _flyoutHeader           = null;
                _rootView               = null;
                _headerView             = null;
                _shellContext           = null;
                _appBar                 = null;
                _flyoutContentView      = null;
                _defaultBackgroundColor = null;
                _bgImage                = null;
                _footerView             = null;
            }

            base.Dispose(disposing);
        }
示例#3
0
        protected virtual void OnViewSet(View view)
        {
            if (_shellContentView == null)
            {
                _shellContentView = new ShellViewRenderer(this.Context, view, _mauiContext);
            }
            else
            {
                _shellContentView.OnViewSet(view);
            }

            if (_shellContentView.PlatformView != null)
            {
                AddView(_shellContentView.PlatformView);
            }
        }
示例#4
0
        AView CreateFlyoutContent(ViewGroup rootView)
        {
            _rootView = rootView;
            if (_contentView != null)
            {
                var oldContentView = _contentView;
                _contentView        = null;
                oldContentView.View = null;
            }

            DisconnectRecyclerView();

            var content = ((IShellController)ShellContext.Shell).FlyoutContent;

            if (content == null)
            {
                var lp = new CoordinatorLayout.LayoutParams(CoordinatorLayout.LayoutParams.MatchParent, CoordinatorLayout.LayoutParams.MatchParent);
                lp.Behavior = new AppBarLayout.ScrollingViewBehavior();
                var context      = ShellContext.AndroidContext;
                var recyclerView = new RecyclerViewContainer(context)
                {
                    LayoutParameters = lp
                };

                recyclerView.SetAdapter(new ShellFlyoutRecyclerAdapter(ShellContext, OnElementSelected));

                return(recyclerView);
            }

            _contentView = new ShellViewRenderer(ShellContext.AndroidContext, content, MauiContext);

            _contentView.PlatformView.LayoutParameters = new CoordinatorLayout.LayoutParams(LP.MatchParent, LP.MatchParent)
            {
                Behavior = new AppBarLayout.ScrollingViewBehavior()
            };

            return(_contentView.PlatformView);
        }
示例#5
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                Disconnect();

                if (_appBar != null)
                {
                    _appBar.RemoveOnOffsetChangedListener(this);

                    if (_headerFrameLayout != null)
                    {
                        _appBar.RemoveView(_headerFrameLayout);
                    }
                }

                if (_rootView != null && _footerView != null)
                {
                    _rootView.RemoveView(_footerView);
                }

                if (View != null && View is ShellFlyoutLayout sfl)
                {
                    sfl.LayoutChanging -= OnFlyoutViewLayoutChanging;
                }

                if (_headerView != null)
                {
                    _headerView.LayoutChange -= OnHeaderViewLayoutChange;
                }

                if (_contentView != null)
                {
                    _contentView.View = null;
                }

                _flyoutContentView?.Dispose();
                _headerView?.Dispose();

                _rootView?.Dispose();
                _defaultBackgroundColor?.Dispose();
                _bgImage?.Dispose();

                _contentView            = null;
                _rootView               = null;
                _headerView             = null;
                _shellContext           = null;
                _appBar                 = null;
                _flyoutContentView      = null;
                _defaultBackgroundColor = null;
                _bgImage                = null;
                _footerView             = null;
            }

            base.Dispose(disposing);
        }