public static Task PushPopupAsync(this INavigation sender, PopupPage page, bool animate = true)
 {
     return(PopupNavigation.PushAsync(page, animate));
 }
 /// <summary>
 /// This is called after the <see cref="Page.OnDisappearing"/> method to dispose the animation and any unmanaged code.
 /// </summary>
 /// <param name="content">Content.</param>
 /// <param name="page">Page.</param>
 public void Disposing(View content, PopupPage page)
 {
     //Not used
 }
Пример #3
0
 public abstract void Disposing(View content, PopupPage page);
Пример #4
0
 private async Task RemoveAsync(PopupPage page)
 {
     await PopupPlatform.RemoveAsync(page);
 }
Пример #5
0
 public static void Open(PopupPage popup)
 {
     PopupNavigation.Instance.PushAsync(popup);
 }
Пример #6
0
 public static Task RemovePageAsync(PopupPage page, bool animate = true)
 {
     return(Instance.RemovePageAsync(page, animate));
 }
        public Task RemovePageAsync(PopupPage page, bool animate = true)
        {
            _popupStack.Remove(page);

            return(Task.CompletedTask);
        }
Пример #8
0
 public static void ShowPopup(this Page page, PopupPage popup, bool animated = true)
 {
     Rg.Plugins.Popup.Services.PopupNavigation.Instance.PushAsync(popup, animated);
 }
        private async void PushPopupPage(PopupPage popupPage, View dialogView, bool animated = true)
        {
            View mask = DialogLayout.GetMask(dialogView);

            if (mask is null)
            {
                Style overlayStyle = GetOverlayStyle(dialogView);

                mask = new BoxView
                {
                    Style = overlayStyle
                };
            }

            mask.SetBinding(VisualElement.WidthRequestProperty, new Binding {
                Path = "Width", Source = popupPage
            });
            mask.SetBinding(VisualElement.HeightRequestProperty, new Binding {
                Path = "Height", Source = popupPage
            });

            var overlay       = new AbsoluteLayout();
            var relativeWidth = DialogLayout.GetRelativeWidthRequest(dialogView);

            if (relativeWidth != null)
            {
                dialogView.SetBinding(View.WidthRequestProperty,
                                      new Binding("Width",
                                                  BindingMode.OneWay,
                                                  new RelativeContentSizeConverter {
                    RelativeSize = relativeWidth.Value
                },
                                                  source: popupPage));
            }

            var relativeHeight = DialogLayout.GetRelativeHeightRequest(dialogView);

            if (relativeHeight != null)
            {
                dialogView.SetBinding(View.HeightRequestProperty,
                                      new Binding("Height",
                                                  BindingMode.OneWay,
                                                  new RelativeContentSizeConverter {
                    RelativeSize = relativeHeight.Value
                },
                                                  source: popupPage));
            }

            //AbsoluteLayout.SetLayoutFlags(content, AbsoluteLayoutFlags.PositionProportional);
            //AbsoluteLayout.SetLayoutBounds(content, new Rectangle(0f, 0f, popupPage.Width, popupPage.Height));
            AbsoluteLayout.SetLayoutFlags(dialogView, AbsoluteLayoutFlags.PositionProportional);
            var popupBounds = DialogLayout.GetLayoutBounds(dialogView);

            AbsoluteLayout.SetLayoutBounds(dialogView, popupBounds);
            //overlay.Children.Add(content);
            if (DialogLayout.GetUseMask(dialogView) ?? true)
            {
                overlay.Children.Add(mask);
            }

            overlay.Children.Add(dialogView);
            popupPage.Content = overlay;
            await _popupNavigation.PushAsync(popupPage, animated);
        }
Пример #10
0
        private static async Task OpenPopup(PopupPage popupPage)
        {
            await ClosePopup();

            await PopupNavigation.Instance.PushAsync(popupPage);
        }
Пример #11
0
 private async void CurMusic_Tapped(object sender, EventArgs e)
 {
     PopupPage page = (PopupPage)Activator.CreateInstance(new CurMusic().GetType());
     await PopupNavigation.Instance.PushAsync(new CurMusic());
 }
Пример #12
0
 public async Task PushPopupAsync(PopupPage page, bool animate)
 {
     await _lazyNavigation.Value.PushPopupAsync(page, animate);
 }
Пример #13
0
 public async Task Appearing(View content, PopupPage page)
 {
     // Show animation
     await content.FadeTo(0.5);
 }
Пример #14
0
        public Task RemovePageAsync(PopupPage page, bool animate = true)
        {
            lock (_locker)
            {
                if (page == null)
                {
                    throw new NullReferenceException("Page can not be null");
                }

                if (!_popupStack.Contains(page))
                {
                    throw new InvalidOperationException("The page has not been pushed yet or has been removed already");
                }

                if (page.DisappearingTransactionTask != null)
                {
                    return(page.DisappearingTransactionTask);
                }

                var task = InvokeThreadSafe(async() =>
                {
                    if (page.AppearingTransactionTask != null)
                    {
                        await page.AppearingTransactionTask;
                    }

                    lock (_locker)
                    {
                        if (!_popupStack.Contains(page))
                        {
                            return;
                        }
                    }

                    Popping?.Invoke(this, new PopupNavigationEventArgs(page, animate));

                    animate = CanBeAnimated(animate);

                    if (animate)
                    {
                        await page.DisappearingAnimation();
                    }

                    await RemoveAsync(page);

                    if (animate)
                    {
                        page.DisposingAnimation();
                    }

                    lock (_locker)
                    {
                        _popupStack.Remove(page);
                        page.DisappearingTransactionTask = null;

                        Popped?.Invoke(this, new PopupNavigationEventArgs(page, animate));
                    }
                });

                page.DisappearingTransactionTask = task;

                return(task);
            }
        }
