import 'package:flutter/material.dart';
import 'package:pweb/models/wallet.dart';
import 'package:pweb/utils/currency.dart';


class BalanceAmount extends StatelessWidget {
  final Wallet wallet;
  final VoidCallback onToggleVisibility;

  const BalanceAmount({
    super.key,
    required this.wallet,
    required this.onToggleVisibility,
  });

  static const double _iconSpacing = 12.0;
  static const double _iconSize = 24.0;

  @override
  Widget build(BuildContext context) {
    final textTheme = Theme.of(context).textTheme;
    final colorScheme = Theme.of(context).colorScheme;
    final currencyBalance = currencyCodeToSymbol(wallet.currency);

    return Row(
      children: [
        Text(
          wallet.isHidden ? '•••• $currencyBalance' : '${wallet.balance.toStringAsFixed(2)} $currencyBalance',
          style: textTheme.headlineSmall?.copyWith(
            fontWeight: FontWeight.bold,
            color: colorScheme.onSurface,
          ),
        ),
        const SizedBox(width: _iconSpacing),
        GestureDetector(
          onTap: onToggleVisibility,
          child: Icon(
            wallet.isHidden ? Icons.visibility_off : Icons.visibility,
            size: _iconSize,
            color: colorScheme.onSurface,
          ),
        ),
      ],
    );
  }
}