Hello I have the following problem with latest version (1.1.4.168)
First of all I use a really simple LoadingPopupPage (PopupPage) that I show when I change page from the side menu of my app.
I use this LoadingPage only for Android, I dont need for iOS (that runs more smoothly)
On ItemSelected on side list I simple do:
await Navigation.PushPopupAsync(loadingPage);
await this.root.NavigateAsync(((MenuItem)e.SelectedItem).MenuType).ContinueWith(
task =>
Navigation.PopAsync()
// Navigation.PopAllPopupAsync(true)
// await Navigation.PopAllPopupAsync(true)
);
(I try PopPopupAsync too, and I try to call the async one, but the problem is still here)
root is my RootPage (:MasterDetailPage)
Till the previous version all working as expected, but now happen that:
protected override bool OnBackgroundClicked()
of the PopupPage
My LoadingPopupPage
<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:blabla;assembly=blabla"
x:Class="blabla.Views.LoadingPopupPage" BackgroundColor="#eeeeee" CloseWhenBackgroundIsClicked="False">
<ActivityIndicator
Color="#3885eb"
BackgroundColor="Transparent"
IsRunning="True"
IsEnabled="True"
VerticalOptions="Center"
IsInNativeLayout="true"
IsNativeStateConsistent="true"
HorizontalOptions="Center"/>
</pages:PopupPage>
...
{
public partial class LoadingPopupPage : PopupPage
{
public LoadingPopupPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
}
protected override void OnDisappearing()
{
base.OnDisappearing();
}
protected override bool OnBackgroundClicked()
{
return base.OnBackgroundClicked();
}
protected override bool OnBackButtonPressed()
{
return true;
}
}
}
Thanks
how did you understand that it is only invisible? i have similar implementation i couldnt see the popup that it is just invisible
I believe it was discovered by watching the override trigger on the popup page:
If I tap the screen is invoked:
protected override bool OnBackgroundClicked()
of the PopupPage
yes,
is invoked OnBackgroundClicked of the popup page (that should be gone)
I tried your code wiht 1.1.4.168 but i cant reproduce your problem. for me first of all it is not clear what your exact problem is. because i understand 2 things
1) although you wrote CloseWhenBackgroundIsClicked="False", OnBackgroundClicked is fired? if that is the problem yes it is fired but it doesnt close the popup. which is expected.
2) if this is not the problem but although you close the popup (removed), it is still in the visual tree, not removed from memory but just set invisible when you try to tap on an item which is on the main layout, you actually tap on popup that fires OnBackgroundClicked.
I cant reproduce 2nd one. popup is removed from the visual tree for me. And tapping on main layout never fires OnBackgroundClicked.
What confused me is that you say "LoadingPopupPage is only transparent" and your title says invisible. these 2 are totally 2 different things.
Sorry my english is not so good, I dont know if it's invisible or trasparent (in my mediocre english is the same)
When the popup is visible, I tap a row and in my ItemSelected of mypopup I do Navigation.PopAsync()
I see that the popup disappear. Ok until now
The problem: If I touch the screen OnBackgroundClicked of the popup page is called.
This ticket is really old and I remove this popup for my page..I haven't code to share :(
Had the same issue, Fixed by invoking RemovePageAsync on main thread
Device.BeginInvokeOnMainThread(() => Rg.Plugins.Popup.Services.PopupNavigation.Instance.RemovePageAsync(this));
Other popups didnt seem to need this, Only difference was this one used code behind instead of xaml
@antmurph
Device.BeginInvokeOnMainThread(() => Rg.Plugins.Popup.Services.PopupNavigation.Instance.RemovePageAsync(this));
It is not correct. You try to invoke RemovePageAsync without await operator.
I still think that there is a mistake in the code of users who get this issue because they try to invoke navigation methods without await operator or in the second thread. Anyway, I implemented a thread safety helpers to avoid this issue.
From this moment you can invoke PushAsync, PopAsync, PopAllAsync, RemovePageAsync methods in the second thread or without await operator. It is not good practice but it will not break your application now.
You can try 1.1.5.184 or newlest version in Development NuGet or just wait for when a new stable version is published on nuget.
Good luck guys.
@rotorgames this version has breaking changes for me, I am not sure if it was wrong before or now. But basically, I created a full screen activity indicator using this plugin. I push the page using
as you can see i push it without async-await, reason for that is i call it directly inside constructor
LoadingPage page = new LoadingPage(Message);
_navigation.PushPopupAsync(page);
and after doing work- i call popall function by checking if there is any popup in the stack
if (Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.Any())
{
await _navigation.PopAllPopupAsync();
}
this works fine if work in between is long running task but if task completes in a second, it doesnt work.
.PopupStack.Any() returns null. but popup is on the screen. this means that popup is pushed after check .PopupStack.Any() is called. Previous versions are working fine. Do you know the reason? I tried running function with async await but problem is the same. It seems that it has nothing to do with using async-await. I think that you can try to simply test running push and popup one after another.
my popup ui is very simple. i have only a label and activity indicator. it shouldnt take long time to render it either.
@EmilAlipiev The behavior of navigation was changed in the last version for supporting thread-safe navigation. When you invoke _navigation.PushPopupAsync(page); navigation begins not immediately and PopupStack can be empty after several milliseconds after invoking PushPopupAsync. I think if you would like to pop or remove a page you need to wait for PushPopupAsync async operation is finished.
UPD: You can do something. You can set a Task of PushPopupAsyncto a private field and when your class finishes a work the class just needs await _taksField to wait for if an animation is not finished. If the animation has been finished already then it will not take any time.
UPD2: If you would like to use await in a constructor you can create another method with async avoid signature and invoke it in the constructor.