import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';


import '../../../core/constants/app_assets.dart';
import '../../../core/constants/translation_keys.dart';
import '../../../custom_widgets/custom_app_bar.dart';
import '../../../custom_widgets/custom_label.dart';
import '../../../res/app_colors.dart';
import '../../../routes/app_pages.dart';
import '../../login/views/shared/bottom_sheet_login.dart';
import '../controllers/bill_management_controller.dart';

class BillManagementView extends GetView<BillManagementController> {
  const BillManagementView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: DashBoardAppBar(
        title: TranslationKeys.makeTranslation(TranslationKeys.transUtilityBill),
        onBackButtonPressed: () {
          Get.back();
        },
      ),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 10),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 10),
                child: Text(TranslationKeys.makeTranslation(TranslationKeys.textSelectBillType), style: Theme.of(context).textTheme.titleSmall!.copyWith(color: AppColors.colorTitle)),
              ),
              const SizedBox(height: 20),
              Wrap(
                children: [
                  GridView.builder(
                      padding: const EdgeInsets.only(left: 15, right: 15, top: 0, bottom: 15),
                      itemCount: options.length,
                      shrinkWrap: true,
                      physics: const NeverScrollableScrollPhysics(),
                      itemBuilder: (context, index) {
                        BottomSheetLogin bottomSheetLogin = options[index];
                        return InkWell(
                            customBorder: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(10),
                            ),
                            onTap: bottomSheetLogin.onTap,
                            child: Container(
                                padding: const EdgeInsets.all(8),
                                alignment: Alignment.center,
                                decoration: BoxDecoration(border: Border.all(color: AppColors.colorGrey350, width: 1), borderRadius: const BorderRadius.all(Radius.circular(10))),
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Image.asset(
                                      bottomSheetLogin.icon,
                                      width: 50,
                                    ),
                                    const SizedBox(height: 10),
                                    Center(
                                      child: LabelText(fontSize: 12, bottomSheetLogin.description),
                                    ),
                                  ],
                                )));
                      },
                      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                        childAspectRatio: 0.4 / 0.3,
                        crossAxisCount: 2,
                        crossAxisSpacing: 10,
                        mainAxisSpacing: 10,
                      )),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }

  static List<BottomSheetLogin> options = [
    BottomSheetLogin(
        billTypes: "${BillType.electricity}",
        description: TranslationKeys.makeTranslation(TranslationKeys.transUtilityElectricity),
        icon: AppAssets.ic_electricity,
        onTap: () {
          Get.toNamed(Routes.BILL_MANAGEMENT_CATEGORY, arguments: BillType.electricity);
        }),
    BottomSheetLogin(
        billTypes: "${BillType.gas}",
        description: TranslationKeys.makeTranslation(TranslationKeys.transUtilityGas),
        icon: AppAssets.ic_gas,
        onTap: () {
          Get.toNamed(Routes.BILL_MANAGEMENT_CATEGORY, arguments: BillType.gas);
        }),
    BottomSheetLogin(
        billTypes: "${BillType.internet}",
        description: TranslationKeys.makeTranslation(TranslationKeys.transUtilityInternet),
        icon: AppAssets.ic_internet,
        onTap: () {
          Get.toNamed(Routes.BILL_MANAGEMENT_CATEGORY, arguments: BillType.internet);
        }),
    BottomSheetLogin(
        billTypes: "${BillType.water}",
        description: TranslationKeys.makeTranslation(TranslationKeys.transUtilityWater),
        icon: AppAssets.ic_water,
        onTap: () {
          Get.toNamed(Routes.BILL_MANAGEMENT_CATEGORY, arguments: BillType.water);
        }),
    // BottomSheetLogin(
    //     billTypes: "${BillType.creditCard}",
    //     description: TranslationKeys.makeTranslation(
    //         TranslationKeys.transUtilityCreditCard),
    //     icon: AppAssets.ic_card,
    //     onTap: () {
    //       Get.toNamed(Routes.BILL_MANAGEMENT_CATEGORY,
    //           arguments: BillType.creditCard);
    //     }),
  ];
}

/// Enum to represent different bill types
enum BillType {
  electricity,
  gas,
  internet,
  ptcl,
  water,
  creditCard,
  utilityAJKBARKIYAT,
  utilityFESCO,
  utilityGBBARKIYAT,
  utilityIESCO,
  utilityGEPCO,
  utilityHESCO,
  pakGasAgency,
  suitGas,
  fiber,
  zong,
  nestle,
  aqua,
  pepsiCo,
  minerva,
}
