65 lines
2.0 KiB
Dart
65 lines
2.0 KiB
Dart
// 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: 20,
|
|
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,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|