Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.27.1"
"flutter": "3.29.2"
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dart.flutterSdkPath": ".fvm/versions/3.27.1",
"dart.flutterSdkPath": ".fvm/versions/3.29.2",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
Expand Down
2 changes: 1 addition & 1 deletion examples/tagflow/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: "none"
version: 1.1.0

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">= 3.7.0 <4.0.0"

dependencies:
cupertino_icons: ^1.0.8
Expand Down
11 changes: 11 additions & 0 deletions packages/tagflow/lib/src/widgets/selectable_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,15 @@
_geometry.dispose();
super.dispose();
}

@override

Check warning on line 372 in packages/tagflow/lib/src/widgets/selectable_adapter.dart

View check run for this annotation

Codecov / codecov/patch

packages/tagflow/lib/src/widgets/selectable_adapter.dart#L372

Added line #L372 was not covered by tests
int get contentLength => 1;

@override

Check warning on line 375 in packages/tagflow/lib/src/widgets/selectable_adapter.dart

View check run for this annotation

Codecov / codecov/patch

packages/tagflow/lib/src/widgets/selectable_adapter.dart#L375

Added line #L375 was not covered by tests
SelectedContentRange? getSelection() {
if (!value.hasSelection) {

Check warning on line 377 in packages/tagflow/lib/src/widgets/selectable_adapter.dart

View check run for this annotation

Codecov / codecov/patch

packages/tagflow/lib/src/widgets/selectable_adapter.dart#L377

Added line #L377 was not covered by tests
return null;
}
return const SelectedContentRange(startOffset: 0, endOffset: 1);
}
}
2 changes: 1 addition & 1 deletion packages/tagflow/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ homepage: https://docs.arya.run/tagflow
issue_tracker: https://github.com/devaryakjha/tagflow/issues

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">= 3.7.0 <4.0.0"

dependencies:
collection: ^1.19.0
Expand Down
117 changes: 64 additions & 53 deletions packages/tagflow_table/lib/src/rendering/tagflow_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@
right: BorderSide.lerp(a.right, b.right, t),
top: BorderSide.lerp(a.top, b.top, t),
bottom: BorderSide.lerp(a.bottom, b.bottom, t),
horizontalInside:
BorderSide.lerp(a.horizontalInside, b.horizontalInside, t),
horizontalInside: BorderSide.lerp(
a.horizontalInside,
b.horizontalInside,
t,
),
verticalInside: BorderSide.lerp(a.verticalInside, b.verticalInside, t),
);
}
Expand Down Expand Up @@ -169,16 +172,8 @@
if (treatFirstRowAsHeader && headerBackgroundColor != null && rows > 0) {
// extending beyond the padding
// TODO(devaryakjha): make this configurable
final headerRect = Rect.fromLTWH(
0,
0,
rect.width,
rowHeights[0],
);
canvas.drawRect(
headerRect,
Paint()..color = headerBackgroundColor,
);
final headerRect = Rect.fromLTWH(0, 0, rect.width, rowHeights[0]);
canvas.drawRect(headerRect, Paint()..color = headerBackgroundColor);

Check warning on line 176 in packages/tagflow_table/lib/src/rendering/tagflow_table.dart

View check run for this annotation

Codecov / codecov/patch

packages/tagflow_table/lib/src/rendering/tagflow_table.dart#L175-L176

Added lines #L175 - L176 were not covered by tests
}

// Paint outer borders
Expand Down Expand Up @@ -216,8 +211,10 @@

// Paint inner borders
if (horizontalInside != BorderSide.none && rows > 1) {
_horizontalInsidePaint =
_getPaint(horizontalInside, _horizontalInsidePaint);
_horizontalInsidePaint = _getPaint(
horizontalInside,
_horizontalInsidePaint,
);
var y = rowHeights[0];
for (var i = 1; i < rows; i++) {
// Find segments where we should draw the horizontal line
Expand Down Expand Up @@ -314,13 +311,13 @@
@override
// coverage:ignore-line
List<Object?> get props => [
left,
right,
top,
bottom,
horizontalInside,
verticalInside,
];
left,
right,
top,
bottom,
horizontalInside,
verticalInside,
];
}

class RenderTagflowTable extends RenderBox
Expand Down Expand Up @@ -410,9 +407,11 @@

// Calculate total spacing needed between columns
final totalColumnSpacing = (_columnCount - 1) * _columnSpacing;

// Calculate available width for columns after accounting for spacing and padding
final availableWidth = constraints.maxWidth - totalColumnSpacing - _padding.horizontal;

// Calculate available width for columns after accounting for
// spacing and padding
final availableWidth =
constraints.maxWidth - totalColumnSpacing - _padding.horizontal;

