PopModalAsync() public static method

Asynchronously dismisses the most recent modally presented T:Xamarin.Forms.Page.
public static PopModalAsync ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 private static async Task CloseModalAsync()
 {
     if (Application.Current.GetActivePage() is ContentPage currentPage)
     {
         if (currentPage.Content is PopupLayout popupLayout && popupLayout.IsPopupActive)
         {
             await popupLayout.DismissPopupAsync();
         }
         else
         {
             await NavigationHelper.PopModalAsync();
         }
     }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private static async Task CloseModalAsync()
        {
            var currentPage = Application.Current.CurrentPage() as ContentPage;

            if (currentPage != null)
            {
                var popupLayout = currentPage.Content as PopupLayout;
                if (popupLayout != null && popupLayout.IsPopupActive)
                {
                    await popupLayout.DismissPopupAsync();
                }
                else
                {
                    await NavigationHelper.PopModalAsync();
                }
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OnBackButtonPressed(object sender, EventArgs e)
        {
            var contentPage = sender as ContentPage;

            if (contentPage != null)
            {
                var popupLayout = contentPage.Content as PopupLayout;
                if (popupLayout != null && popupLayout.IsPopupActive)
                {
                    _callbacks[contentPage]?.Item2?.SafeInvoke(this, new UICompletedEventArgs(_callbacks[contentPage].Item1, null));
                    await popupLayout.DismissPopup();
                }

                if (popupLayout == null)
                {
                    _callbacks[contentPage]?.Item2?.SafeInvoke(this, new UICompletedEventArgs(_callbacks[contentPage].Item1, null));
                    await NavigationHelper.PopModalAsync();
                }

                contentPage.BackButtonPressed -= OnBackButtonPressed;
            }
        }