Example #1
0
        protected virtual void AttachFlyout(IShellContext context, AView content)
        {
            Profile.FrameBegin();

            _content = content;

            _flyoutContent = context.CreateShellFlyoutContentRenderer();

            _flyoutWidth = 1;

            _flyoutContent.AndroidView.LayoutParameters =
                new LayoutParams(1, LP.MatchParent)
            {
                Gravity = (int)GravityFlags.Start
            };

            AddView(content);

            AddView(_flyoutContent.AndroidView);

            AddDrawerListener(this);

            ((IShellController)context.Shell).AddFlyoutBehaviorObserver(this);

            Profile.FrameEnd();
        }
        protected virtual void AttachFlyout(IShellContext context, AView content)
        {
            _content = content;

            _flyoutContent = context.CreateShellFlyoutContentRenderer();

            // Depending on what you read the right edge of the drawer should be Max(56dp, actionBarSize)
            // from the right edge of the screen. Fine. Well except that doesn't account
            // for landscape devices, in which case its still, according to design
            // documents from google 56dp, except google doesn't do that with their own apps.
            // So we are just going to go ahead and do what google does here even though
            // this isn't what DrawerLayout does by default.

            // Oh then there is this rule about how wide it should be at most. It should not
            // at least according to docs be more than 6 * actionBarSize wide. Again non of
            // this is about landscape devices and google does not perfectly follow these
            // rules... so we'll kind of just... do our best.

            var metrics = Context.Resources.DisplayMetrics;
            var width   = Math.Min(metrics.WidthPixels, metrics.HeightPixels);

            var actionBarHeight = (int)Context.ToPixels(56);

            using (var tv = new TypedValue())
            {
                if (Context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true))
                {
                    actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics);
                }
            }

            width -= actionBarHeight;

            var maxWidth = actionBarHeight * 6;

            width = Math.Min(width, maxWidth);

            _flyoutWidth = width;

            _flyoutContent.AndroidView.LayoutParameters =
                new LayoutParams(width, LP.MatchParent)
            {
                Gravity = (int)GravityFlags.Start
            };

            AddView(content);
            AddView(_flyoutContent.AndroidView);

            AddDrawerListener(this);

            ((IShellController)context.Shell).AddFlyoutBehaviorObserver(this);
        }
Example #3
0
        void AddFlyoutContentToLayoutIfNeeded(FlyoutBehavior behavior)
        {
            if (behavior == FlyoutBehavior.Disabled)
            {
                return;
            }

            if (_flyoutContent == null && ChildCount > 0)
            {
                _flyoutContent = _shellContext.CreateShellFlyoutContentRenderer();

                UpdateFlyoutSize();

                AddView(_flyoutContent.AndroidView);
            }
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                if (!_disposed)
                {
                    _disposed = true;
                    FlyoutContent.WillAppear    -= OnFlyoutContentWillAppear;
                    FlyoutContent.WillDisappear -= OnFlyoutContentWillDisappear;
                    ((IShellController)_context.Shell).RemoveFlyoutBehaviorObserver(this);
                }

                FlyoutContent = null;
                _content      = null;
                _context      = null;
            }
        }