-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Mirror before scaling in _AnimatedIconPainter #93312
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
Conversation
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Amir-P thanks for the contribution, and welcome!
Can you add another test that validates the positioning like from the example before/after images you shared?
Also, it looks like there are currently failing tests, can you take a look?
Thanks! @Piinks |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I couldn't find a way to test the final position of drawn path. The position is determined by the transformations made to the canvas before drawing path and we have tests for that.
If you can guide me on writing tests for the position of path on canvas, please let me know.
The type of test to add should take the code sample that illustrates your bug (above), and verify that the icon is placed in the right position now. This validates that it actually fixes the reported bug, and prevents it from regressing in the future.
Here is a similar test:
| testWidgets('AppBar endDrawer icon has default size', (WidgetTester tester) async { |
Instead of checking the size (tester.getSize), you would want to check the position, using tester.getCenter or tester.getTopLeft and validate that the icon is in the right place now.
This change does not effect the widget and it's position. You can check the testWidgets('Direction has no effect on AnimatedIcon widget position',
(WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.rtl,
child: AnimatedIcon(
progress: AlwaysStoppedAnimation<double>(0.0),
icon: AnimatedIcons.arrow_menu,
),
),
);
final Rect rtlRect = tester.getRect(find.byType(AnimatedIcon));
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: AnimatedIcon(
progress: AlwaysStoppedAnimation<double>(0.0),
icon: AnimatedIcons.arrow_menu,
),
),
);
final Rect ltrRect = tester.getRect(find.byType(AnimatedIcon));
expect(rtlRect, ltrRect);
}); |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testWidgets('Direction has no effect on AnimatedIcon widget position', (WidgetTester tester) async { await tester.pumpWidget( const Directionality( textDirection: TextDirection.rtl, child: AnimatedIcon( progress: AlwaysStoppedAnimation<double>(0.0), icon: AnimatedIcons.arrow_menu, ), ), ); final Rect rtlRect = tester.getRect(find.byType(AnimatedIcon)); await tester.pumpWidget( const Directionality( textDirection: TextDirection.ltr, child: AnimatedIcon( progress: AlwaysStoppedAnimation<double>(0.0), icon: AnimatedIcons.arrow_menu, ), ), ); final Rect ltrRect = tester.getRect(find.byType(AnimatedIcon)); expect(rtlRect, ltrRect); });
I couldn't find this test in the framework, can you add it? Thanks!
Also, we'll still need a test that validates the very real use case you have in your before and after image above. Otherwise we may regress in the future. The current test validates that you have changed the order of operations, not that the visual difference above has changed.
If checking the position does not validate this, then it sounds like a golden file test is more appropriate. Can you add one? Thanks!
|
Can you please check the latest commit? Some of the tests are failing but I'm not sure why because I didn't make any changes. Also I guess we need to upload those golden file images which I don't have access to. @Piinks |
|
Gold has detected about 6 new digest(s) on patchset 3. |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you visit https://flutter-gold.skia.org/cl/github/93312 you can see the images your test generated for each platform, I can approve them when this is ready to land. You may want to add a RepaintBoundary around the icon widget, right now the images are large white squares with a tiny icon in the top left corner. :)
It looks like the file with the golden file test needs a tag added at the top to pass analysis, the other failing checks should be fixed by updating your branch.
For more on golden file testing, check out this wiki page:
https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can you revert this style change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This should be one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean to remove the break line after ...widget', ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: revert this, these style changes don't match the style guide.
Hope I got it right this time🤞🏻. @Piinks |
|
Gold has detected about 7 new digest(s) on patchset 4. |
|
Coming along nicely! Thanks for the updates! It looks like you still need to update your PR with the latest from the master branch. :) |
|
Gold has detected about 4 new digest(s) on patchset 4. |
Done. @Piinks |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Golden file images are approved, and this LGTM! Thank you!
|
This will need a secondary review, I've reached out to the team for one. Meanwhile, can you take a look at the merge conflict here? |
|
Gold has detected about 4 new digest(s) on patchset 5. |
|
Done @Piinks . |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| @Tags(<String>['reduced-test-set']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flutter.dev/go/reduce-ci-tests
https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter#reduced-test-set-tag
One of the velocity projects over the summer involved removing unit test runs on windows and mac machines. Just doing so though would remove our ability to provide a golden file test for every platform someone might be contributing to Flutter on, so we created a reduced test set for windows and mac. The analyzer will ensure now that all test files that contain a golden file test are included in the reduced test set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nice
Hixie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NATHANIELCROSBY1 NATHANIELCROSBY1 create … 609e127 13 days ago Git stats 27,477 commits Files Type Name Latest commit message Commit time .github Bump github/codeql-action from 1.0.26 to 1.0.31 (flutter#97820) 14 days ago bin Roll Engine from 2a4709a to 0712096 (1 revision) (flutter#9… 13 days ago dev Include -isysroot -arch and -miphoneos-version-min when creating dumm… 15 days ago examples Clean up the bindings APIs. (flutter#89451) 16 days ago packages Report progress on Dismissible update callback (flutter#95504) 14 days ago .ci.yaml Marks Linux_android opacity_peephole_fade_transition_text_perf__e2e_s… 15 days ago .cirrus.yml Pin dependencies in docker file. (flutter#97466) 18 days ago .gitattributes Add pre-stable support for create on Windows (flutter#51895) 2 years ago .gitignore Add macOS ephemeral to gitignore (flutter#96397) 20 days ago AUTHORS Mirror before scaling in _AnimatedIconPainter (flutter#93312) 24 days ago CODEOWNERS [codeowners] Remove *_builders.json ownership (flutter#91691) 4 months ago CODE_OF_CONDUCT.md Update CODE_OF_CONDUCT.md (flutter#94583) 3 months ago CONTRIBUTING.md Links How to contribute to Flutter YouTube video (flutter#96313) last month LICENSE License update (flutter#45373) 2 years ago PATENT_GRANT Rename patent file (flutter#38686) 3 years ago README.md Update README (flutter#97271) 24 days ago TESTOWNERS Add benchmarks to measure impact of alpha saveLayers in DisplayLists (f… 23 days ago analysis_options.yaml Enable no_leading_underscores_for_local_identifiers (flutter#96422) 29 days ago dartdoc_options.yaml Eliminate uses of pub executable in docs publishing and sample analys… 6 months ago flutter_console.bat License update (flutter#45373) 2 years ago git clone create 13 days ago README.md Flutter logo Build Status - Cirrus Discord badge Twitter handle Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source. Documentation Install Flutter Flutter documentation Development wiki Contributing to Flutter For announcements about new releases, follow the [email protected] mailing list. Our documentation also tracks breaking changes across releases. Terms of service The Flutter tool may occasionally download resources from Google servers. By downloading or using the Flutter SDK you agree to the Google Terms of Service: https://policies.google.com/terms For example, when installed from GitHub (as opposed to from a prepackaged archive), the Flutter tool will download the Dart SDK from Google servers immediately when first run, as it is used to execute the flutter tool itself. This will also occur when Flutter is upgraded (e.g. by running the flutter upgrade command). About Flutter We think Flutter will help you create beautiful, fast apps, with a productive, extensible and open development model, whether you're targeting iOS or Android, web, Windows, macOS, Linux or embedding it as the UI toolkit for a platform of your choice. Beautiful user experiences We want to enable designers to deliver their full creative vision without being forced to water it down due to limitations of the underlying framework. Flutter's layered architecture gives you control over every pixel on the screen and its powerful compositing capabilities let you overlay and animate graphics, video, text, and controls without limitation. Flutter includes a full set of widgets that deliver pixel-perfect experiences whether you're building for iOS (Cupertino) or Android (Material), along with support for customizing or creating entirely new visual components. Reflectly hero image Fast results Flutter is fast. It's powered by the same hardware-accelerated 2D graphics library that underpins Chrome and Android: Skia. We architected Flutter to support glitch-free, jank-free graphics at the native speed of your device. Flutter code is powered by the world-class Dart platform, which enables compilation to 32-bit and 64-bit ARM machine code for iOS and Android, as well as JavaScript for the web and Intel x64 for desktop devices. Dart diagram Productive development Flutter offers stateful hot reload, allowing you to make changes to your code and see the results instantly without restarting your app or losing its state. Hot reload animation Extensible and open model Flutter works with any development tool (or none at all), and also includes editor plug-ins for both Visual Studio Code and IntelliJ / Android Studio. Flutter provides tens of thousands of packages to speed your development, regardless of your target platform. And accessing other native code is easy, with support for both FFI and platform-specific APIs. Flutter is a fully open-source project, and we welcome contributions. Information on how to get started can be found in our contributor guide.

This PR attempts to fix an issue in
_AnimatedIconPaintercausing wrong positioning of_AnimatedIconDatawhenmatchTextDirectionset true in layouts with RTL directionality. This can be fixed by doing mirror before scaling the canvas.Code to reproduce:
Before:

After:

Issues this PR attempts to fix:
Fixes #60521
Pre-launch Checklist
///).