/// <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(); } }
/// <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(); } } }
/// <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; } }