From d57dfac4df93c651cabe68958e9f2180dccac70c Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Thu, 1 Feb 2024 21:46:15 +0530 Subject: [PATCH] implemented the collapsable table --- .../bill_generation_details_provider.dart | 3 +- .../widgets/count_table_widget.dart | 41 ++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/frontend/mgramseva/lib/providers/bill_generation_details_provider.dart b/frontend/mgramseva/lib/providers/bill_generation_details_provider.dart index f6a82d062..16dc0647e 100644 --- a/frontend/mgramseva/lib/providers/bill_generation_details_provider.dart +++ b/frontend/mgramseva/lib/providers/bill_generation_details_provider.dart @@ -374,7 +374,8 @@ class BillGenerationProvider with ChangeNotifier { FittedBox( child: DataTable( border: TableBorder.all( - width: 0.5, borderRadius: BorderRadius.all(Radius.circular(5))), columns: [ + width: 0.5, borderRadius: BorderRadius.all(Radius.circular(5)), + color: Colors.grey,), columns: [ DataColumn( label: Text( "${ApplicationLocalizations.of(context).translate(i18.searchWaterConnection.CONNECTION_TYPE)}", diff --git a/frontend/mgramseva/lib/screeens/generate_bill/widgets/count_table_widget.dart b/frontend/mgramseva/lib/screeens/generate_bill/widgets/count_table_widget.dart index d00b0d065..c1be7e756 100644 --- a/frontend/mgramseva/lib/screeens/generate_bill/widgets/count_table_widget.dart +++ b/frontend/mgramseva/lib/screeens/generate_bill/widgets/count_table_widget.dart @@ -63,16 +63,26 @@ class _CountTableWidgetState extends State { Widget _buildDataTable(List connectionCount) { return DataTable( border: TableBorder.all( - width: 0.5, borderRadius: BorderRadius.all(Radius.circular(5))), + width: 0.5, + borderRadius: BorderRadius.all(Radius.circular(5)), + color: Colors.grey, // Set border color to grey + ),// Set heading row background color to grey + headingTextStyle: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), // Set heading text color to black and bold columns: [ DataColumn( - label: FittedBox( - child: Text( - "${ApplicationLocalizations.of(context).translate(i18.common.LAST_BILL_CYCLE_MONTH)}"))), + label: FittedBox( + child: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.LAST_BILL_CYCLE_MONTH)}", + ), + ), + ), DataColumn( - label: FittedBox( - child: Text( - "${ApplicationLocalizations.of(context).translate(i18.common.CONSUMER_COUNT)}"))) + label: FittedBox( + child: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.CONSUMER_COUNT)}", + ), + ), + ) ], rows: _isCollapsed ? connectionCount.take(5).map((e) => _buildDataRow(e)).toList() @@ -81,11 +91,22 @@ class _CountTableWidgetState extends State { } DataRow _buildDataRow(WaterConnectionCount count) { + final bool isEvenRow = widget.waterConnectionCount!.indexOf(count) % 2 == 0; + final Color? rowColor = isEvenRow ? Colors.grey[100] : Colors.white; // Set alternate row background color to grey + return DataRow( + color: MaterialStateColor.resolveWith((states) => rowColor!), // Apply alternate row background color cells: [ - DataCell(Text(DateFormats.getMonthAndYearFromDateTime( - DateTime.fromMillisecondsSinceEpoch(count.taxperiodto!)))), - DataCell(Text(count.count.toString())), + DataCell( + Text( + DateFormats.getMonthAndYearFromDateTime( + DateTime.fromMillisecondsSinceEpoch(count.taxperiodto!), + ), + ), + ), + DataCell( + Text(count.count.toString()), + ), ], ); }