Frontend first draft
This commit is contained in:
63
frontend/pweb/lib/pages/report/table/widget.dart
Normal file
63
frontend/pweb/lib/pages/report/table/widget.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
// operations_table.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pshared/models/payment/operation.dart';
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
import 'package:pweb/pages/report/table/row.dart';
|
||||
|
||||
class OperationsTable extends StatelessWidget {
|
||||
final List<OperationItem> operations;
|
||||
final bool showFileNameColumn;
|
||||
|
||||
const OperationsTable({
|
||||
super.key,
|
||||
required this.operations,
|
||||
required this.showFileNameColumn,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
return Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: DataTable(
|
||||
columnSpacing: 24,
|
||||
headingTextStyle: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
columns: [
|
||||
DataColumn(label: Text(l10n.statusColumn)),
|
||||
DataColumn(label: Text(l10n.fileNameColumn)),
|
||||
DataColumn(label: Text(l10n.amountColumn)),
|
||||
DataColumn(label: Text(l10n.toAmountColumn)),
|
||||
DataColumn(label: Text(l10n.payIdColumn)),
|
||||
DataColumn(label: Text(l10n.cardNumberColumn)),
|
||||
DataColumn(label: Text(l10n.nameColumn)),
|
||||
DataColumn(label: Text(l10n.dateColumn)),
|
||||
DataColumn(label: Text(l10n.commentColumn)),
|
||||
],
|
||||
rows: List.generate(
|
||||
operations.length,
|
||||
(index) {
|
||||
final op = operations[index];
|
||||
// Alternate row colors
|
||||
final color = WidgetStateProperty.resolveWith<Color?>((states) {
|
||||
return index.isEven
|
||||
? Theme.of(context).colorScheme.surfaceContainerHighest
|
||||
: null;
|
||||
});
|
||||
|
||||
// Use the DataRow built by OperationRow and extract its cells
|
||||
final row = OperationRow.build(op, context);
|
||||
return DataRow.byIndex(
|
||||
index: index,
|
||||
color: color,
|
||||
cells: row.cells,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user