Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Still no way to turn off animation on navigating back #3054

Closed
tlhintoq opened this issue Jun 15, 2018 · 8 comments
Closed

Still no way to turn off animation on navigating back #3054

tlhintoq opened this issue Jun 15, 2018 · 8 comments
Labels
e/4 🕓 4 help wanted We welcome community contributions to any issue, but these might be a good place to start! t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@tlhintoq
Copy link

tlhintoq commented Jun 15, 2018

Description

You can turn off the navigation animation when pushing a page. Its a simple argument
Navigation.PushAsync(new MyCoolPage(), false);
But when you hit [Back] there is a still a zooming animation.

Steps to Reproduce

Navigate from page to page, then hit the back button (android) - I presume back from the navbar is the same on iOS.

Expected Behavior

If animation is set to false when you go TO a page, I would expect LEAVING that page would also be False. It just seems natural.

Actual Behavior

Animation is always on when you go [back] even if it was false when pushing the page out.

Basic Information

  • Version with issue: Xamarin.Forms 3
  • Last known good version: Its never worked as expected (or wanted in MANY forum threads)
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

@samhouts samhouts changed the title Still no way to turn of animation on navigating back Still no way to turn off animation on navigating back Jun 15, 2018
@adrianknight89
Copy link
Contributor

The fix for this could potentially be a breaking change for people who implemented a custom pop animation and expect to see it even if the push was without an animation. The likelihood is probably minimal, however.

If animation is set to false when you go TO a page, I would expect LEAVING that page would also be False

Why do you make this assumption?

- (void)pushViewController:(UIViewController *)viewController 
                  animated:(BOOL)animated;

- (UIViewController *)popViewControllerAnimated:(BOOL)animated;

I think the APIs here are pretty clear as they can be animated independently of each other.

I also needed to disable both push and pop transitions for custom design, and my workaround was creating custom NavigationPageRenderers and overriding the async navigation methods to pass a false flag to their base. This has the side effect of rendering Core animated flag useless, but at least it's handling the Back button animation.

@tlhintoq
Copy link
Author

@adrianknight89 Said:

I also needed to disable both push and pop transitions for custom design, and my workaround was creating custom NavigationPageRenderers and overriding the async navigation methods to pass a false flag to their base.

Would you mind sharing those renderers for the rest of us facing the same problem?

@adrianknight89
Copy link
Contributor

using Android.Content;
using System.Threading.Tasks;
using TestApp.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android.AppCompat;

[assembly: ExportRenderer(typeof(NavigationPage), typeof(CNavigationPageRenderer))]
namespace TestApp.Droid
{
	public class CNavigationPageRenderer : NavigationPageRenderer
	{
		public CNavigationPageRenderer(Context context) : base(context)
		{

		}

		protected override Task<bool> OnPushAsync(Page view, bool animated)
		{
			return base.OnPushAsync(view, false);
		}

		protected override Task<bool> OnPopViewAsync(Page page, bool animated)
		{
			return base.OnPopViewAsync(page, false);
		}

		protected override Task<bool> OnPopToRootAsync(Page page, bool animated)
		{
			return base.OnPopToRootAsync(page, false);
		}
	}
}

Do the same thing for other platforms. As I said, this is making the animated flag in Core useless, but at least it disables all page animations even when you use the Back button because it should call OnPopViewAsync.

You could potentially add custom logic here to scan for page types or certain set of criteria (like your custom logic [i.e. non-animated push should be coupled with a non-animated pop for that specific page]).

@samhouts samhouts added the e/4 🕓 4 label Jul 30, 2018
@IQbrod
Copy link

IQbrod commented Sep 4, 2018

@adrianknight89 Your solution doesn't work for basic content pages with a Navigation.PushModalAsync(new ContentPage())

@samhouts samhouts added the inactive Issue is older than 6 months and needs to be retested label Mar 4, 2019
@samhouts samhouts added help-wanted up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! help wanted We welcome community contributions to any issue, but these might be a good place to start! and removed help-wanted labels Jun 28, 2019
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts
Copy link
Member

This issue doesn't seem to have had any activity in a long time. We're working on prioritizing issues and resolving them as quickly as we can. To help us get through the list, we would appreciate an update from you to let us know if this is still affecting you on the latest version of Xamarin.Forms, since it's possible that we may have resolved this as part of another related or duplicate issue. If we don't see any new activity on this issue in the next 30 days, we'll evaluate whether this issue should be closed. Thank you!

@samhouts samhouts added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Sep 15, 2020
@kvpt
Copy link
Contributor

kvpt commented Sep 22, 2020

This issue is still present and relevant today.
A proposal has been made to extend the current navigation api to fix this issue #5116

@samhouts samhouts removed inactive Issue is older than 6 months and needs to be retested s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels Sep 30, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@jfversluis
Copy link
Member

Thanks for this suggestion! As Xamarin.Forms is now in maintenance mode, this will not happen anymore for Xamarin.Forms. We're only adding bugfixes and stability fixes.

If this is still important to you, make sure to check the .NET MAUI repo and see if it's already on the roadmap. If not, feel free to open a discussion to discuss a change first or open an issue with a detailed feature request. Thanks!

@jl-mobitech
Copy link

@adrianknight89 Your solution doesn't work for basic content pages with a Navigation.PushModalAsync(new ContentPage())

NavigationStack and ModalStack are two different things.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e/4 🕓 4 help wanted We welcome community contributions to any issue, but these might be a good place to start! t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
None yet
Development

No branches or pull requests

7 participants