Пример #15
0
        public async Task PushPopupAsync(string popUpPageKey, object parameter, bool animate = false, CancellationToken cancelToken = default)
        {
            await SemaphoreSlim.WaitAsync();

            await Device.InvokeOnMainThreadAsync(async() =>
            {
                try
                {
                    Debug.WriteLine($"PushPopupAsync(popUpPageKey={popUpPageKey}, param1={parameter}, animate={animate})");
                    // Make sure only one modal opens when a navigation button is clicked multiple times
                    if (_popUp != null)
                    {
                        return;
                    }

                    if (Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.Count > 0)
                    {
                        var popupPageType       = Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.Last().GetType();
                        var currentPopupPageKey = _pagesByKey.First(p => p.Value == popupPageType).Key;
                        if (currentPopupPageKey == popUpPageKey)
                        {
                            return;
                        }
                    }

                    if (_pagesByKey.ContainsKey(popUpPageKey))
                    {
                        var type = _pagesByKey[popUpPageKey];
                        ConstructorInfo constructor;
                        object[] parameters;

                        if (parameter == null)
                        {
                            constructor = type.GetTypeInfo()
                                          .DeclaredConstructors
                                          .FirstOrDefault(c => !c.GetParameters().Any());

                            parameters = new object[]
                            {
                            };
                        }
                        else
                        {
                            constructor = type.GetTypeInfo()
                                          .DeclaredConstructors
                                          .FirstOrDefault(
                                c =>
                            {
                                var p = c.GetParameters();
                                return(p.Count() == 1 &&
                                       p[0].ParameterType == parameter.GetType());
                            });

                            parameters = new[]
                            {
                                parameter
                            };
                        }

                        if (constructor == null)
                        {
                            throw new InvalidOperationException(
                                "No suitable constructor found for popup page " + popUpPageKey);
                        }

                        _popUp = constructor.Invoke(parameters) as Rg.Plugins.Popup.Pages.PopupPage;

                        if (_popUp == null)
                        {
                            return;
                        }

                        // This fixes the issue where the popup will not reopen if clicked outside
                        if (_popUp.CloseWhenBackgroundIsClicked)
                        {
                            _popUp.BackgroundClicked += async(s, o) =>
                            {
                                await RemovePopupAsync(animate, _popUp);
                                _popUp      = null;
                                CurrentPage = new CustomPage(_navigation.CurrentPage, Data.Models.Enums.ePageType.PushPopup);
                            };
                        }

                        cancelToken.Register(async() =>
                        {
                            await RemovePopupAsync(animate, _popUp);
                            _popUp      = null;
                            CurrentPage = new CustomPage(_navigation.CurrentPage, Data.Models.Enums.ePageType.PushPopup);
                        });

                        await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PushAsync(_popUp, animate);
                        CurrentPage = new CustomPage(_popUp);
                    }
                    else
                    {
                        throw new ArgumentException(
                            $"No such popup page: {popUpPageKey}. Did you forget to call NavigationService.Configure?",
                            nameof(popUpPageKey));
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    throw;
                }
                finally
                {
                    SemaphoreSlim.Release();
                }
            });
        }
Пример #16
0
 public async Task Disappearing(View content, PopupPage page)
 {
     await content.FadeTo(0);
 }
Пример #17
0
 public static Task PushAsync(PopupPage page, bool animate = true)
 {
     return(Instance.PushAsync(page, animate));
 }
Пример #18
0
 private static async Task PushPopupPageModel(PopupPage page, bool animate = true)
 {
     await PopupNavigation.Instance.PushAsync(page, animate);
 }
        public Task PushAsync(PopupPage page, bool animate = true)
        {
            _popupStack.Add(page);

            return(Task.CompletedTask);
        }
Пример #20
0
 // Call Before OnAppering
 public void Preparing(Xamarin.Forms.View content, PopupPage page)
 {
     // Preparing content and page
     content.Opacity = 0;
 }
Пример #21
0
        // Private

        private async Task AddAsync(PopupPage page)
        {
            await PopupPlatform.AddAsync(page);
        }
Пример #22
0
 // Call After OnDisappering
 public void Disposing(Xamarin.Forms.View content, PopupPage page)
 {
     // Dispose Unmanaged Code
 }
 public void RemovePopup(PopupPage page)
 {
     _decoreView.RemoveView(page.GetOrCreateRenderer().ViewGroup);
     UpdateListeners(false);
 }
Пример #24
0
 // Call Before OnDisappering
 public async Task Disappearing(Xamarin.Forms.View content, PopupPage page)
 {
     // Hide animation
     await content.FadeTo(0);
 }
 /// <summary>
 /// This is called before the <see cref="Page.OnAppearing"/> method to prepare the content and page for the animated banner view.
 /// </summary>
 /// <param name="content">Content.</param>
 /// <param name="page">Page.</param>
 public void Preparing(View content, PopupPage page)
 {
     content.Opacity = 0;
 }
Пример #26
0
 private static void HandleINavigatingAware(PopupPage page, NavigationParameters parameters)
 {
     //TODO: This will need to be updated to INavigatingAware once Pre2 is released
     (page as INavigationAware)?.OnNavigatingTo(parameters);
     (page?.BindingContext as INavigationAware)?.OnNavigatingTo(parameters);
 }
Пример #27
0
 public abstract void Preparing(View content, PopupPage page);
        // Internal

        internal void RemovePopupFromStack(PopupPage page)
        {
            _popupStack.Remove(page);
        }
Пример #29
0
 public abstract Task Appearing(View content, PopupPage page);
Пример #30
0
 public static Task RemovePopupPageAsync(this INavigation sender, PopupPage page, bool animate = true)
 {
     return(PopupNavigation.RemovePageAsync(page, animate));
 }