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

[two_dimensional_scrollables] Merged cells for TableView #5917

Merged
merged 22 commits into from
Jan 31, 2024

Conversation

Piinks
Copy link
Contributor

@Piinks Piinks commented Jan 18, 2024

Fixes flutter/flutter#131224

➡️ Design Doc ⬅️

This adds support for merged cells in TableView.
This contains a breaking change that will require all children of the TableView to be a TableViewCell.

Screenshot 2024-01-25 at 4 38 49 PM

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 relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this 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.

@Piinks Piinks added the p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package label Jan 18, 2024
Piinks added a commit to flutter/website that referenced this pull request Jan 25, 2024
@Piinks Piinks changed the title [WIP] [two_dimensional_scrollables] Merged cells for TableView [two_dimensional_scrollables] Merged cells for TableView Jan 25, 2024
sfshaza2 pushed a commit to flutter/website that referenced this pull request Jan 26, 2024
_Description of what this PR is changing or adding, and why:_

Design doc for flutter/packages#5917

_Issues fixed by this PR (if any):_

Related to flutter/flutter#131224

## Presubmit checklist

- [x] This PR doesn’t contain automatically generated corrections
(Grammarly or similar).
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

Great test coverage!

@goderbauer
Copy link
Member

Somehow the checks are rather unhappy now.

ChildVicinity vicinity, {
bool allowMerged = true,
}) {
return super.getChildFor(vicinity) ??
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to change this to the suggestion in that other comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hadn't because I want to be able to assert that if we requested a child that returned null (using the super getChildFor first), then it is for certain covered by a merged cell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or, maybe stated better, I want to see if there is a canonical child first, and if not, need to ensure we have not lost a child so it asserts the vicinity returning null is in fact covered by a merged cell.

Copy link
Member

Choose a reason for hiding this comment

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

I see. That makes sense. Thanks for the explanation!

@Piinks
Copy link
Contributor Author

Piinks commented Jan 31, 2024

Somehow the checks are rather unhappy now.

Oh I see I accidentally committed some changes to the example app.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

/// [TableVicinity] in a [TableView], but may return null.
///
/// Used by [TableCellBuilderDelegate.builder] to build cells on demand for the
/// table.
typedef TableViewCellBuilder = Widget? Function(
typedef TableViewCellBuilder = TableViewCell Function(
Copy link
Member

Choose a reason for hiding this comment

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

I didn't notice this before: Is this intentional that null is no longer allowed as a return value? If so, the doc above needs updating. (Remind me: what did it mean when this was previously returning null? What are we no longer allowing?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This felt like a bug I came across. Typically in Flutter scrolling land, returning null from the child delegate means we have reached the end of the children. This is not currently supported, but is part of supporting infinite children in the table: flutter/flutter#131226.

I think it was here by mistake since if you return null currently, with or without this change, it will crash! :(

/// represented by its [TableVicinity]. The table supports lazy rendering and
/// will only instantiate those cells that are currently visible in the table's
/// viewport and those that extend into the [cacheExtent].
/// Each child [TableViewCell] can belong to exactly one row and one column as
Copy link
Member

Choose a reason for hiding this comment

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

über-nit: What do you think about inserting an "either" in this sentence between "to" and "exactly"? The first part of the sentence makes it sound like we don't support merged cells at all and then the second part catches you by surprise. With that either we can maybe emphasize a little more that the "exactly one row/column" is not the whole story.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes excellent sense to me!

ChildVicinity vicinity, {
bool allowMerged = true,
}) {
return super.getChildFor(vicinity) ??
Copy link
Member

Choose a reason for hiding this comment

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

I see. That makes sense. Thanks for the explanation!

// vicinity.
assert(_mergedVicinities.keys.contains(vicinity));
final TableVicinity mergedVicinity = _mergedVicinities[vicinity]!;
return getChildFor(mergedVicinity)!;
Copy link
Member

Choose a reason for hiding this comment

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

For my own sanity, should this call specify mapMergedVicinityToCanonicalChild: false to make it super clear, that we do not expect this call to recurse? It is a bug if this call to getChildFor would call _getMergedChildFor again, right? I think specifying this expectation here clearly would make this code a little easier to understand and follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wow I totally missed that recursion. Ha! Gotcha, nice catch. 🙃

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 31, 2024
@auto-submit auto-submit bot merged commit 2d0f24f into flutter:main Jan 31, 2024
78 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 2, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Feb 2, 2024
flutter/packages@5b48c44...d37fb0a

2024-02-02 [email protected] Add a link the different possible Android virtual device configs (flutter/packages#6033)
2024-02-01 [email protected] Update the emulator versions and expose cipd. (flutter/packages#6025)
2024-02-01 [email protected] [tool] Add details to missing gradle coverage error (flutter/packages#6029)
2024-02-01 [email protected] [file_selector] Fix comment typo (flutter/packages#6027)
2024-02-01 [email protected] [camerax] Change `buildPreview` to return `Texture` versus `FutureBuilder` (flutter/packages#6021)
2024-02-01 [email protected] Manual roll Flutter from c65ab4d to e02e207 (38 revisions) (flutter/packages#6028)
2024-02-01 [email protected] Manual roll Flutter from 75a2e5b to c65ab4d (22 revisions) (flutter/packages#6026)
2024-02-01 [email protected] Roll Flutter from ace9181 to 75a2e5b (16 revisions) (flutter/packages#6017)
2024-02-01 [email protected] [webview_flutter] Support for handling basic authentication requests (flutter/packages#5727)
2024-01-31 [email protected] [tool] Extend `flutter test` workaround to other desktops (flutter/packages#6024)
2024-01-31 [email protected] [two_dimensional_scrollables] Merged cells for TableView (flutter/packages#5917)
2024-01-31 [email protected] [rfw] Restore RFW to 100% coverage after `ButtonBar` update (flutter/packages#6020)
2024-01-31 [email protected] [in_app_purchase] Convert storefront(), transactions(), canMakePayment(), and addPayment() to pigeon (flutter/packages#5910)
2024-01-31 [email protected] [in_app_purchase] Add play country code api (flutter/packages#5941)

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-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@ahmednfwela
Copy link
Contributor

@Piinks It seems that the package wasn't uploaded on pub.dev after this PR, is there a reason for this ?

atsansone pushed a commit to atsansone/website that referenced this pull request Feb 15, 2024
_Description of what this PR is changing or adding, and why:_

Design doc for flutter/packages#5917

_Issues fixed by this PR (if any):_

Related to flutter/flutter#131224

- [x] This PR doesn’t contain automatically generated corrections
(Grammarly or similar).
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.
atsansone pushed a commit to atsansone/website that referenced this pull request Apr 5, 2024
_Description of what this PR is changing or adding, and why:_

Design doc for flutter/packages#5917

_Issues fixed by this PR (if any):_

Related to flutter/flutter#131224

## Presubmit checklist

- [x] This PR doesn’t contain automatically generated corrections
(Grammarly or similar).
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
Fixes flutter/flutter#131224
 
��  [Design Doc](https://docs.google.com/document/d/1UekXjG_VKmWYbsxDEzMqTb7F-6oUr05v998n5IqtVWs/edit?usp=sharing) �� 

This adds support for merged cells in TableView.
This contains a breaking change that will require all children of the TableView to be a TableViewCell.

![Screenshot 2024-01-25 at 4 38 49�PM](https://github.com/flutter/packages/assets/16964204/02f4c158-23e9-401e-ac84-b6303d999095)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TableView follow up: Merged cells
3 participants