import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/constant/colors.dart';
import 'package:ride/constant/style.dart';
import 'package:ride/controller/home/payment/captain_wallet_controller.dart';
import 'package:ride/controller/payment/payment_controller.dart';

class PointsCaptain extends StatelessWidget {
  PaymentController paymentController = Get.put(PaymentController());
  CaptainWalletController captainWalletController =
      Get.put(CaptainWalletController());

  PointsCaptain({
    super.key,
    required this.kolor,
    required this.countPoint,
    required this.pricePoint,
  });
  final Color kolor;
  final String countPoint;
  int pricePoint;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () async {
        await paymentController.makePaymentStripe(pricePoint, 'USD', () async {
          await captainWalletController.addDriverPayment('visa', pricePoint);
          await captainWalletController.addDriverWallet('visa', countPoint);
          await captainWalletController.getCaptainWalletFromBuyPoints();
        });
      },
      child: Container(
          width: Get.width * .2,
          height: Get.width * .2,
          margin: const EdgeInsets.all(4),
          decoration: BoxDecoration(
            color: kolor,
            border: Border.all(color: AppColor.accentColor),
            borderRadius: BorderRadius.circular(12),
            shape: BoxShape.rectangle,
          ),
          child: Center(
            child: Column(
              children: [
                Text(
                  '$countPoint Point',
                  style: AppStyle.subtitle,
                ),
                Text(
                  '$pricePoint\$',
                  style: AppStyle.title,
                ),
              ],
            ),
          )),
    );
  }
}
