import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

import 'package:pshared/controllers/payment/source.dart';

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


class WalletEditHeader extends StatelessWidget {
  const WalletEditHeader({super.key});

  @override
  Widget build(BuildContext context) {
    final controller = context.watch<PaymentSourceController>();
    final wallet = controller.selectedWallet;
    final ledger = controller.selectedLedgerAccount;
    final loc = AppLocalizations.of(context)!;

    if (wallet == null && ledger == null) {
      return const SizedBox.shrink();
    }

    final theme = Theme.of(context);
    final title = wallet != null
        ? loc.paymentTypeCryptoWallet
        : loc.paymentTypeLedger;
    final subtitle = wallet?.tokenSymbol;

    return Row(
      spacing: 8,
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            spacing: 4,
            children: [
              Text(
                title,
                style: theme.textTheme.headlineMedium?.copyWith(
                  fontWeight: FontWeight.bold,
                ),
              ),
              if (subtitle != null && subtitle.trim().isNotEmpty)
                Text(
                  subtitle,
                  style: theme.textTheme.bodyMedium?.copyWith(
                    color: theme.colorScheme.onSurfaceVariant,
                  ),
                ),
            ],
          ),
        ),
      ],
    );
  }
}
