Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Navigate to page after animation

52 views
Skip to first unread message

Sana Rajput

unread,
Dec 5, 2018, 2:37:25 AM12/5/18
to
I am trying to make a simple effect where I have an overlay that fades in before pushing a new page for display. I am using a simple FadeTo animation, and I am supplying code for navigation using the returned task's ContinueWith method. I can see that the code gets run, but that the page is not changed. I suspect it may have something to do with threading and the UI, but I am not particularly familiar with how that all works. I created a FadeOverlay class that inherits from BoxView, and I use the following method:

/// <summary>
/// Fades to black and then pushes a new page for display
/// </summary>
/// <param name="page">Page to fade to</param>
/// <param name="removePage">Supply current page if you wish to replace it in stack (for onboarding) </param>
public void FadeToPage(Page page, Page removePage = null)
{
this.FadeTo(1, (uint) FadeTime).ContinueWith(x =>
{
if (removePage != null)
{
Debug.WriteLine("This gets called");
Navigation.InsertPageBefore(new NoAdsPage(), removePage);
Navigation.PopAsync(false);
Debug.WriteLine("This also gets called");
}
else
{
Navigation.PushAsync(page);
}
});
}
Can anyone explain why the page is not being pushed? What is an alternative to achieving the same effect? I tried the same thing using timers, but with no luck

akshita...@gmail.com

unread,
Dec 11, 2018, 1:48:23 AM12/11/18
to
Hi Sana,

By the way, here is the output log:

[0:] This gets called
01-20 12:06:23.326 D/Mono ( 3594): DllImport searching in: '__Internal' ('(null)').
01-20 12:06:23.326 D/Mono ( 3594): Searching for 'java_interop_jnienv_call_boolean_method'.
01-20 12:06:23.326 D/Mono ( 3594): Probing 'java_interop_jnienv_call_boolean_method'.
01-20 12:06:23.326 D/Mono ( 3594): Found as 'java_interop_jnienv_call_boolean_method'.
[0:] This also gets called

I don't know if that helps anyone, it does not really help me. I am not sure what to make of it

EDIT: I fixed the issue by rewriting the code like this:

public async Task FadeToPage(Page page, Page removePage = null)
{
await this.FadeTo(1, (uint) FadeTime);

if (removePage != null)
{
Navigation.InsertPageBefore(page, removePage);
await Navigation.PopAsync(false);
}
else
{
await Navigation.PushAsync(page);
}
}
Works like a charm. Cheers! If you still need help regarding Xamarin Migration Services feel free to contact me: https://goo.gl/wwRkXR
0 new messages