Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hiding original hero after hero transition #37341

Merged
merged 1 commit into from Aug 9, 2019

Conversation

@chunhtai
Copy link
Contributor

commented Jul 31, 2019

Description

If you transition for route 1 to route2, the hero in route1 is hidden during the transition and reappear after transition end. This is generally ok when route2 is not transparent, but looks weird when it is transparent.

before

after this pr it will hide the original hero

after

Related Issues

#10667

Tests

I added the following tests:

"Heroes animate should hide original hero"

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@googlebot googlebot added the cla: yes label Jul 31, 2019

@chunhtai chunhtai requested a review from goderbauer Jul 31, 2019

@chunhtai

This comment has been minimized.

Copy link
Contributor Author

commented Jul 31, 2019

cc @Piinks

@@ -360,13 +368,13 @@ class _HeroState extends State<Hero> {
'A Hero widget cannot be the descendant of another Hero widget.'
);

final bool isHeroInFlight = _placeholderSize != null;
final bool placeheld = _placeholderSize != null;

This comment has been minimized.

Copy link
@Piinks

Piinks Aug 1, 2019

Contributor

Why change the name here? 'placeheld' seems a bit more ambiguous to understanding that the hero is currently flying.

This comment has been minimized.

Copy link
@chunhtai

chunhtai Aug 1, 2019

Author Contributor

This pr make it so after hero transition finishes, the hero widget in the original route will still be hidden. The placeheld (or isHeroInFlight previously) is controlling whether to hide the hero. After this change, we want to hide hero even if it is not in flight. I feel the name become confusing, and that is why i renamed it. I am open to any name suggestion tho

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Maybe a better name would be: showPlaceholder?


manifest.fromHero.endFlight();
manifest.toHero.endFlight();
// There can only be one hero. The one on top should survive.

This comment has been minimized.

Copy link
@Piinks

Piinks Aug 1, 2019

Contributor

Can you elaborate further about what this means?

This comment has been minimized.

Copy link
@chunhtai

chunhtai Aug 1, 2019

Author Contributor

one of the hero should be hidden after the flight, when AnimationStatus.completed toHero will be the one on top, if AnimationStatus.dismissed, it means it starts transition but got canceled, so the fromHero will be the one on top

This comment has been minimized.

Copy link
@chunhtai

chunhtai Aug 1, 2019

Author Contributor

I will update the comment

@goderbauer
Copy link
Member

left a comment

I am not sure if anybody depends on those heroes becoming visible again, but for those people, this will be a nasty breaking change. Nasty, because their app will just compile fine and run without exceptions. It'll be hard for them to notice that something is broken. Again, I can't think of any reason for anybody to depend on the fact that the heroes in the route below become visible again, but if we want to do this as a breaking change, we should collect feedback by sending out a breaking change proposal and giving people some time to respond. The breaking change should also be clearly stated in the PR description.

We could also make this a non-breaking change by just having it as a config option on the hero and defaulting it to the current behavior.

if (!isUserGestureTransition || heroWidget.transitionOnUserGestures) {
result[tag] = heroState;
} else {
// If transition is not allowed, we reset hero.

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Not sure what this comment means?

});
}

