import 'package:flutter/material.dart';

import 'package:pweb/pages/report/charts/payout_volumes/aggregator.dart';
import 'package:pweb/pages/report/charts/payout_volumes/palette.dart';
import 'package:pweb/utils/report/format.dart';


class PayoutTotalsList extends StatelessWidget {
  final List<CurrencyTotal> totals;

  const PayoutTotalsList({super.key, required this.totals});

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final palette = payoutVolumesPalette(theme);

    return SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          for (var index = 0; index < totals.length; index++)
            Padding(
              padding: EdgeInsets.only(
                bottom: index == totals.length - 1 ? 0 : 8,
              ),
              child: Row(
                children: [
                  Icon(
                    Icons.circle,
                    size: 10,
                    color: palette[index % palette.length],
                  ),
                  const SizedBox(width: 6),
                  Expanded(
                    child: Text(
                      totals[index].currency,
                      style: theme.textTheme.bodySmall,
                      overflow: TextOverflow.ellipsis,
                    ),
                  ),
                  const SizedBox(width: 8),
                  Text(
                    formatAmount(
                      context,
                      totals[index].amount,
                      totals[index].currency,
                    ),
                    style: theme.textTheme.bodySmall?.copyWith(
                      fontWeight: FontWeight.w600,
                    ),
                  ),
                ],
              ),
            ),
        ],
      ),
    );
  }
}
