Files
fin-tracker/app/lib/features/imports/widgets/sample_events_table.dart
T
Dmitry 322c60a359 style(app): остальные экраны под новый визуальный язык и форматирование
Доходы, ребалансировка, налоги, импорт, цели, здоровье данных, правила, транзакции, категории, cashflow, pending: новые виджеты и токены темы, dart format. Тесты подстроены под новые модели.
2026-09-19 22:14:27 +03:00

89 lines
3.2 KiB
Dart

import 'package:flutter/material.dart';
import '../../../core/utils/ru_date.dart';
import '../../../core/widgets/money_text.dart';
import '../../portfolio/labels.dart' show eventKindLabels, formatQty;
import '../data/imports_api.dart';
/// The first lines of the report as the parser read them. A row already present in the
/// ledger (same `dedupe_key`) is marked: committing will update it, not add a second one.
class SampleEventsTable extends StatelessWidget {
const SampleEventsTable({required this.events, super.key});
final List<SampleEvent> events;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
columnSpacing: 20,
headingRowHeight: 36,
dataRowMinHeight: 36,
dataRowMaxHeight: 52,
columns: const [
DataColumn(label: Text('№')),
DataColumn(label: Text('Дата')),
DataColumn(label: Text('Тип')),
DataColumn(label: Text('Инструмент')),
DataColumn(label: Text('Кол-во')),
DataColumn(label: Text('Цена')),
DataColumn(label: Text('Сумма')),
DataColumn(label: Text('')),
],
rows: [
for (final e in events)
DataRow(
color: e.isDuplicate
? WidgetStatePropertyAll(
theme.colorScheme.surfaceContainerHighest.withValues(
alpha: 0.6,
),
)
: null,
cells: [
DataCell(Text('${e.lineNo}')),
DataCell(
Text(e.tradeDate == null ? '—' : ruDate(e.tradeDate!)),
),
DataCell(Text(eventKindLabels[e.kind] ?? e.kind)),
DataCell(
Tooltip(
message: e.instrumentKey ?? '',
child: Text(e.instrumentName ?? e.instrumentKey ?? '—'),
),
),
DataCell(
Text(e.quantity == null ? '—' : formatQty(e.quantity!)),
),
DataCell(Text(_money(e.price, e.currency))),
DataCell(Text(_money(e.amount, e.currency))),
DataCell(
e.isDuplicate
? Tooltip(
message: 'Такое событие уже есть в леджере',
child: Chip(
visualDensity: VisualDensity.compact,
label: const Text('дубль'),
backgroundColor: theme
.colorScheme
.secondaryContainer
.withValues(alpha: 0.8),
),
)
: const SizedBox.shrink(),
),
],
),
],
),
);
}
static String _money(String? value, String? currency) =>
value == null || value.isEmpty
? '—'
: MoneyText.format(value, currency ?? 'RUB');
}