// First pass: Calculate minimum and preferred column widths
_columnWidths = List<double>.filled(_columnCount, 0);
Expand All @@ -429,23 +428,29 @@
// Update minimum widths
for (var i = 0; i < childParentData.colSpan; i++) {
final colIndex = childParentData.column + i;
_columnWidths[colIndex] = math.max(_columnWidths[colIndex], widthPerColumn);

_columnWidths[colIndex] = math.max(
_columnWidths[colIndex],
widthPerColumn,
);

// Track how flexible each column is based on content
final flexibility = (maxWidth - minWidth) / childParentData.colSpan;
columnFlexibility[colIndex] = math.max(columnFlexibility[colIndex], flexibility);
columnFlexibility[colIndex] = math.max(
columnFlexibility[colIndex],
flexibility,
);
}
}
child = childParentData.nextSibling;
}

// Calculate total current width and adjust if needed
final totalColumnWidth = _columnWidths.reduce((a, b) => a + b);

if (totalColumnWidth > availableWidth) {
// Need to shrink columns - distribute reduction proportionally
final reduction = totalColumnWidth - availableWidth;

// Calculate shrink factors based on current widths
final totalWidth = _columnWidths.reduce((a, b) => a + b);
for (var i = 0; i < _columnCount; i++) {
Expand Down Expand Up @@ -490,9 +495,11 @@
final childHeight =
child.getMinIntrinsicHeight(cellWidth) / childParentData.rowSpan;
for (var i = 0; i < childParentData.rowSpan; i++) {
_rowHeights[childParentData.row + i] =
_rowHeights[childParentData.row + i]
.clamp(childHeight, double.infinity);
_rowHeights[childParentData.row +
i] = _rowHeights[childParentData.row + i].clamp(
childHeight,
double.infinity,
);
}
}
child = childParentData.nextSibling;
Expand Down Expand Up @@ -556,11 +563,13 @@
}

// Update final table size to include spacing
final tableWidth = _columnWidths.reduce((a, b) => a + b) +
(_columnCount - 1) * _columnSpacing +
final tableWidth =
_columnWidths.reduce((a, b) => a + b) +
(_columnCount - 1) * _columnSpacing +
_padding.horizontal;
final tableHeight = _rowHeights.reduce((a, b) => a + b) +
(_rowCount - 1) * _rowSpacing +
final tableHeight =
_rowHeights.reduce((a, b) => a + b) +
(_rowCount - 1) * _rowSpacing +
_padding.vertical;

size = constraints.constrain(Size(tableWidth, tableHeight));
Expand All @@ -571,12 +580,7 @@
// First paint the table background and borders
_border.paint(
context.canvas,
Rect.fromLTWH(
offset.dx,
offset.dy,
size.width,
size.height,
),
Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height),
rows: _rowCount,
columns: _columnCount,
cellData: _buildCellDataGrid(),
Expand Down Expand Up @@ -732,13 +736,17 @@
// Update minimum widths
for (var i = 0; i < childParentData.colSpan; i++) {
final colIndex = childParentData.column + i;
_columnWidths[colIndex] =
_columnWidths[colIndex].clamp(widthPerColumn, double.infinity);
_columnWidths[colIndex] = _columnWidths[colIndex].clamp(
widthPerColumn,
double.infinity,
);

// Track how flexible each column is based on content
final flexibility = (maxWidth - minWidth) / childParentData.colSpan;
columnFlexibility[colIndex] =
math.max(columnFlexibility[colIndex], flexibility);
columnFlexibility[colIndex] = math.max(
columnFlexibility[colIndex],
flexibility,
);
}
}
child = childParentData.nextSibling;
Expand All @@ -747,8 +755,10 @@
// Calculate total minimum width and distribute extra space
final totalMinWidth =
_columnWidths.reduce((a, b) => a + b) + _padding.horizontal;
final extraWidth =
(constraints.maxWidth - totalMinWidth).clamp(0.0, double.infinity);
final extraWidth = (constraints.maxWidth - totalMinWidth).clamp(
0.0,
double.infinity,
);

if (extraWidth > 0) {
// Calculate total flexibility
Expand Down Expand Up @@ -782,16 +792,17 @@
}

// Get the height needed for this width
final childHeight = child
final childHeight =
child
.getDryLayout(BoxConstraints.tightFor(width: cellWidth))
.height /
childParentData.rowSpan;
for (var i = 0; i < childParentData.rowSpan; i++) {
rowHeights[childParentData.row + i] =
rowHeights[childParentData.row + i]
.clamp(childHeight, double.infinity);
rowHeights[childParentData.row + i] = rowHeights[childParentData.row +
i]
.clamp(childHeight, double.infinity);
}
child = childParentData.nextSibling;
child = childParentData.nextSibling;
}
child = childParentData.nextSibling;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tagflow_table/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ homepage: https://docs.arya.run/tagflow
issue_tracker: https://github.com/devaryakjha/tagflow/issues

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">= 3.7.0 <4.0.0"

dependencies:
equatable: ^2.0.7
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: tagflow_workspace

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">= 3.7.0 <4.0.0"

dev_dependencies:
melos: ^6.2.0