示例#1
0
 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));
         }
     }
 }
示例#2
0
 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);
 }
示例#3
0
 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));
        }
示例#5
0
 public void PopAsync()
 {
     lock (s_threadPadlock)
     {
         if (TopPopupPage != null)
         {
             s_popupNavigation.RemovePageAsync(TopPopupPage).SafeFireAndForget();
         }
         else
         {
             Console.WriteLine("here");
         }
     }
 }
示例#6
0
        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);
        }
示例#7
0
        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);
        }