merged with dev and access_bugs and solved conflicts

This commit is contained in:
Abdullah Alassaf
2024-08-28 14:50:47 +03:00
30 changed files with 1326 additions and 1207 deletions

View File

@ -14,7 +14,6 @@ class DynamicTable extends StatefulWidget {
final void Function(bool?)? selectAll;
final void Function(int, bool, dynamic)? onRowSelected;
final List<String>? initialSelectedIds;
const DynamicTable({
super.key,
required this.headers,
@ -66,14 +65,11 @@ class _DynamicTableState extends State<DynamicTable> {
child: Column(
children: [
Container(
decoration: widget.headerDecoration ??
BoxDecoration(color: Colors.grey[200]),
decoration: widget.headerDecoration ?? BoxDecoration(color: Colors.grey[200]),
child: Row(
children: [
if (widget.withCheckBox) _buildSelectAllCheckbox(),
...widget.headers
.map((header) => _buildTableHeaderCell(header))
.toList(),
...widget.headers.map((header) => _buildTableHeaderCell(header)).toList(),
],
),
),
@ -97,8 +93,7 @@ class _DynamicTableState extends State<DynamicTable> {
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color: ColorsManager.grayColor),
.copyWith(color: ColorsManager.grayColor),
)
],
),
@ -118,12 +113,10 @@ class _DynamicTableState extends State<DynamicTable> {
return Row(
children: [
if (widget.withCheckBox)
_buildRowCheckbox(
index, widget.size.height * 0.10),
_buildRowCheckbox(index, widget.size.height * 0.10),
...row
.map((cell) => _buildTableCell(
cell.toString(),
widget.size.height * 0.10))
.map((cell) =>
_buildTableCell(cell.toString(), widget.size.height * 0.10))
.toList(),
],
);
@ -211,6 +204,27 @@ class _DynamicTableState extends State<DynamicTable> {
batteryLevel = double.tryParse(content.replaceAll('%', '').trim());
}
Color? statusColor;
switch (content) {
case 'Effective':
statusColor = ColorsManager.textGreen;
break;
case 'Expired':
statusColor = ColorsManager.red;
break;
case 'To be effective':
statusColor = ColorsManager.yaGreen;
break;
case 'Online':
statusColor = ColorsManager.green;
break;
case 'Offline':
statusColor = ColorsManager.red;
break;
default:
statusColor = Colors.black; // Default color
}
return Expanded(
child: Container(
height: size,
@ -227,16 +241,11 @@ class _DynamicTableState extends State<DynamicTable> {
child: Text(
content,
style: TextStyle(
color: batteryLevel != null && batteryLevel < 20
? ColorsManager.red // Red color for low battery
: content == 'Online'
? ColorsManager.green // Green color for Online
: content == 'Offline'
? ColorsManager.red // Red color for Offline
: Colors.black,
fontSize: 12,
fontWeight: FontWeight.w400,
),
color: batteryLevel != null && batteryLevel < 20
? ColorsManager.red
: statusColor, // Use the passed color or default to black
fontSize: 10,
fontWeight: FontWeight.w400),
),
),
);