import 'package:flutter/material.dart';

import 'package:pweb/models/dashboard/summary_values.dart';
import 'package:pweb/pages/dashboard/payouts/summary/fee.dart';
import 'package:pweb/pages/dashboard/payouts/summary/recipient_receives.dart';
import 'package:pweb/pages/dashboard/payouts/summary/row.dart';
import 'package:pweb/pages/dashboard/payouts/summary/total.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';

class PaymentSummary extends StatelessWidget {
  final double spacing;
  final PaymentSummaryValues? values;

  const PaymentSummary({super.key, required this.spacing, this.values});

  @override
  Widget build(BuildContext context) {
    final resolvedValues = values;
    if (resolvedValues != null) {
      final theme = Theme.of(context);
      final loc = AppLocalizations.of(context)!;
      return Align(
        alignment: Alignment.center,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            PaymentSummaryRow(
              labelFactory: loc.fee,
              money: null,
              value: resolvedValues.fee,
              style: theme.textTheme.titleMedium,
            ),
            PaymentSummaryRow(
              labelFactory: loc.recipientWillReceive,
              money: null,
              value: resolvedValues.recipientReceives,
              style: theme.textTheme.titleMedium,
            ),
            SizedBox(height: spacing),
            PaymentSummaryRow(
              labelFactory: loc.total,
              money: null,
              value: resolvedValues.total,
              style: theme.textTheme.titleMedium?.copyWith(
                fontWeight: FontWeight.w600,
              ),
            ),
          ],
        ),
      );
    }

    return Align(
      alignment: Alignment.center,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          const PaymentFeeRow(),
          const PaymentRecipientReceivesRow(),
          SizedBox(height: spacing),
          const PaymentTotalRow(),
        ],
      ),
    );
  }
}
