Open SuriGabi opened 2 years ago
I had the same problem showing a popup and then calling a Task.Delay
, if the user clicks to dismiss the popup before the delay finished, the popup gets removed from the stack for some reason I don't understand.
I solved by checking the stack first, since I have only 1 popup at the time:
if(PopupNavigation.Instance.PopupStack.Any())
{
await PopupNavigation.Instance.PopAsync();
}
HI LuckyDucko,
The problem still persists with the new version! (Tested on android platform all versions) I have created a new project and I am using Rg.Plugins.Popup 2.1.0.
If you use the sample code (see below) you can easily get the following error: Rg.Plugins.Popup.Exceptions.RGPopupStackInvalidException: 'The page has not been pushed yet or has been removed already' Version 1.1.5.188 did not have this error.
It this a sample:
MainActivity inserted line: Rg.Plugins.Popup.Popup.Init(this);
Make new PopupPage view: (XAML)
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup" xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup" x:Class="SCL.Dialogs.MessageBar" BackgroundColor="Transparent" InputTransparent="False" BackgroundInputTransparent="True" HasSystemPadding="False" CloseWhenBackgroundIsClicked="True"> pages:PopupPage.Animation
</pages:PopupPage.Animation>
</pages:PopupPage>
(CS) using System; using System.Threading.Tasks;
using Xamarin.Forms;
using Rg.Plugins.Popup.Pages; using Rg.Plugins.Popup.Services;
namespace SCL.Dialogs { public partial class MessageBar : PopupPage { public MessageBar(string title, Color color) { InitializeComponent();
} }
And create mainview add button with clicked event private async void Button_Clicked(object sender, EventArgs e) { await PopupNavigation.Instance.PushAsync(new MessageBar("POPUP!!! Please click repeatedly and crash!!!", Color.Red)); }
Please click the button repeatedly and quickly. After 10-15 clicks you will get the crash
Thanks for yout help! Have nice day!