mirror of
https://github.com/flutter/packages.git
synced 2025-07-03 17:18:22 +08:00
[two_dimensional_scrollables] Fix another combo of pinned/unpinned merged TableViewCells (#6283)
Fixes https://github.com/flutter/flutter/issues/144100 Picks up doc fix from https://github.com/flutter/packages/pull/6154 as well
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
## 0.1.2
|
||||||
|
|
||||||
|
* Fixes a layout issue for unpinned merged cells that follow pinned table spans.
|
||||||
|
* Updates outdated sample code.
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
* Fixes a layout issue when pinned cells are merged.
|
* Fixes a layout issue when pinned cells are merged.
|
||||||
|
@ -49,8 +49,10 @@ import 'table_span.dart';
|
|||||||
/// ```dart
|
/// ```dart
|
||||||
/// TableView.builder(
|
/// TableView.builder(
|
||||||
/// cellBuilder: (BuildContext context, TableVicinity vicinity) {
|
/// cellBuilder: (BuildContext context, TableVicinity vicinity) {
|
||||||
/// return Center(
|
/// return TableViewCell(
|
||||||
|
/// child: Center(
|
||||||
/// child: Text('Cell ${vicinity.column} : ${vicinity.row}'),
|
/// child: Text('Cell ${vicinity.column} : ${vicinity.row}'),
|
||||||
|
/// ),
|
||||||
/// );
|
/// );
|
||||||
/// },
|
/// },
|
||||||
/// columnCount: 10,
|
/// columnCount: 10,
|
||||||
@ -809,10 +811,10 @@ class RenderTableViewport extends RenderTwoDimensionalViewport {
|
|||||||
switch ((rowIsInPinnedColumn, rowIsPinned)) {
|
switch ((rowIsInPinnedColumn, rowIsPinned)) {
|
||||||
// Both row and column are pinned at this cell, or just pinned row.
|
// Both row and column are pinned at this cell, or just pinned row.
|
||||||
(true, true) || (false, true) => 0.0,
|
(true, true) || (false, true) => 0.0,
|
||||||
// Cell is within a pinned column
|
// Cell is within a pinned column, or no pinned area at all.
|
||||||
(true, false) => _pinnedRowsExtent - verticalOffset.pixels,
|
(true, false) ||
|
||||||
// Cell is within a pinned row, or no pinned portion.
|
(false, false) =>
|
||||||
(false, false) => -verticalOffset.pixels,
|
_pinnedRowsExtent - verticalOffset.pixels,
|
||||||
};
|
};
|
||||||
mergedRowOffset = baseRowOffset +
|
mergedRowOffset = baseRowOffset +
|
||||||
_rowMetrics[firstRow]!.leadingOffset +
|
_rowMetrics[firstRow]!.leadingOffset +
|
||||||
@ -830,10 +832,10 @@ class RenderTableViewport extends RenderTwoDimensionalViewport {
|
|||||||
switch ((columnIsInPinnedRow, columnIsPinned)) {
|
switch ((columnIsInPinnedRow, columnIsPinned)) {
|
||||||
// Both row and column are pinned at this cell, or just pinned column.
|
// Both row and column are pinned at this cell, or just pinned column.
|
||||||
(true, true) || (false, true) => 0.0,
|
(true, true) || (false, true) => 0.0,
|
||||||
// Cell is within a pinned row.
|
// Cell is within a pinned row, or no pinned area at all.
|
||||||
(true, false) => _pinnedColumnsExtent - horizontalOffset.pixels,
|
(true, false) ||
|
||||||
// No pinned portion.
|
(false, false) =>
|
||||||
(false, false) => -horizontalOffset.pixels,
|
_pinnedColumnsExtent - horizontalOffset.pixels,
|
||||||
};
|
};
|
||||||
mergedColumnOffset = baseColumnOffset +
|
mergedColumnOffset = baseColumnOffset +
|
||||||
_columnMetrics[firstColumn]!.leadingOffset +
|
_columnMetrics[firstColumn]!.leadingOffset +
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: two_dimensional_scrollables
|
name: two_dimensional_scrollables
|
||||||
description: Widgets that scroll using the two dimensional scrolling foundation.
|
description: Widgets that scroll using the two dimensional scrolling foundation.
|
||||||
version: 0.1.1
|
version: 0.1.2
|
||||||
repository: https://github.com/flutter/packages/tree/main/packages/two_dimensional_scrollables
|
repository: https://github.com/flutter/packages/tree/main/packages/two_dimensional_scrollables
|
||||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+two_dimensional_scrollables%22+
|
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+two_dimensional_scrollables%22+
|
||||||
|
|
||||||
|
@ -2207,6 +2207,74 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'Merged unpinned cells following pinned cells are laid out correctly',
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
final ScrollController verticalController = ScrollController();
|
||||||
|
final ScrollController horizontalController = ScrollController();
|
||||||
|
final Set<TableVicinity> mergedCell = <TableVicinity>{
|
||||||
|
const TableVicinity(row: 2, column: 2),
|
||||||
|
const TableVicinity(row: 3, column: 2),
|
||||||
|
const TableVicinity(row: 2, column: 3),
|
||||||
|
const TableVicinity(row: 3, column: 3),
|
||||||
|
};
|
||||||
|
final TableView tableView = TableView.builder(
|
||||||
|
columnCount: 10,
|
||||||
|
rowCount: 10,
|
||||||
|
columnBuilder: (_) => const TableSpan(extent: FixedTableSpanExtent(100)),
|
||||||
|
rowBuilder: (_) => const TableSpan(extent: FixedTableSpanExtent(100)),
|
||||||
|
cellBuilder: (BuildContext context, TableVicinity vicinity) {
|
||||||
|
if (mergedCell.contains(vicinity)) {
|
||||||
|
return const TableViewCell(
|
||||||
|
rowMergeStart: 2,
|
||||||
|
rowMergeSpan: 2,
|
||||||
|
columnMergeStart: 2,
|
||||||
|
columnMergeSpan: 2,
|
||||||
|
child: Text('Tile c: 2, r: 2'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return TableViewCell(
|
||||||
|
child: Text('Tile c: ${vicinity.column}, r: ${vicinity.row}'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
pinnedRowCount: 1,
|
||||||
|
pinnedColumnCount: 1,
|
||||||
|
verticalDetails: ScrollableDetails.vertical(
|
||||||
|
controller: verticalController,
|
||||||
|
),
|
||||||
|
horizontalDetails: ScrollableDetails.horizontal(
|
||||||
|
controller: horizontalController,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(MaterialApp(home: tableView));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(verticalController.position.pixels, 0.0);
|
||||||
|
expect(horizontalController.position.pixels, 0.0);
|
||||||
|
expect(
|
||||||
|
tester.getRect(find.text('Tile c: 2, r: 2')),
|
||||||
|
const Rect.fromLTWH(200.0, 200.0, 200.0, 200.0),
|
||||||
|
);
|
||||||
|
|
||||||
|
verticalController.jumpTo(10.0);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(verticalController.position.pixels, 10.0);
|
||||||
|
expect(horizontalController.position.pixels, 0.0);
|
||||||
|
expect(
|
||||||
|
tester.getRect(find.text('Tile c: 2, r: 2')),
|
||||||
|
const Rect.fromLTWH(200.0, 190.0, 200.0, 200.0),
|
||||||
|
);
|
||||||
|
|
||||||
|
horizontalController.jumpTo(10.0);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(verticalController.position.pixels, 10.0);
|
||||||
|
expect(horizontalController.position.pixels, 10.0);
|
||||||
|
expect(
|
||||||
|
tester.getRect(find.text('Tile c: 2, r: 2')),
|
||||||
|
const Rect.fromLTWH(190.0, 190.0, 200.0, 200.0),
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _NullBuildContext implements BuildContext, TwoDimensionalChildManager {
|
class _NullBuildContext implements BuildContext, TwoDimensionalChildManager {
|
||||||
|
Reference in New Issue
Block a user