Skip to content

Workaround rounding erros in cupertino nav bar transition - #88935

Merged
fluttergithubbot merged 4 commits into
flutter:masterfrom
LongCatIsLooong:workaround-rounding-erros-in-cupertino-nav-bar-transition
Aug 31, 2021
Merged

fluttergithubbot merged 4 commits into
flutter:masterfrom
LongCatIsLooong:workaround-rounding-erros-in-cupertino-nav-bar-transition

Conversation

@LongCatIsLooong

Copy link
Copy Markdown
Contributor

Guarantees the incoming constraints of the middle widget are always the same during the transition.

screencasts (in RTL)

before.mp4
after.mp4

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Prevent the nav bar from changing the size of the middle wiget during transition.
@LongCatIsLooong
LongCatIsLooong requested a review from xster August 26, 2021 06:54
@flutter-dashboard flutter-dashboard Bot added p: cupertino_ui cupertino_ui package in flutter/packages framework flutter/packages/flutter repository. See also f: labels. labels Aug 26, 2021
@google-cla google-cla Bot added the cla: yes label Aug 26, 2021
@nt4f04uNd nt4f04uNd mentioned this pull request Aug 26, 2021
7 of 8 tasks

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't review whether this framework-y code is idiomatic, but the Dart code LGTM.
Resulting video really LGTM!

}
}

class _PositionedAnchorTransition extends AnimatedWidget {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this class use a comment to explain what "positioned anchor" means in this context?

child.layout(childConstraints, parentUsesSize: true);

late final double x;
final double x;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work as a final if x is set a few lines below?

@LongCatIsLooong LongCatIsLooong Aug 27, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is final double x only declares the variable, and the compiler/analyzer is smart enough to determine that there's nothing using x before it gets initialized in the if clauses.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

hasVisualOverflow = true;

late final double y;
final double y;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: length

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing to add a test for: if in page 1 the content widget is font size 10 and in page 2 it's size 20, and the text animates from a smaller size to a bigger size, if in page 2, it doesn't wrap at the end, we'd want to make sure it never wraps at any point in the transition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the transition starts from page 1 and the text has a font size of 10, then during the transition the text widget will always be given the same width constraint that's just enough for the max intrinsic width of the text when the font size is 10 right? If the font animates to size 20 then it's guaranteed to wrap?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going through the bug, it seems like this wasn't the issue. Would still be nice to address separately (since the beginning state isn't wrapped, the end state isn't wrapped either, but the transition might be wrapped). But otherwise the PR LGTM to fix the rounding issue

@LongCatIsLooong LongCatIsLooong Aug 31, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During the animation the font size can change, and in the case where the font size gets larger but the container is still able to provide enough horizontal space the text shouldn't wrap?

As I understand it during the animation the middle widget has a start size but does not typically have an end size:

      return slideFromLeadingEdge(
        fromKey: bottomComponents.middleKey,
        fromNavBarBox: bottomNavBarBox,
        toKey: topComponents.backLabelKey,
        toNavBarBox: topNavBarBox,

So the middle widget moves to align with the backLabelKey widget when the animation completes and it's not given a size.

@LongCatIsLooong
LongCatIsLooong force-pushed the workaround-rounding-erros-in-cupertino-nav-bar-transition branch from ce7c3cd to b2460e1 Compare August 31, 2021 16:55
@fluttergithubbot
fluttergithubbot merged commit a0b560f into flutter:master Aug 31, 2021
@LongCatIsLooong
LongCatIsLooong deleted the workaround-rounding-erros-in-cupertino-nav-bar-transition branch August 31, 2021 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: cupertino_ui cupertino_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CupertinoNavigationBar animation flickering

4 participants