fixed report table

This commit is contained in:
ashrafzarkanisala
2024-09-02 21:23:31 +03:00
parent 7bbae2d332
commit 3017a5d1f6
4 changed files with 60 additions and 53 deletions

View File

@ -6,6 +6,8 @@ import 'package:syncrow_web/pages/device_managment/shared/table/table_header.dar
class ReportsTable extends StatelessWidget {
final DeviceReport report;
final String? thirdColumnTitle;
final String? thirdColumnDescription;
final Function(int index) onRowTap;
final VoidCallback onClose;
@ -14,6 +16,8 @@ class ReportsTable extends StatelessWidget {
required this.report,
required this.onRowTap,
required this.onClose,
this.thirdColumnTitle,
this.thirdColumnDescription,
});
@override
@ -32,33 +36,34 @@ class ReportsTable extends StatelessWidget {
children: [
TableRow(
decoration: BoxDecoration(color: Colors.grey.shade200),
children: const [
TableHeader(title: 'Date'),
TableHeader(title: 'Time'),
TableHeader(title: 'Status'),
children: [
const TableHeader(title: 'Date'),
const TableHeader(title: 'Time'),
TableHeader(title: thirdColumnTitle ?? 'Status'),
],
),
...report.data!.asMap().entries.map((entry) {
int index = entry.key;
DeviceEvent data = entry.value;
if (report.data != null)
...report.data!.asMap().entries.map((entry) {
int index = entry.key;
DeviceEvent data = entry.value;
// Parse eventTime into Date and Time
DateTime eventDateTime =
DateTime.fromMillisecondsSinceEpoch(data.eventTime!);
String date = DateFormat('dd/MM/yyyy').format(eventDateTime);
String time = DateFormat('HH:mm').format(eventDateTime);
// Parse eventTime into Date and Time
DateTime eventDateTime =
DateTime.fromMillisecondsSinceEpoch(data.eventTime!);
String date = DateFormat('dd/MM/yyyy').format(eventDateTime);
String time = DateFormat('HH:mm').format(eventDateTime);
return TableRow(
children: [
TableCellWidget(value: date),
TableCellWidget(value: time),
TableCellWidget(
value: data.value!,
onTap: () => onRowTap(index),
),
],
);
}).toList(),
return TableRow(
children: [
TableCellWidget(value: date),
TableCellWidget(value: time),
TableCellWidget(
value: '${data.value!} $thirdColumnDescription',
onTap: () => onRowTap(index),
),
],
);
}),
],
),
),