@@ -436,17 +436,11 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
436436 return Checkbox (
437437 value: value.length == _filteredData.value.length && _filteredData.value.isNotEmpty,
438438 onChanged: (val) {
439- // print('BEFORE');
440- // print('Selected data: ${_selectedItems.value.length}');
441- // print(' Filtered data: ${_filteredData.value.length}');
442439 if (val == true ) {
443440 _selectedItems.value = .from (_filteredData.value);
444441 } else {
445442 _selectedItems.value = [];
446443 }
447- // debugPrint('AFTER');
448- // debugPrint('Selected data: ${_selectedItems.value.length}');
449- // debugPrint(' Filtered data: ${_filteredData.value.length}');
450444 },
451445 );
452446 },
@@ -467,6 +461,7 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
467461 itemBuilder: (context, index) {
468462 final ThemedColumn2 <T > entry = widget.columns[index];
469463 final bool isSelected = entry == _colSelected;
464+ double cellWidth = sizes[index]! - (index < widget.columns.length - 1 ? 1 : 0 );
470465
471466 return Row (
472467 children: [
@@ -480,38 +475,62 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
480475 _colSelected = entry;
481476 _isReversed = false ;
482477 }
483-
484478 _filterAndSort ('SORT' );
485479 },
486480 child: Container (
487- width: sizes[index] ! - (index < widget.columns.length - 1 ? 1 : 0 ) ,
481+ width: cellWidth ,
488482 padding: _padding,
489483 alignment: entry.alignment,
490- child: RichText (
491- text: TextSpan (
492- children: [
493- if (isSelected) ...[
494- WidgetSpan (
495- alignment: .middle,
496- child: Icon (
497- _isReversed
498- ? LayrzIcons .solarBoldSortFromBottomToTop
499- : LayrzIcons .solarBoldSortFromTopToBottom,
500- size: _sortIconSize,
501- color: Theme .of (context).textTheme.bodyMedium? .color,
502- ),
503- ),
504- const WidgetSpan (child: SizedBox (width: 5 )),
505- ],
506-
507- TextSpan (
508- text: entry.headerText,
509- style: Theme .of (
510- context,
511- ).textTheme.bodyMedium? .copyWith (fontWeight: .bold),
484+ child: Builder (
485+ builder: (context) {
486+ final double textWidth = cellWidth - (_padding.left + _padding.right);
487+
488+ // Fetch inline spans if richTextBuilder is provided, otherwise, use the header text
489+ final textOnlySpan = TextSpan (
490+ text: entry.headerText,
491+ style: Theme .of (
492+ context,
493+ ).textTheme.bodyMedium? .copyWith (fontWeight: FontWeight .bold),
494+ );
495+ // Calculate if the text overflows the available width
496+ final textPainter = TextPainter (
497+ text: textOnlySpan,
498+ maxLines: 1 ,
499+ textDirection: Directionality .of (context),
500+ )..layout (maxWidth: textWidth);
501+
502+ final bool isOverflowing = textPainter.didExceedMaxLines;
503+ // Widget to display the header text
504+ final richText = RichText (
505+ maxLines: 1 ,
506+ overflow: TextOverflow .ellipsis,
507+ text: TextSpan (
508+ children: [
509+ if (isSelected)
510+ WidgetSpan (
511+ alignment: PlaceholderAlignment .middle,
512+ child: Icon (
513+ _isReversed
514+ ? LayrzIcons .solarBoldSortFromBottomToTop
515+ : LayrzIcons .solarBoldSortFromTopToBottom,
516+ size: _sortIconSize,
517+ color: Theme .of (context).textTheme.bodyMedium? .color,
518+ ),
519+ ),
520+ if (isSelected) const WidgetSpan (child: SizedBox (width: 5 )),
521+ textOnlySpan,
522+ ],
512523 ),
513- ],
514- ),
524+ );
525+ // If richTextBuilder is provided, use it to build the header content, otherwise, use the header text
526+ return isOverflowing
527+ ? ThemedTooltip (
528+ position: .top,
529+ message: entry.headerText,
530+ child: richText,
531+ )
532+ : richText;
533+ },
515534 ),
516535 ),
517536 ),
@@ -817,6 +836,25 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
817836 );
818837 }
819838
839+ Widget buildHeaderCell (String text, TextStyle style, double maxWidth) {
840+ final textPainter = TextPainter (
841+ text: TextSpan (text: text, style: style),
842+ maxLines: 1 ,
843+ textDirection: TextDirection .ltr,
844+ )..layout (maxWidth: maxWidth);
845+
846+ final isOverflowing = textPainter.didExceedMaxLines;
847+
848+ final child = Text (
849+ text,
850+ style: style,
851+ maxLines: 1 ,
852+ overflow: TextOverflow .ellipsis,
853+ );
854+
855+ return isOverflowing ? ThemedTooltip (position: ThemedTooltipPosition .top, message: text, child: child) : child;
856+ }
857+
820858 void _onSearchChanged (String value) {
821859 _debounce? .cancel ();
822860 _debounce = Timer (const Duration (milliseconds: 600 ), () {
0 commit comments