import 'package:flutter/material.dart';
import 'package:get/get.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 '../controllers/cheque_request_controller.dart';

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: DashBoardAppBar(
        title: TranslationKeys.makeTranslation(TranslationKeys.textChequeRequest),
        onBackButtonPressed: () {
          Get.back();
        },
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 10),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text(TranslationKeys.makeTranslation(TranslationKeys.textChequeRequestContent), style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontSize: 14, color: AppColors.colorText, fontWeight: FontWeight.w400)),
            ),
            const SizedBox(height: 20),
            Wrap(
              children: [
                GridView.builder(
                    padding: const EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 15),
                    itemCount: options.length,
                    shrinkWrap: true,
                    physics: const NeverScrollableScrollPhysics(),
                    itemBuilder: (context, index) {
                      ChequeRequestModel 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: [
                                  Center(
                                    child: LabelText(bottomSheetLogin.leave, labelColor: AppColors.colorGrey800, fontWeight: FontWeight.w600),
                                  ),
                                  const SizedBox(height: 5),
                                  Center(
                                    child: LabelText(bottomSheetLogin.description, labelColor: AppColors.colorGrey400, fontSize: 12),
                                  ),
                                  const SizedBox(height: 10),
                                  Container(
                                    decoration: BoxDecoration(
                                      color: AppColors.colorGrey350,
                                      borderRadius: BorderRadius.circular(50),
                                    ),
                                    child: Padding(
                                      padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 4),
                                      child: Text(
                                        bottomSheetLogin.buttonText,
                                        style: Theme.of(context).textTheme.bodySmall?.copyWith(color: AppColors.black),
                                      ),
                                    ),
                                  ),
                                ],
                              )));
                    },
                    gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                      childAspectRatio: 0.4 / 0.3,
                      crossAxisCount: 2,
                      crossAxisSpacing: 10,
                      mainAxisSpacing: 10,
                    )),
              ],
            ),
          ],
        ),
      ),
    );
  }

  static List<ChequeRequestModel> options = [
    ChequeRequestModel(
        leave: TranslationKeys.makeTranslation(TranslationKeys.textLeave20),
        description: TranslationKeys.makeTranslation(TranslationKeys.textLeaves),
        buttonText: TranslationKeys.makeTranslation(TranslationKeys.textGet),
        onTap: () {
          Get.toNamed(Routes.CHEQUE_BOOK_REQUEST_DETAILS);
        }),
    ChequeRequestModel(
        leave: TranslationKeys.makeTranslation(TranslationKeys.textLeave50),
        description: TranslationKeys.makeTranslation(TranslationKeys.textLeaves),
        buttonText: TranslationKeys.makeTranslation(TranslationKeys.textGet),
        onTap: () {
          Get.toNamed(Routes.CHEQUE_BOOK_REQUEST_DETAILS);
        }),
    ChequeRequestModel(
        leave: TranslationKeys.makeTranslation(TranslationKeys.textLeave100),
        description: TranslationKeys.makeTranslation(TranslationKeys.textLeaves),
        buttonText: TranslationKeys.makeTranslation(TranslationKeys.textGet),
        onTap: () {
          Get.toNamed(Routes.CHEQUE_BOOK_REQUEST_DETAILS);
        }),
  ];
}

class ChequeRequestModel {
  String leave;
  String description;
  String buttonText;
  Function()? onTap;

  ChequeRequestModel({required this.leave, required this.description, required this.buttonText, required this.onTap});
}
