public void PopAsync <TPopupType>() where TPopupType : PopupPage, new() { lock (s_threadPadlock) { var PotentialPages = s_popupNavigation.PopupStack.Where((PopupPage PageOnPopupStack) => PageOnPopupStack.GetType().IsEquivalentTo(typeof(TPopupType))); if (PotentialPages.Any()) { s_popupNavigation.RemovePageAsync(PotentialPages.First()).SafeFireAndForget(onException: (Exception ex) => Console.WriteLine(ex)); } } }
public static async Task RemovePopupPageAsyncSafe(this INavigation sender, PopupPage page, IPopupNavigation popupNavigation, bool animate = true) { if (Device.RuntimePlatform == "Test") { return; } await popupNavigation.RemovePageAsync(page, animate); }
public void PopAsync() { lock (s_threadPadlock) { if (TopPopupPage != null) { s_popupNavigation.RemovePageAsync(TopPopupPage).SafeFireAndForget(); } } }
/// <inheritdoc/> public IObservable<Unit> RemovePopup(IViewModel viewModel, string? contract = null, bool animate = true) { if (viewModel is null) { throw new ArgumentNullException(nameof(viewModel)); } PopupPage popupPage = LocatePopupFor(viewModel, contract); return Observable.FromAsync(() => _popupNavigation.RemovePageAsync(popupPage, animate)) .Do(_ => RemoveFromStackAndTick(PopupSubject, viewModel)); }
public void PopAsync() { lock (s_threadPadlock) { if (TopPopupPage != null) { s_popupNavigation.RemovePageAsync(TopPopupPage).SafeFireAndForget(); } else { Console.WriteLine("here"); } } }
public async Task ExecuteAndWait(Action action, View view) { var popup = new PopupPage() { CloseWhenBackgroundIsClicked = false, Content = view, BackgroundColor = Color.Transparent, IsBusy = true, }; IPopupNavigation ipn = PopupNavigation.Instance; await ipn.PushAsync(popup); action.Invoke(); await ipn.RemovePageAsync(popup); }
public async Task <Piece> ShowPawnReplacementPopup(List <Piece> availableReplacements) { // This allows us to wait until the user closes the popup var resultAwaiter = new TaskCompletionSource <Piece>(); var pawnReplacementPopupPage = new PawnReplacementPopupPage { Pieces = availableReplacements }; pawnReplacementPopupPage.ConfirmSelectionCommand = new DelegateCommand <Piece>((chosenPiece) => { resultAwaiter.SetResult(chosenPiece); Device.BeginInvokeOnMainThread(async() => await _popupNavigation.RemovePageAsync(pawnReplacementPopupPage)); }); Device.BeginInvokeOnMainThread(async() => await _popupNavigation.PushAsync(pawnReplacementPopupPage)); return(await resultAwaiter.Task); }
/// <summary> /// Handle popup page Navigation /// </summary> /// <typeparam name="T"></typeparam> /// <param name="popup"></param> /// <returns></returns> private async Task <T> Navigate <T>(CustomGeneralPopupView <T> popup) { if (Device.RuntimePlatform == "Test") { return(default(T)); } ThreadingHelpers.InvokeOnMainThread(async() => { await _popupNavigation.PushAsync(popup); }); // await for the user to enter the text input var result = await popup.PageClosingTask; // Pop the page from Navigation Stack ThreadingHelpers.InvokeOnMainThread(async() => { try { await _popupNavigation.RemovePageAsync(popup); } catch { try { await _popupNavigation.PopAsync(); } catch { } } }); return(result); }