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

import 'package:pshared/models/ledger/account.dart';
import 'package:pshared/models/payment/wallet.dart';

import 'package:pweb/controllers/dashboard/balance/carousel.dart';
import 'package:pweb/pages/dashboard/buttons/balance/carousel/card_item.dart';


class BalanceCarouselCardsView extends StatelessWidget {
  final BalanceCarouselController controller;
  final ValueChanged<Wallet> onTopUp;
  final ValueChanged<LedgerAccount> onLedgerAddFunds;
  final ValueChanged<Wallet> onWalletTap;
  final ValueChanged<LedgerAccount> onLedgerTap;
  final double height;

  const BalanceCarouselCardsView({
    super.key,
    required this.controller,
    required this.onTopUp,
    required this.onLedgerAddFunds,
    required this.onWalletTap,
    required this.onLedgerTap,
    required this.height,
  });

  @override
  Widget build(BuildContext context) {
    final scrollBehavior = ScrollConfiguration.of(context).copyWith(
      dragDevices: const {
        PointerDeviceKind.touch,
        PointerDeviceKind.mouse,
        PointerDeviceKind.trackpad,
      },
    );

    return SizedBox(
      height: height,
      child: MouseRegion(
        cursor: SystemMouseCursors.grab,
        child: ScrollConfiguration(
          behavior: scrollBehavior,
          child: PageView.builder(
            controller: controller.pageController,
            onPageChanged: controller.onPageChanged,
            itemCount: controller.items.length,
            itemBuilder: (context, index) => BalanceCarouselCardItem(
              item: controller.items[index],
              onTopUp: onTopUp,
              onLedgerAddFunds: onLedgerAddFunds,
              onWalletTap: onWalletTap,
              onLedgerTap: onLedgerTap,
            ),
          ),
        ),
      ),
    );
  }
}
