import 'package:flutter/material.dart';

import 'package:pshared/models/payment/chain_network.dart';
import 'package:pshared/utils/l10n/chain.dart';

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

class BalanceHeader extends StatelessWidget {
  final ChainNetwork? walletNetwork;
  final String? tokenSymbol;

  const BalanceHeader({
    super.key,
    this.walletNetwork,
    this.tokenSymbol,
  });

  @override
  Widget build(BuildContext context) {
    final textTheme = Theme.of(context).textTheme;
    final colorScheme = Theme.of(context).colorScheme;
    final loc = AppLocalizations.of(context)!;
    final symbol = tokenSymbol?.trim();
    final networkLabel = (walletNetwork == null || walletNetwork == ChainNetwork.unspecified)
        ? null
        : walletNetwork!.localizedName(context);

    return Row(
      children: [
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                loc.paymentTypeCryptoWallet,
                style: textTheme.titleMedium?.copyWith(
                  color: colorScheme.onSurface,
                ),
              ),
              if (networkLabel != null)
                Text(
                  networkLabel,
                  style: textTheme.bodySmall?.copyWith(
                    color: colorScheme.onSurfaceVariant,
                    fontWeight: FontWeight.w500,
                  ),
                ),
            ],
          ),
        ),
        if (symbol != null && symbol.isNotEmpty) ...[
          const SizedBox(width: 8),
          Container(
            padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
            decoration: BoxDecoration(
              color: colorScheme.primaryContainer,
              borderRadius: BorderRadius.circular(999),
            ),
            child: Text(
              symbol,
              style: textTheme.bodyMedium?.copyWith(
                color: colorScheme.onPrimaryContainer,
                fontWeight: FontWeight.w600,
              ),
            ),
          ),
        ],
      ],
    );
  }
}
