Exemple #1
0
        public void ShowPopup(PopupExtended popup)
        {
            try
            {
                if (CurrentPopup != null)
                {
                    return;
                }

                if (popup.IsVisible == false)
                {
                    CurrentPopup = popup;
                    BackgroundLayout.BackgroundColor = popup.BackgroundLayerColor;



                    PopupControls.Add(popup.Content);



                    PopupContentLayout = popup.Content;

                    popup.Content = null;
                    grid.Children.Add(PopupControls[0]);



                    if (popup.CloseOnBackGroundClicked)
                    {
                        TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer();
                        tapGestureRecognizer.Tapped += TapGestureRecognizer_Tapped;

                        boxView.GestureRecognizers.Add(tapGestureRecognizer);
                    }



                    popup.IsVisible            = true;
                    BackgroundLayout.IsVisible = true;
                    ShowEnterAnimation();

                    CurrentPopup.IsOpen = true;
                }
            }
            catch (Exception ex)
            {
                RootPage.DisplayAlert("Exception", ex.Message, "OK");
            }
        }
Exemple #2
0
        private Task <bool> ShowExitAnimation()
        {
            Task <bool> task = null;

            switch (CurrentPopup.ExitAnimation)
            {
            case AnimationEnum.SlideLeft:
                task = PopupContentLayout.TranslateTo(0 - PopupContentLayout.Width, 0);
                break;

            case AnimationEnum.SlideRight:

                task = PopupContentLayout.TranslateTo(PopupContentLayout.Width, 0);
                break;

            case AnimationEnum.SlideUp:
                task = PopupContentLayout.TranslateTo(0, 0 - PopupContentLayout.Height);
                break;

            case AnimationEnum.SlideDown:
                task = PopupContentLayout.TranslateTo(0, PopupContentLayout.Height);
                break;
            }

            task.ContinueWith(b =>
            {
                BackgroundLayout.IsVisible = false;
                CurrentPopup.IsVisible     = false;
                CurrentPopup.IsOpen        = false;


                BackgroundLayout.Children.Remove(PopupControls[0]);
                CurrentPopup.Content = PopupControls[0];


                PopupControls.Clear();

                CurrentPopup       = null;
                PopupContentLayout = null;
            }, TaskScheduler.FromCurrentSynchronizationContext());

            return(task);
        }
Exemple #3
0
        public async Task ClosePopup(PopupExtended popup)
        {
            try
            {
                if (CurrentPopup == null)
                {
                    return;
                }

                if (CurrentPopup.ExitAnimation != AnimationEnum.None)
                {
                    await ShowExitAnimation();
                }
            }
            catch (Exception ex)
            {
                await RootPage.DisplayAlert("Exception", ex.Message, "OK");
            }
        }