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
TwoDimensional scrolling foundation #125437
Conversation
I'll have to block some time to look at this. In the meantime, can you make the checks pass? |
Of course! Take your time. :)
Oof sorry! I thought I caught all of them. On it! |
xLayoutOffset += 200; | ||
} | ||
if (applyDimensions) { | ||
verticalOffset.applyContentDimensions(0, 200 * 100 - viewportDimension.height); |
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.
This is the only thing I am still unsure of. I tried to write some logic to estimate the max scroll extent for the user, but it was really hard to guess what they were building or how long it would be in one or both dimensions.
So right now, the user has to call applyContentDimensions. I currently have a check that will tell them to do so if they have not.
The other thing I considered was exposing a maxScrollOffset
getter that the subclasses would have to implement, and then the super class could call applyContentDimensions with that at the end of performLayout.
I like the getter approach, curious to know what you think first though. :)
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.
Either seems fine to me. If we want people to call applyContentDimensions within layoutChildSequence we should document that, though. The getter may be a little less flexible (which could be fine), but simpler to implement.
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.
Comments from initial read-through to familiarize myself with this large PR. It's not a full review yet and I didn't get to two_dimensional_viewport.dart and the test file yet.
0ad8747
to
b3add8d
Compare
I am having branch issues. I really do not want to close this, but the Github UI is not updating with the code. |
Ok I think my branch issues are behind me. I responded to the last review and left a few questions for feedback. I will push tests next now that I have everything fixed. |
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.
Finished initial read-through of the last few remaining files.
packages/flutter/test/widgets/two_dimensional_viewport_test.dart
Outdated
Show resolved
Hide resolved
xLayoutOffset += 200; | ||
} | ||
if (applyDimensions) { | ||
verticalOffset.applyContentDimensions(0, 200 * 100 - viewportDimension.height); |
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.
Either seems fine to me. If we want people to call applyContentDimensions within layoutChildSequence we should document that, though. The getter may be a little less flexible (which could be fine), but simpler to implement.
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.
Overall, this LGTM. It is missing some test coverage, though.
/// Subclasses must implement this function and will typically wrap their | ||
/// children in [RepaintBoundary] widgets. | ||
/// | ||
/// The values returned by this method are cached. To indicate that the |
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.
Can you also just call "notifyListeners" as the class level comment indicated?
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.
I think so, added more to the doc.
for (final RenderBox child in _children.values) { | ||
final TwoDimensionalViewportParentData childParentData = parentDataOf(child); | ||
final Rect childRect = childParentData.paintOffset & child.size; | ||
if (childRect.contains(position)) { |
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.
Doesn't child.hitTest
below already contain this check?
if (_size!.contains(position)) { |
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.
Excellent point, fixed!
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.
Looks like this wasn't resolved after all?
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 right. I changed it, and then had a bug and ended up writing it back in. Let me double check. Thanks for pointing it out! I did not realize I ended up reverting it.
void _startLayout(); | ||
void _buildChild(ChildVicinity index); | ||
void _reuseChild(ChildVicinity index); | ||
void _endLayout(); |
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.
Maybe consider making the methods public. That way, people can implement their own TwoDimensionalChildManager
if they wanted to and having a public class with no visible methods is kinda strange.
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.
Yeah, I think that is where we started a conversation about finding a way to make it private.
Would folks actually be able to implement their own? So much of the implementation relies on private class members.
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.
Overall, this LGTM. It is missing some test coverage, though. :)
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.
LGTM
for (final RenderBox child in _children.values) { | ||
final TwoDimensionalViewportParentData childParentData = parentDataOf(child); | ||
final Rect childRect = childParentData.paintOffset & child.size; | ||
if (childRect.contains(position)) { |
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.
Looks like this wasn't resolved after all?
flutter/flutter@ee162e4...3db9504 2023-05-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 340936f7c03c to a4d4ad9dae1a (1 revision) (flutter/flutter#127772) 2023-05-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 57e491a46e05 to 340936f7c03c (1 revision) (flutter/flutter#127767) 2023-05-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from a37b1a38d97a to 57e491a46e05 (1 revision) (flutter/flutter#127765) 2023-05-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from b1698020bd57 to a37b1a38d97a (1 revision) (flutter/flutter#127761) 2023-05-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9e97c7379c7f to b1698020bd57 (1 revision) (flutter/flutter#127758) 2023-05-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0f38a0f0a18a to 9e97c7379c7f (1 revision) (flutter/flutter#127755) 2023-05-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 1187168472a7 to 0f38a0f0a18a (1 revision) (flutter/flutter#127752) 2023-05-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3426cb827efb to 1187168472a7 (1 revision) (flutter/flutter#127745) 2023-05-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 795db50e7453 to 3426cb827efb (9 revisions) (flutter/flutter#127738) 2023-05-27 tessertaha@gmail.com Updated the `ToggleButtons` API doc to link to `SegmentedButton` (flutter/flutter#127021) 2023-05-26 nbosch@google.com Remove more `test_api/src` imports (flutter/flutter#127716) 2023-05-26 31859944+LongCatIsLooong@users.noreply.github.com Move shared inline widget logic to `RenderInlineWidgetContainerDefaults` (flutter/flutter#127308) 2023-05-26 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3b5b5fc96b8f to 795db50e7453 (1 revision) (flutter/flutter#127720) 2023-05-26 pq@users.noreply.github.com Update collection-fors to prefer final (as per updated `prefer_final_in_for_each`) (flutter/flutter#127511) 2023-05-26 engine-flutter-autoroll@skia.org Roll Flutter Engine from eed12f36f595 to 3b5b5fc96b8f (1 revision) (flutter/flutter#127713) 2023-05-26 gspencergoog@users.noreply.github.com Remove references to deprecated `ThemeData.primaryColorBrightness` (flutter/flutter#127238) 2023-05-26 katelovett@google.com TwoDimensional scrolling foundation (flutter/flutter#125437) 2023-05-26 engine-flutter-autoroll@skia.org Roll Flutter Engine from 858d9753453c to eed12f36f595 (2 revisions) (flutter/flutter#127702) 2023-05-26 36861262+QuncCccccc@users.noreply.github.com Remove button announcement for `MenuItemButton` and `SubmenuButton` (flutter/flutter#127620) 2023-05-26 chillers@google.com Reland "Update labeler action wildcards #127524" (flutter/flutter#127690) 2023-05-26 vashworth@google.com Revert "Log all lines from ios-deploy (#127502)" (flutter/flutter#127684) 2023-05-26 engine-flutter-autoroll@skia.org Roll Flutter Engine from ec7b0ae3599f to 858d9753453c (2 revisions) (flutter/flutter#127700) 2023-05-26 tessertaha@gmail.com Add M3 date range picker tests and fix header background theme color (flutter/flutter#127662) 2023-05-26 reidbaker@google.com Support minifcation for apps that depend on AGP 8 and integration_test (flutter/flutter#127628) 2023-05-26 gspencergoog@users.noreply.github.com Bump Snippet version (flutter/flutter#127688) 2023-05-26 chris@bracken.jp [Linux] Use up_client_get_devices2 when possible (flutter/flutter#127699) 2023-05-26 engine-flutter-autoroll@skia.org Roll Flutter Engine from 84f2fc16e55d to ec7b0ae3599f (3 revisions) (flutter/flutter#127698) 2023-05-26 5236035+fzyzcjy@users.noreply.github.com Fix `TextField` error in production environment because it wrongly uses ancestor render boxes (flutter/flutter#126324) 2023-05-26 127535196+JsGjKJzi@users.noreply.github.com Interactive viewer doesn't appear to respect the trackpadScrollCausesScale parameter (flutter/flutter#127114) 2023-05-26 chillers@google.com Remove release timeline (flutter/flutter#127685) 2023-05-26 engine-flutter-autoroll@skia.org Manual roll Flutter Engine from 8573f3b63a1f to 84f2fc16e55d (7 revisions) (flutter/flutter#127676) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
hello, how can I use this ? is there any example ? Thanks |
From the 2D scrolling proposal: flutter.dev/go/2D-Foundation ✅ updated 4/25
Fixes #125505
Follow up issues:
This adds a mostly abstract foundation for 2D scrolling in Flutter.
With these base classes, developers will be able to construct widgets that scroll in both dimensions and can lazily load their children for the best performance. This implementation is meant to be flexible in order to support different kinds of 2D compositions, from tables to scatter plots.
The upcoming TableView, TreeView, etc widgets (coming soon in flutter/packages) are built on top of this foundation.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.