Exemplo n.º 1
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            if (formsWrapper != null)
            {
                formsWrapper.Renderer.UpdateLayout();
                ViewGroup.BringChildToFront(formsWrapper);
            }
        }
Exemplo n.º 2
0
        private void moveToBack(View myCurrentView)
        {
            ViewGroup myViewGroup = ((ViewGroup)myCurrentView.Parent);
            int       index       = myViewGroup.IndexOfChild(myCurrentView);

            for (int i = 0; i < index; i++)
            {
                myViewGroup.BringChildToFront(myViewGroup.GetChildAt(i));
            }
        }
Exemplo n.º 3
0
        void AddMenu()
        {
            if (_basePage == null)
            {
                return;
            }
            var menu = _basePage.SlideMenu;

            if (menu == null)
            {
                return;
            }

            _basePage.HideMenuAction = () =>
            {
                if (_dialogDrawer == null)
                {
                    return;
                }
                var r = _dialogDrawer.GetHidePosition();
                formsWrapper.Animate()
                .X((float)r.left)
                .Y((float)r.top)
                .SetDuration(menu.AnimationDurationMillisecond)
                .SetListener(new AnimatorListener(_dialogDrawer, false, _basePage))
                .Start();
            };

            _basePage.ShowMenuAction = () =>
            {
                if (_dialogDrawer == null)
                {
                    return;
                }
                var r = _dialogDrawer.GetShowPosition();
                formsWrapper.Animate()
                .X((float)r.left)
                .Y((float)r.top)
                .SetDuration(menu.AnimationDurationMillisecond)
                .SetListener(new AnimatorListener(_dialogDrawer, true, _basePage))
                .Start();
            };

            if (formsWrapper != null)
            {
                formsWrapper.RemoveFromParent();
            }

            formsWrapper = new FormsElementWrapper(Context, menu, this.Element);
            formsWrapper.SetBackgroundResource(Resource.Drawable.dialogBorder);
            formsWrapper.Renderer.View.SetBackgroundResource(Resource.Drawable.dialogBorder);

            var metrics  = Resources.DisplayMetrics;
            var rootView = formsWrapper;


            _dialogDrawer = (formsWrapper.Renderer as SlideMenuDroidRenderer).GragGesture;

            if (_dialogDrawer == null)
            {
                return;
            }
            var rect = _dialogDrawer.GetHidePosition();

            menu.Layout(new Xamarin.Forms.Rectangle(
                            rect.left / metrics.Density,
                            rect.top / metrics.Density,
                            (rect.right - rect.left) / metrics.Density,
                            (rect.bottom - rect.top) / metrics.Density));

            rootView.Layout((int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom);
            ViewGroup.AddView(rootView);
            ViewGroup.BringChildToFront(rootView);

            _dialogDrawer.NeedShowBackgroundView = (open, alpha) =>
            {
                if (open)
                {
                    ShowBackgroundOverlay(alpha);
                }
                else
                {
                    HideBackgroundOverlay();
                }
            };
        }