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
206 changes: 105 additions & 101 deletions packages/tagflow/CHANGELOG.md

Large diffs are not rendered by default.

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 @@ class _RenderSelectableAdapter extends RenderProxyBox
_geometry.dispose();
super.dispose();
}

@override
int get contentLength => 1;

@override
SelectedContentRange? getSelection() {
if (!value.hasSelection) {
return null;
}
return const SelectedContentRange(startOffset: 0, endOffset: 1);
}
}
4 changes: 2 additions & 2 deletions packages/tagflow/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: tagflow
description: Transform HTML markup into native Flutter widgets with an elegant, customizable converter.
version: 0.0.1+1
version: 0.0.2+1
repository: https://github.com/devaryakjha/tagflow
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
54 changes: 29 additions & 25 deletions packages/tagflow_table/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
## 0.0.4

- Update flutter version to 3.29.2

## 0.0.3

- Graduate package to a stable release. See pre-releases prior to this version for changelog entries.
- Graduate package to a stable release. See pre-releases prior to this version for changelog entries.

## 0.0.3-dev.0

- **FEAT**(tagflow_table): add column and row spacing properties to TagflowTable. ([66989cf5](https://github.com/devaryakjha/tagflow/commit/66989cf5e67805c2b472dcfccd9bed84158fdf8d))
- **FEAT**(tagflow_table): add column and row spacing properties to TagflowTable. ([66989cf5](https://github.com/devaryakjha/tagflow/commit/66989cf5e67805c2b472dcfccd9bed84158fdf8d))

## 0.0.2+1

- Graduate package to a stable release. See pre-releases prior to this version for changelog entries.
- Graduate package to a stable release. See pre-releases prior to this version for changelog entries.

## 0.0.2-dev.0+1

- Update a dependency to the latest release.
- Update a dependency to the latest release.

## 0.0.2

- Graduate package to a stable release. See pre-releases prior to this version for changelog entries.
- Update a dependency to the latest release.
- Graduate package to a stable release. See pre-releases prior to this version for changelog entries.
- Update a dependency to the latest release.

## 0.0.2-dev.6

- Update a dependency to the latest release.
- Update a dependency to the latest release.

## 0.0.2-dev.5

- **FEAT**(tagflow_table): enhance column width calculation for flexible layouts. ([4c0e3d77](https://github.com/devaryakjha/tagflow/commit/4c0e3d7757b8db5d0e8a33c0b2df29c0f005baad))
- **FEAT**(tagflow_table): enhance column width calculation for flexible layouts. ([4c0e3d77](https://github.com/devaryakjha/tagflow/commit/4c0e3d7757b8db5d0e8a33c0b2df29c0f005baad))

## 0.0.2-dev.4

- **FIX**(tagflow_table): correct separator layout width calculation. ([a4d777f9](https://github.com/devaryakjha/tagflow/commit/a4d777f9d3b4effcaf553f9bb20dc0c14b7c7c6d))
- **FIX**(tagflow_table): correct separator layout width calculation. ([a4d777f9](https://github.com/devaryakjha/tagflow/commit/a4d777f9d3b4effcaf553f9bb20dc0c14b7c7c6d))

## 0.0.2-dev.3

- **FEAT**(tagflow_table): enhance table rendering with header support and separators. ([d8307c06](https://github.com/devaryakjha/tagflow/commit/d8307c06bcb73e07f74a0cc5d0d5305ef1c8f1e9))
- **FEAT**(tagflow_table): enhance table rendering with header support and separators. ([d8307c06](https://github.com/devaryakjha/tagflow/commit/d8307c06bcb73e07f74a0cc5d0d5305ef1c8f1e9))

## 0.0.2-dev.2

- **REFACTOR**(tagflow_table): relaxed dart SDK constraints. ([5cba3f98](https://github.com/devaryakjha/tagflow/commit/5cba3f98a0eef120a79ca4da7ae8094abecadba5))
- **REFACTOR**(tagflow_table): relaxed dart SDK constraints. ([5cba3f98](https://github.com/devaryakjha/tagflow/commit/5cba3f98a0eef120a79ca4da7ae8094abecadba5))

## 0.0.2-dev.1

- **REFACTOR**(tagflow_table): relaxed dart SDK constraints. ([5cba3f98](https://github.com/devaryakjha/tagflow/commit/5cba3f98a0eef120a79ca4da7ae8094abecadba5))
- **REFACTOR**(tagflow_table): relaxed dart SDK constraints. ([5cba3f98](https://github.com/devaryakjha/tagflow/commit/5cba3f98a0eef120a79ca4da7ae8094abecadba5))

## 0.0.2-dev.0

- **REFACTOR**(tagflow_table): improve empty cell handling in TagflowTableConverter. ([2cd288ec](https://github.com/devaryakjha/tagflow/commit/2cd288ecde7af366e0242aa555a60520dc285ebc))
- **FIX**(converter): update table border style to none for improved layout consistency. ([40b1ea62](https://github.com/devaryakjha/tagflow/commit/40b1ea621b0911bbce6eabb501c0e784fed3eb3c))
- **FEAT**(docs): add contributing guidelines and enhance README structure. ([579ec3d6](https://github.com/devaryakjha/tagflow/commit/579ec3d695b2af1811dff3ef52d53f9b677001e5))
- **FEAT**(tests): add comprehensive tests for TagflowTable and related components. ([219c0606](https://github.com/devaryakjha/tagflow/commit/219c0606ff3deb6c0e8c5be15fb1c14ce1cf2d49))
- **FEAT**(tagflow_table): integrate Equatable for TagflowTableBorder and update dependencies. ([05aa0b56](https://github.com/devaryakjha/tagflow/commit/05aa0b56df24a4360ed1c6b814a8d049432a50f5))
- **FEAT**(tagflow_table): add HTML parsing tests and update dependencies. ([cd8e68de](https://github.com/devaryakjha/tagflow/commit/cd8e68ded76dedb6173742679cb7185aa485ce59))
- **FEAT**(table_example,table_converter,table_parser): add support for table captions and enhance rendering. ([76ee33fb](https://github.com/devaryakjha/tagflow/commit/76ee33fbfd4369a19a3908e57d8747770f064388))
- **FEAT**(tagflow_table,table_example): add TagflowTableCellConverter and enhance table rendering. ([b1e32d9c](https://github.com/devaryakjha/tagflow/commit/b1e32d9cb3733fe8466b7c6f9097e82982436d4b))
- **FEAT**(table_example,tagflow_table): enhance table examples and rendering logic. ([ab226159](https://github.com/devaryakjha/tagflow/commit/ab226159fc4d07d88b0a8359bb3537a7d3891bb3))
- **FEAT**(table_example): enhance table examples with new HTML structures and rendering improvements. ([89b191bf](https://github.com/devaryakjha/tagflow/commit/89b191bfdd0a89bf710be451cc6cc4c4def6b82c))
- **FEAT**(tagflow_table): implement table rendering and conversion logic. ([d8e82f4d](https://github.com/devaryakjha/tagflow/commit/d8e82f4d2f1d01a17b4d43f9e6f6a0704e6e7a67))
- **FEAT**(tagflow_table): initial project setup with essential files. ([3db0ea81](https://github.com/devaryakjha/tagflow/commit/3db0ea815c2448bfa048d54bd61c235a3c29e802))
- **REFACTOR**(tagflow_table): improve empty cell handling in TagflowTableConverter. ([2cd288ec](https://github.com/devaryakjha/tagflow/commit/2cd288ecde7af366e0242aa555a60520dc285ebc))
- **FIX**(converter): update table border style to none for improved layout consistency. ([40b1ea62](https://github.com/devaryakjha/tagflow/commit/40b1ea621b0911bbce6eabb501c0e784fed3eb3c))
- **FEAT**(docs): add contributing guidelines and enhance README structure. ([579ec3d6](https://github.com/devaryakjha/tagflow/commit/579ec3d695b2af1811dff3ef52d53f9b677001e5))
- **FEAT**(tests): add comprehensive tests for TagflowTable and related components. ([219c0606](https://github.com/devaryakjha/tagflow/commit/219c0606ff3deb6c0e8c5be15fb1c14ce1cf2d49))
- **FEAT**(tagflow_table): integrate Equatable for TagflowTableBorder and update dependencies. ([05aa0b56](https://github.com/devaryakjha/tagflow/commit/05aa0b56df24a4360ed1c6b814a8d049432a50f5))
- **FEAT**(tagflow_table): add HTML parsing tests and update dependencies. ([cd8e68de](https://github.com/devaryakjha/tagflow/commit/cd8e68ded76dedb6173742679cb7185aa485ce59))
- **FEAT**(table_example,table_converter,table_parser): add support for table captions and enhance rendering. ([76ee33fb](https://github.com/devaryakjha/tagflow/commit/76ee33fbfd4369a19a3908e57d8747770f064388))
- **FEAT**(tagflow_table,table_example): add TagflowTableCellConverter and enhance table rendering. ([b1e32d9c](https://github.com/devaryakjha/tagflow/commit/b1e32d9cb3733fe8466b7c6f9097e82982436d4b))
- **FEAT**(table_example,tagflow_table): enhance table examples and rendering logic. ([ab226159](https://github.com/devaryakjha/tagflow/commit/ab226159fc4d07d88b0a8359bb3537a7d3891bb3))
- **FEAT**(table_example): enhance table examples with new HTML structures and rendering improvements. ([89b191bf](https://github.com/devaryakjha/tagflow/commit/89b191bfdd0a89bf710be451cc6cc4c4def6b82c))
- **FEAT**(tagflow_table): implement table rendering and conversion logic. ([d8e82f4d](https://github.com/devaryakjha/tagflow/commit/d8e82f4d2f1d01a17b4d43f9e6f6a0704e6e7a67))
- **FEAT**(tagflow_table): initial project setup with essential files. ([3db0ea81](https://github.com/devaryakjha/tagflow/commit/3db0ea815c2448bfa048d54bd61c235a3c29e802))

## 0.0.1

* TODO: Describe initial release.
- TODO: Describe initial release.
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 @@ class TagflowTableBorder extends Equatable {
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 @@ class TagflowTableBorder extends Equatable {
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);
}

// Paint outer borders
Expand Down Expand Up @@ -216,8 +211,10 @@ class TagflowTableBorder extends Equatable {

// 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 @@ class TagflowTableBorder extends Equatable {
@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 @@ class RenderTagflowTable extends RenderBox

// 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 @@ class RenderTagflowTable extends RenderBox
// 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 @@ class RenderTagflowTable extends RenderBox
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 @@ class RenderTagflowTable extends RenderBox
}

// 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 @@ class RenderTagflowTable extends RenderBox
// 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 @@ class RenderTagflowTable extends RenderBox
// 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 @@ class RenderTagflowTable extends RenderBox
// 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 @@ class RenderTagflowTable extends RenderBox
}

// 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
6 changes: 3 additions & 3 deletions packages/tagflow_table/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: tagflow_table
description: A pluggable package for tagflow to add support for advanced HTML tables.
version: 0.0.3
version: 0.0.4
repository: https://github.com/devaryakjha/tagflow
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
flutter:
sdk: flutter
tagflow: ^0.0.1+1
tagflow: ^0.0.2+1

dev_dependencies:
flutter_test:
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
Loading