-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[two_dimensional_scrollables] Add TableSpanPadding #5039
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
packages/two_dimensional_scrollables/lib/src/table_view/table_span.dart
Outdated
Show resolved
Hide resolved
packages/two_dimensional_scrollables/lib/src/table_view/table_span.dart
Outdated
Show resolved
Hide resolved
packages/two_dimensional_scrollables/test/table_view/table_test.dart
Outdated
Show resolved
Hide resolved
packages/two_dimensional_scrollables/lib/src/table_view/table.dart
Outdated
Show resolved
Hide resolved
packages/two_dimensional_scrollables/lib/src/table_view/table.dart
Outdated
Show resolved
Hide resolved
packages/two_dimensional_scrollables/lib/src/table_view/table.dart
Outdated
Show resolved
Hide resolved
|
The paddings for the @override
Widget build(BuildContext context) {
final padding = MediaQuery.paddingOf(context);
const columnCount = 100;
const rowCount = 100;
return TableView.builder(
cellBuilder: (context, vicinity) {
return const Text('foo');
},
columnCount: columnCount,
columnBuilder: (int column) => TableSpan(
extent: const FixedTableSpanExtent(64),
padding: TableSpanPadding(
leading: column == 0 ? padding.left : 0.0,
trailing: column == columnCount - 1 ? padding.right : 0.0,
),
),
rowCount: rowCount,
rowBuilder: (int row) => TableSpan(
extent: FixedTableSpanExtent(64),
padding: TableSpanPadding(
leading: row == 0 ? padding.top : 0.0,
trailing: row == rowCount - 1 ? padding.bottom : 0.0,
),
),
);
}Also the |
That can be achieved here by applying the appropriate padding to the first/last columns/rows. Additionally, you can always wrap the TableView with a padding widget. In general, we avoid enumerating padding properties on widgets when we have a Padding widget itself. :)
This sounds like a case for SafeArea!
Good point! Thanks for the feedback! |
Sure. This wouldn't make anything possible that wasn't possible before. It would just be a convenience feature and would make it consistent with other scrollable widgets such as
But wouldn't both a
screen-20231010-211917.2.mp4
screen-20231010-212041.2.mp4 |
|
Sure! I think we are talking about different things, I may have misunderstood. :) |
|
FYI @goderbauer, not ready for review yet. |
| // TODO(Piinks): Rewrite this to remove golden files from this repo when | ||
| // mock_canvas is public - https://github.com/flutter/flutter/pull/131631 | ||
| // foreground, background, and precedence per mainAxis | ||
| // * foreground, background, and precedence per mainAxis |
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 realize I am packing a lot into this single golden file test, but I don't want to add more images to the repo when very soon I will be able to rewrite this into tests that use the mock canvas API when it reaches stable.
| // extend beyond the viewport, we would never see them as they would never | ||
| // scroll into view. So this currently implementation is fairly assuming | ||
| // we will never have rows/cols that are outside of the viewport. We should | ||
| // maybe add an assertion for this during layout. |
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.
Assertion sounds dangerous. For me as a developer on my MegaPhone everything my look fine, but when my users run it on their TinyPhone things will be broken for them - and I never saw the assertion during development to warn me about this.
To really fix this, we probably need to do more than just an assertion. What do other implementations do if there isn't enough screen real estate to display all frozen rows/cols? Spreadsheet apps come to mind that we could check for their behavior (both on web and in their native app).
(This is of course not required to be resolved for this PR, having a TODO for this use case seems fine for now.)
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.
We discussed this offline and agreed we will pursue a non fatal warning here in the same way we do the render overflow error.
| /// The [extent] argument must be provided. | ||
| const TableSpan({ | ||
| required this.extent, | ||
| TableSpanPadding? padding, |
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.
Just wondering if this could/should be
| TableSpanPadding? padding, | |
| this.padding = const TableSpanPadding(), |
and then remove the padding initializer below?
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 had it this way originally, then when writing the sample code, I found it unfriendly. For example:
// Non-nullable
TableSpan(
padding: someCondition ? TableSpanPadding(leading: 20) : TableSpanPadding(),
// ...
)versus
// Nullable, resolves to non nullable in field member assignment
TableSpan(
padding: someCondition ? TableSpanPadding(leading: 20) : null,
// ...
)| /// }, | ||
| /// ); | ||
| /// ``` | ||
| /// {@end-tool} |
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 know we cannot do this here (yet) but I really wish this would be an interactive example so I can play with enabling/disabling consumeSpanPadding and see what it does.)
| required TableVicinity start, | ||
| required TableVicinity end, | ||
| required Offset offset, | ||
| }) { |
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.
Could you explain to me how the padding is taken into account when calculating the start and end (input to this method) cells?
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.
_Span.trailingOffset is used to calculate the start and end, which includes the padding. There are even tests for this case. Awesome!
goderbauer
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.
LGTM
flutter/packages@fea24c5...2af6954 2023-10-26 katelovett@google.com [two_dimensional_scrollables] Add TableSpanPadding (flutter/packages#5039) 2023-10-26 engine-flutter-autoroll@skia.org Roll Flutter (stable) from 6c4930c to d211f42 (1 revision) (flutter/packages#5238) 2023-10-26 chrislangham@rightnow.org [url_launcher] migrating objc plugin to swift (flutter/packages#4753) 2023-10-26 ybz975218925@live.com [go_router_builder]Avoid losing NullabilitySuffix for typeArguments (flutter/packages#5215) 2023-10-26 engine-flutter-autoroll@skia.org Roll Flutter from 5dd2a4e to c555599 (14 revisions) (flutter/packages#5237) 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 flutter-ecosystem@google.com,rmistry@google.com 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
Fixes flutter/flutter#134453
Also related: flutter/flutter#134655
This adds padding to TableSpans with TableSpanPadding. This affords folks a leading and trailing offset to pad rows and columns by.
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.