import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/constant/box_name.dart';
import 'package:ride/constant/style.dart';

import '../../../constant/colors.dart';
import '../../../controller/home/map_passenger_controller.dart';
import '../../../controller/payment/payment_controller.dart';
import '../../../main.dart';

class CashConfirmPageShown extends StatelessWidget {
  const CashConfirmPageShown({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MapPassengerController>(
        builder: (controller) => Positioned(
              right: 5,
              bottom: 5,
              left: 5,
              child: AnimatedContainer(
                duration: const Duration(milliseconds: 400),
                height: controller.isCashConfirmPageShown
                    ? controller.cashConfirmPageShown
                    : 0,
                decoration: BoxDecoration(
                    color: AppColor.secondaryColor,
                    borderRadius: BorderRadius.circular(15)),
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 20),
                  child: Column(
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            'Payment Method'.tr,
                            style: AppStyle.title.copyWith(fontSize: 22),
                          ),
                          IconButton(
                            onPressed: () =>
                                controller.changeCashConfirmPageShown(),
                            icon: const Icon(Icons.close),
                          ),
                        ],
                      ),
                      GetBuilder<PaymentController>(
                        builder: (paymentController) => Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            const Icon(
                              Icons.wallet_outlined,
                              size: 25,
                              color: AppColor.redColor,
                            ),
                            const SizedBox(
                              width: 20,
                            ),
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text(
                                  'Ride Wallet'.tr,
                                  style: AppStyle.title,
                                ),
                                Text(
                                  // '${'Your Wallet balance is '.tr}JD ',
                                  '${'Your Wallet balance is '.tr} ${box.read(BoxName.passengerWalletTotal).toString()} JD',
                                  style: AppStyle.subtitle,
                                ),
                              ],
                            ),
                            const Spacer(),
                            Checkbox.adaptive(
                              value: paymentController.isWalletChecked,
                              onChanged: (value) {
                                paymentController
                                    .onChangedPaymentMethodWallet(value);
                              },
                            )
                          ],
                        ),
                      ),
                      const Divider(
                        color: AppColor.accentColor,
                        thickness: 1,
                        height: 2,
                        indent: 1,
                      ),
                      Row(
                        children: [
                          Icon(
                            Icons.monetization_on,
                            color: Colors.green[400],
                          ),
                          const SizedBox(
                            width: 20,
                          ),
                          InkWell(
                            onTap: () =>
                                controller.changeCashConfirmPageShown(),
                            child: Text(
                              'CASH',
                              style: AppStyle.title,
                            ),
                          ),
                          const Spacer(),
                          GetBuilder<PaymentController>(
                              builder: (controller) => Checkbox.adaptive(
                                    value: controller.isCashChecked,
                                    onChanged: (value) {
                                      controller
                                          .onChangedPaymentMethodCash(value);
                                    },
                                  ))
                        ],
                      ),
                      const Divider(
                        color: AppColor.accentColor,
                        thickness: 1,
                        height: 2,
                        indent: 1,
                      ),
                      // controller.cardNumber == null ||
                      //         controller.cardNumber!.isEmpty
                      //     ? MyElevatedButton(
                      //         title: 'Add Payment Method'.tr,
                      //         onPressed: () {
                      //           controller.changePaymentMethodPageShown();
                      //           CreditCardController().openPayment();
                      //         },
                      //       )
                      //     : const SizedBox()
                    ],
                  ),
                ),
              ),
            ));
  }
}