void endFlight({ bool placeheld = false }) {

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Add documentation what placeheld means?

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Maybe the parameter should be named: keepPlaceholder.

setState(() {
_placeholderSize = null;
});
void reset() {

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Can this get a more descriptive name? Maybe "ensurePlaceholderIsHidden"?

@@ -360,13 +368,13 @@ class _HeroState extends State<Hero> {
'A Hero widget cannot be the descendant of another Hero widget.'
);

final bool isHeroInFlight = _placeholderSize != null;
final bool placeheld = _placeholderSize != null;

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Maybe a better name would be: showPlaceholder?


manifest.fromHero.endFlight();
manifest.toHero.endFlight();
// We want to hide the hero underneath the current page. If

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Do you have tests for both of these cases?

manifest.fromHero.endFlight();
manifest.toHero.endFlight();
// We want to hide the hero underneath the current page. If
// [AnimationStatus.completed], toHero will be the one on top and we hide

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

hide? fromHero is already hidden and we just keep it hidden, no?

// We want to hide the hero underneath the current page. If
// [AnimationStatus.completed], toHero will be the one on top and we hide
// fromHero. If [AnimationStatus.dismissed], the animation is triggered
// but canceled before it finishes. In this case, we hide toHero instead.

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

same here?

if (manifest.fromHero != newManifest.toHero) {
manifest.fromHero.endFlight();
// Aborted animation should be placeheld.

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Do you have a test for this case?

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Also: why's the from hero placeheld?

This comment has been minimized.

Copy link
@chunhtai

chunhtai Aug 2, 2019

Author Contributor

I don't think this will matter because the old heros are disposed, and it will not be testable because the elements are gone. I modify this just to be extra safe

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 5, 2019

Member

If it doesn't matter, I'd remove the comment. The comment makes it sound like that this is super-important.

@@ -630,8 +640,9 @@ class _HeroFlight {
else
_proxyAnimation.parent = newManifest.animation;

manifest.fromHero.endFlight();
manifest.toHero.endFlight();
// Aborted animations should be placeheld.

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Tests for this code path?

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 2, 2019

Member

Again, why do we hide them in this case?

@chunhtai

This comment has been minimized.

Copy link
Contributor Author

commented Aug 2, 2019

I am not sure if anybody depends on those heroes becoming visible again, but for those people, this will be a nasty breaking change. Nasty, because their app will just compile fine and run without exceptions. It'll be hard for them to notice that something is broken. Again, I can't think of any reason for anybody to depend on the fact that the heroes in the route below become visible again, but if we want to do this as a breaking change, we should collect feedback by sending out a breaking change proposal and giving people some time to respond. The breaking change should also be clearly stated in the PR description.

We could also make this a non-breaking change by just having it as a config option on the hero and defaulting it to the current behavior.

I am struggle on whether to keep the original behavior. I think if we want to provide options, they will be either the fromHero is always displayed or the always hidden. The current behavior is just weird and ugly.

@chunhtai chunhtai force-pushed the chunhtai:issues/10667 branch from 7b9c6a2 to 6a04a14 Aug 2, 2019

});
}

// The 'keepPlaceholder' flag dictates if the hero should keep the placeholder after

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 5, 2019

Member
Suggested change
// The 'keepPlaceholder' flag dictates if the hero should keep the placeholder after
// When `keepPlaceholder` is true, the placeholder will continue to be shown after the flight ends.
if (manifest.fromHero != newManifest.toHero) {
manifest.fromHero.endFlight();
// Aborted animation should be placeheld.

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 5, 2019

Member

If it doesn't matter, I'd remove the comment. The comment makes it sound like that this is super-important.

@goderbauer

This comment has been minimized.

Copy link
Member

commented Aug 5, 2019

I am struggle on whether to keep the original behavior.

You can collect feedback for this by sending out a proposal for this breaking change and we can add options if people depend on this.

@chunhtai chunhtai force-pushed the chunhtai:issues/10667 branch 2 times, most recently from 25d50d8 to 626a6b3 Aug 5, 2019

@goderbauer
Copy link
Member

left a comment

LGTM

_placeholderSize = null;
});
void ensurePlaceholderIsHidden() {
setState(() {

This comment has been minimized.

Copy link
@goderbauer

goderbauer Aug 7, 2019

Member

This should probably be guarded by if (mounted) and the if mounted should be removed from endFlight?

@chunhtai chunhtai force-pushed the chunhtai:issues/10667 branch from 626a6b3 to 2c1f00e Aug 8, 2019

@chunhtai chunhtai merged commit 35532e0 into flutter:master Aug 9, 2019

78 of 79 checks passed

tool_coverage-linux Task Summary
Details
WIP Ready for review
Details
add2app-macos Task Summary
Details
add2app-macos
Details
analyze Task Summary
Details
analyze
Details
build_tests-linux Task Summary
Details
build_tests-linux
Details
build_tests-macos Task Summary
Details
build_tests-macos
Details
build_tests-windows Task Summary
Details
build_tests-windows
Details
cla/google All necessary CLAs are signed
customer_testing-linux Task Summary
Details
customer_testing-linux
Details
customer_testing-macos Task Summary
Details
customer_testing-macos
Details
customer_testing-windows Task Summary
Details
customer_testing-windows
Details
deploy_gallery Task Summary
Details
deploy_gallery
Details
deploy_gallery-macos Task Summary
Details
deploy_gallery-macos
Details
docs Task Summary
Details
docs
Details
flutter-build
Details
integration_tests-linux Task Summary
Details
integration_tests-linux
Details
integration_tests-macos Task Summary
Details
integration_tests-macos
Details
integration_tests-windows Task Summary
Details
integration_tests-windows
Details
integration_tests_gradle1-linux Task Summary
Details
integration_tests_gradle1-linux
Details
integration_tests_gradle1-windows Task Summary
Details
integration_tests_gradle1-windows
Details
integration_tests_gradle2-linux Task Summary
Details
integration_tests_gradle2-linux
Details
integration_tests_gradle2-windows Task Summary
Details
integration_tests_gradle2-windows
Details
release_smoke_tests Task Summary
Details
release_smoke_tests
Details
tests_extras-linux Task Summary
Details
tests_extras-linux
Details
tests_extras-macos Task Summary
Details
tests_extras-macos
Details
tests_extras-windows Task Summary
Details
tests_extras-windows
Details
tests_framework_other-linux Task Summary
Details
tests_framework_other-linux
Details
tests_framework_other-macos Task Summary
Details
tests_framework_other-macos
Details
tests_framework_other-windows Task Summary
Details
tests_framework_other-windows
Details
tests_widgets-linux Task Summary
Details
tests_widgets-linux
Details
tests_widgets-macos Task Summary
Details
tests_widgets-macos
Details
tests_widgets-windows Task Summary
Details
tests_widgets-windows
Details
tool_coverage-linux
Details
tool_tests-linux Task Summary
Details
tool_tests-linux
Details
tool_tests-macos Task Summary
Details
tool_tests-macos
Details
tool_tests-windows Task Summary
Details
tool_tests-windows
Details
tool_tests_create-linux Task Summary
Details
tool_tests_create-linux
Details
tool_tests_create-macos Task Summary
Details
tool_tests_create-macos
Details
tool_tests_create-windows Task Summary
Details
tool_tests_create-windows
Details
tool_tests_integration-linux Task Summary
Details
tool_tests_integration-linux
Details
tool_tests_integration-macos Task Summary
Details
tool_tests_integration-macos
Details
tool_tests_integration-windows Task Summary
Details
tool_tests_integration-windows
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.