import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'package:pweb/models/wallet.dart';
import 'package:pweb/pages/dashboard/buttons/balance/amount.dart';
import 'package:pweb/providers/wallets.dart';
import 'package:pweb/utils/currency.dart';


class WalletCard extends StatelessWidget {
  final Wallet wallet;
  final VoidCallback onTap;

  const WalletCard({super.key, required this.wallet, required this.onTap});

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    
    return Card(
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
      elevation: theme.cardTheme.elevation ?? 4,
      color: theme.colorScheme.onSecondary,
      child: InkWell(
        borderRadius: BorderRadius.circular(12),
        onTap: onTap,
        child: Container(
          padding: const EdgeInsets.only(left: 50, top: 16, bottom: 16),
          child: Row(
            spacing: 3,
            children: [
              CircleAvatar(
                radius: 24,
                child: Icon(iconForCurrencyType(wallet.currency), size: 28),
              ),
              const SizedBox(width: 16),
              Expanded(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    BalanceAmount(
                      wallet: wallet,
                      onToggleVisibility: () {
                        context.read<WalletsProvider>().toggleVisibility(wallet.id);
                      },
                    ),
                    Text(
                      wallet.name,
                      style: theme.textTheme.bodyLarge!.copyWith(fontWeight: FontWeight.w500),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}