@@ -37,6 +37,23 @@ class ThemedTable2<T> extends StatefulWidget {
3737 /// [minColumnWidth] sets the minimum width for each column when calculating flexible widths.
3838 final double minColumnWidth;
3939
40+ /// [multiSelectionTitleText] replaces the text of the multi selection title.
41+ /// This property only will work when `LayrzAppLocalizations` is null.
42+ final String multiSelectionTitleText;
43+
44+ /// [multiSelectionContentText] replaces the text of the multi selection content.
45+ /// This property only will work when `LayrzAppLocalizations` is null.
46+ final String multiSelectionContentText;
47+
48+ /// [multiSelectionCancelLabelText] replaces the text of the multi selection cancel button.
49+ /// This property only will work when `LayrzAppLocalizations` is null.
50+ final String multiSelectionCancelLabelText;
51+
52+ /// [multiselectActions] is a list of action buttons that will be shown when one or more items are selected.
53+ ///
54+ /// Consider that the list will be appened with the clear button
55+ final List <ThemedActionButton > multiselectActions;
56+
4057 const ThemedTable2 ({
4158 required this .items,
4259 required this .columns,
@@ -50,6 +67,10 @@ class ThemedTable2<T> extends StatefulWidget {
5067 this .loadingLabelText = "Computing data, please wait..." ,
5168 this .canSearch = true ,
5269 this .minColumnWidth = 250 ,
70+ this .multiselectActions = const [],
71+ this .multiSelectionTitleText = "Multiple items selected" ,
72+ this .multiSelectionContentText = "You have selected multiple items. What do you want to do?" ,
73+ this .multiSelectionCancelLabelText = "Clear" ,
5374 }) : assert (columns.length > 0 , 'Columns cant be empty' );
5475
5576 @override
@@ -104,9 +125,6 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
104125 /// [_filteredData] holds the filtered and sorted data currently displayed in the table.
105126 List <T > _filteredData = [];
106127
107- /// [_sortedData] holds the sorted data currently displayed in the table.
108- List <T > _sortedData = [];
109-
110128 /// [_itemsStrings] holds a precomputed list of string representations of the items for efficient searching.
111129 Map <int , Map <int , String >> _itemsStrings = {};
112130
@@ -119,6 +137,9 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
119137 /// [isReversed] indicates whether the current sort order is descending (true) or ascending (false).
120138 bool isReversed = false ;
121139
140+ /// [_shouldShowActions] indicates whether action buttons should be shown based on selection state.
141+ bool _shouldShowActions = false ;
142+
122143 @override
123144 void initState () {
124145 super .initState ();
@@ -256,6 +277,8 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
256277 } else {
257278 _selected = [];
258279 }
280+
281+ _shouldShowActions = _selected.isNotEmpty;
259282 setState (() {});
260283 },
261284 ),
@@ -393,6 +416,8 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
393416 } else {
394417 if (_selected.contains (index)) _selected.remove (index);
395418 }
419+
420+ _shouldShowActions = _selected.isNotEmpty;
396421 setState (() {});
397422 },
398423 ),
@@ -513,6 +538,55 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
513538 ],
514539 ),
515540 ),
541+
542+ // /Content
543+ // Actions
544+ if (_shouldShowActions) ...[
545+ Container (
546+ width: double .infinity,
547+ margin: const EdgeInsets .all (5 ),
548+ padding: const EdgeInsets .all (10 ),
549+ decoration: BoxDecoration (
550+ color: Theme .of (context).inputDecorationTheme.fillColor,
551+ borderRadius: BorderRadius .circular (8 ),
552+ ),
553+ child: Column (
554+ children: [
555+ Text (
556+ widget.multiSelectionTitleText,
557+ style: Theme .of (context).textTheme.bodyLarge? .copyWith (fontWeight: FontWeight .bold),
558+ maxLines: 1 ,
559+ ),
560+ Text (
561+ widget.multiSelectionContentText,
562+ maxLines: 1 ,
563+ ),
564+ const SizedBox (height: 10 ),
565+ Center (
566+ child: SingleChildScrollView (
567+ child: Row (
568+ mainAxisAlignment: MainAxisAlignment .center,
569+ crossAxisAlignment: CrossAxisAlignment .center,
570+ children: [
571+ ThemedButton (
572+ labelText: widget.multiSelectionCancelLabelText,
573+ color: Colors .orange,
574+ icon: LayrzIcons .solarOutlineEraser,
575+ onTap: () {
576+ _selected = [];
577+ _shouldShowActions = false ;
578+ setState (() {});
579+ },
580+ ),
581+ ],
582+ ),
583+ ),
584+ ),
585+ ],
586+ ),
587+ ),
588+ ],
589+ // /Actions
516590 ],
517591 );
518592 },
0 commit comments