예제 #1
0
        protected virtual void UpdateFlyoutFooter()
        {
            if (_footerView != null)
            {
                var oldFooterView = _footerView;
                _rootView.RemoveView(_footerView.NativeView);
                _footerView = null;
                oldFooterView.TearDown();
            }

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

            if (footer == null)
            {
                return;
            }

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

            _rootView.AddView(_footerView.NativeView);

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

            UpdateFooterLayout();
            UpdateContentLayout();
            UpdateContentBottomMargin();
        }
예제 #2
0
        AView CreateFlyoutContent(ViewGroup rootView)
        {
            _rootView = rootView;
            if (_contentView != null)
            {
                var oldContentView = _contentView;
                _contentView = null;
                oldContentView.TearDown();
            }

            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;
                Profile.FramePartition("Recycler.SetAdapter");
                var recyclerView = new RecyclerViewContainer(context, new ShellFlyoutRecyclerAdapter(ShellContext, OnElementSelected))
                {
                    LayoutParameters = lp
                };

                return(recyclerView);
            }

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

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

            return(_contentView.NativeView);
        }
        void UpdateFlyoutFooter()
        {
            if (_footerView != null)
            {
                var oldFooterView = _footerView;
                _rootView.RemoveView(_footerView.NativeView);
                _footerView = null;
                oldFooterView.TearDown();
            }

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

            if (footer == null)
            {
                return;
            }

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


            _footerView.NativeView.LayoutParameters = new CoordinatorLayout.LayoutParams(LP.MatchParent, LP.WrapContent)
            {
                Gravity = (int)(GravityFlags.Bottom | GravityFlags.End)
            };

            _footerView.LayoutView(_shellContext.AndroidContext.FromPixels(_rootView.LayoutParameters.Width), -1);
            _rootView.AddView(_footerView.NativeView);
        }
        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?.NativeView != null)
                {
                    _rootView.RemoveView(_footerView.NativeView);
                }

                if (_recycler != null)
                {
                    _recycler.SetLayoutManager(null);
                    _recycler.SetAdapter(null);
                    _recycler.Dispose();
                }

                _adapter?.Dispose();
                _headerView.Dispose();
                _footerView?.TearDown();
                _rootView.Dispose();
                _layoutManager?.Dispose();
                _defaultBackgroundColor?.Dispose();
                _bgImage?.Dispose();

                _flyoutHeader           = null;
                _rootView               = null;
                _headerView             = null;
                _shellContext           = null;
                _appBar                 = null;
                _recycler               = null;
                _adapter                = null;
                _defaultBackgroundColor = null;
                _layoutManager          = null;
                _bgImage                = null;
                _footerView             = null;
            }

            base.Dispose(disposing);
        }
예제 #5
0
        protected virtual void OnViewSet(View view)
        {
            if (_shellViewRenderer == null)
            {
                _shellViewRenderer = new ShellViewRenderer(this.Context, view);
            }
            else
            {
                _shellViewRenderer.OnViewSet(view);
            }

            if (_shellViewRenderer.NativeView != null)
            {
                AddView(_shellViewRenderer.NativeView);
            }
        }