import 'package:flutter/material.dart';

import 'package:pshared/models/recipient/recipient.dart';

import 'package:pweb/pages/payout_page/send/widgets/section/title.dart';
import 'package:pweb/utils/dimensions.dart';

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


class SelectedRecipientCard extends StatelessWidget {
  final AppDimensions dimensions;
  final Recipient recipient;
  final VoidCallback onClear;

  const SelectedRecipientCard({
    super.key,
    required this.dimensions,
    required this.recipient,
    required this.onClear,
  });

  @override
  Widget build(BuildContext context) {
    final loc = AppLocalizations.of(context)!;
    final theme = Theme.of(context);

    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(dimensions.paddingMedium),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SectionTitle(loc.recipient),
          SizedBox(height: dimensions.paddingSmall),
          Row(
            children: [
              CircleAvatar(
                child: Text(recipient.name.substring(0, 1).toUpperCase()),
              ),
              SizedBox(width: dimensions.paddingMedium),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(recipient.name, style: theme.textTheme.titleMedium),
                    if (recipient.email.isNotEmpty)
                      Text(
                        recipient.email,
                        style: theme.textTheme.bodyMedium?.copyWith(
                          color: theme.colorScheme.onSurface,
                        ),
                      ),
                  ],
                ),
              ),
              TextButton(
                onPressed: onClear,
                child: Text(loc.chooseAnotherRecipient),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
