Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Stop before rework
  • Loading branch information
Piinks committed Jan 23, 2024
commit 0d461c7be06884bd1c9d5be26b89a187c0483d84
61 changes: 42 additions & 19 deletions packages/two_dimensional_scrollables/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,22 @@ class TableExample extends StatefulWidget {
}

class _TableExampleState extends State<TableExample> {
final Map<TableVicinity, (int, int)> mergedRows= <TableVicinity, (int, int)>{
final Map<TableVicinity, (int, int)> mergedRows = <TableVicinity, (int, int)>{
// TableVicinity in merged cell : (start, span)
TableVicinity.zero : (0, 2),
TableVicinity.zero: (0, 2),
TableVicinity.zero.copyWith(row: 1): (0, 2),
const TableVicinity(row: 1, column: 1) : (1, 2),
const TableVicinity(row: 2, column: 1) : (1, 2),
const TableVicinity(row: 2, column: 2) : (2, 2),
const TableVicinity(row: 3, column: 2) : (2, 2),
const TableVicinity(row: 1, column: 1): (1, 2),
const TableVicinity(row: 2, column: 1): (1, 2),
const TableVicinity(row: 2, column: 2): (2, 2),
const TableVicinity(row: 3, column: 2): (2, 2),
};

final Map<TableVicinity, (int, int)> mergedColumns = <TableVicinity, (int, int)>{
// TableVicinity in merged cell : (start, span)
const TableVicinity(row: 0, column: 2) : (2, 2),
const TableVicinity(row: 0, column: 3) : (2, 2),
const TableVicinity(row: 3, column: 0) : (0, 2),
const TableVicinity(row: 3, column: 1) : (0, 2),
};

@override
Expand All @@ -68,10 +76,18 @@ class _TableExampleState extends State<TableExample> {
}

TableViewCell _buildCell(BuildContext context, TableVicinity vicinity) {
if (mergedRows.keys.contains(vicinity)) {
if (mergedColumns.keys.contains(vicinity) || mergedRows.keys.contains(vicinity)) {
print('Vicinity $vicinity has: \n '
'\t rowMergeStart: ${mergedRows[vicinity]?.$1}\n'
'\t rowMergeSpan: ${mergedRows[vicinity]?.$2}\n'
'\t columnMergeStart: ${mergedColumns[vicinity]?.$1}\n'
'\t columnMergeSpan: ${mergedColumns[vicinity]?.$2} '
);
return TableViewCell(
rowMergeStart: mergedRows[vicinity]!.$1,
rowMergeSpan: mergedRows[vicinity]!.$2,
rowMergeStart: mergedRows[vicinity]?.$1,
rowMergeSpan: mergedRows[vicinity]?.$2,
// columnMergeStart: mergedColumns[vicinity]?.$1,
// columnMergeSpan: mergedColumns[vicinity]?.$2,
child: const Center(
child: Text('Merged'),
),
Expand All @@ -87,27 +103,34 @@ class _TableExampleState extends State<TableExample> {

TableSpan _buildRowSpan(int index) {
late final Color color;
switch(index) {
case 1: color = Colors.purple;
case 2: color = Colors.blue;
case 3: color = Colors.green;
default: color = Colors.transparent;
switch (index) {
case 1:
color = Colors.purple;
case 2:
color = Colors.blue;
case 3:
color = Colors.green;
default:
color = Colors.transparent;
}

return TableSpan(
extent: const FixedTableSpanExtent(100.0),
backgroundDecoration: TableSpanDecoration(
color: color,
border: const TableSpanBorder(leading: BorderSide(), trailing: BorderSide(),),
),
// backgroundDecoration: TableSpanDecoration(
// color: color,
// border: const TableSpanBorder(
// leading: BorderSide(),
// trailing: BorderSide(),
// ),
// ),
);
}

TableSpan _buildColumnSpan(int index) {
return const TableSpan(
extent: FixedTableSpanExtent(100.0),
// foregroundDecoration: TableSpanDecoration(
// border: const TableSpanBorder(leading: BorderSide(), trailing: BorderSide(),),
// border: TableSpanBorder(leading: BorderSide(), trailing: BorderSide(),),
// ),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading