import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

import 'package:pshared/models/payment/wallet.dart';
import 'package:pshared/provider/payment/wallets.dart';

import 'package:pweb/pages/payout_page/wallet/card.dart';


class WalletWidgets extends StatelessWidget {
  final void Function(Wallet) onWalletTap;

  const WalletWidgets({super.key, required this.onWalletTap});

  @override
  Widget build(BuildContext context) {
    final provider = context.watch<WalletsProvider>();

    final wallets = provider.wallets;

    return GridView.builder(
      scrollDirection: Axis.vertical,
      physics: AlwaysScrollableScrollPhysics(),
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
        mainAxisSpacing: 12,
        crossAxisSpacing: 12,
        childAspectRatio: 3,
      ),
      itemCount: wallets.length,
      itemBuilder: (context, index) {
        final wallet = wallets[index];
        return Padding(
          padding: const EdgeInsets.symmetric(vertical: 6.0),
          child: WalletCard(
            wallet: wallet,
            onTap: () => onWalletTap(wallet),
          ),
        );
      },
    );
  }
}