import 'package:dropdown_button2/dropdown_button2.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_button.dart';
import '../../../res/app_colors.dart';
import '../../../routes/app_pages.dart';
import '../controllers/cheque_deposit_controller.dart';

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: DashBoardAppBar(
        title: TranslationKeys.makeTranslation(TranslationKeys.textChequeDeposit),
        onBackButtonPressed: () {
          Get.back();
        },
      ),
      persistentFooterAlignment: AlignmentDirectional.bottomCenter,
      resizeToAvoidBottomInset: false,
      persistentFooterButtons: [
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
          child: SizedBox(
            width: double.infinity,
            child: ElevatedButton(
              onPressed: () {
                Get.back();
                // showTransactionSuccess(context);
                // controerll.cleanControllers();
                // Get.toNamed(Routes.CHEQUE_MANAGEMENT);
              },
              style: ElevatedButton.styleFrom(
                backgroundColor: AppColors.colorButton,
                padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(50),
                ),
              ),
              child: Text(TranslationKeys.makeTranslation(TranslationKeys.textContinue), style: Theme.of(context).textTheme.labelMedium?.copyWith(color: AppColors.white)),
            ),
          ),
        ),
      ],
      body: Padding(
        padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(TranslationKeys.makeTranslation(TranslationKeys.textChequeStatusContent), style: Theme.of(context).textTheme.bodySmall),
            const SizedBox(height: 20),
            Text(TranslationKeys.makeTranslation(TranslationKeys.textDepositToChequing), style: Theme.of(context).textTheme.bodySmall),
            Container(
              margin: const EdgeInsets.symmetric(horizontal: 0, vertical: 7),
              height: 40,
              padding: const EdgeInsets.symmetric(horizontal: 3.0),
              decoration: BoxDecoration(
                color: Colors.white,
                border: Border.all(color: Colors.grey),
                borderRadius: BorderRadius.circular(20.0),
              ),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                    child: TextField(
                      style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 12),
                      decoration: InputDecoration(
                        enabledBorder: InputBorder.none,
                        border: InputBorder.none,
                        focusedBorder: InputBorder.none,
                        hintText: TranslationKeys.makeTranslation(TranslationKeys.text1000),
                      ),
                      // onChanged: (value) => controller.filterList(value),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 8),
                    child: Text(TranslationKeys.makeTranslation(TranslationKeys.textMax300000), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, color: AppColors.colorText, fontSize: 8)),
                  ),
                ],
              ),
            ),
            const SizedBox(height: 20),
            Text(TranslationKeys.makeTranslation(TranslationKeys.textSelectAccount), style: Theme.of(context).textTheme.bodySmall),
            Obx(() {
              return Container(
                width: double.infinity,
                margin: const EdgeInsets.symmetric(horizontal: 0, vertical: 7),
                height: 40,
                //padding: EdgeInsets.symmetric(horizontal: 3.0),
                decoration: BoxDecoration(
                  color: Colors.white,
                  border: Border.all(color: Colors.grey),
                  borderRadius: BorderRadius.circular(20.0),
                ),
                child: DropdownButtonHideUnderline(
                  child: DropdownButton2<String>(
                    isExpanded: true,
                    hint: Text(
                      'Select Item',
                      style: TextStyle(
                        fontSize: 14,
                        color: Theme.of(context).hintColor,
                      ),
                    ),
                    items: controller.items
                        .map((String item) => DropdownMenuItem<String>(
                              value: item,
                              child: Text(
                                item,
                                style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontSize: 12, fontWeight: FontWeight.w400, color: AppColors.colorText),
                              ),
                            ))
                        .toList(),
                    value: controller.selectedValue.value,
                    onChanged: (String? value) {
                      controller.selectedValue.value = value!;
                    },
                    buttonStyleData: const ButtonStyleData(
                      padding: EdgeInsets.symmetric(horizontal: 16),
                      height: 40,
                      width: 140,
                    ),
                  ),
                ),
              );
            }),
            const SizedBox(height: 20),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(TranslationKeys.makeTranslation(TranslationKeys.textFrontOfCheque), style: Theme.of(context).textTheme.bodySmall),
                Text(TranslationKeys.makeTranslation(TranslationKeys.textBackofCheque), style: Theme.of(context).textTheme.bodySmall),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Column(
                  children: [
                    Container(
                      margin: const EdgeInsets.symmetric(horizontal: 0, vertical: 7),
                      decoration: BoxDecoration(
                        color: Colors.white,
                        border: Border.all(color: AppColors.colorGrey350),
                        borderRadius: BorderRadius.circular(5),
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.end,
                        children: [
                          const Align(
                              alignment: Alignment.topRight,
                              child: Padding(
                                padding: EdgeInsets.only(top: 5, right: 5),
                                child: Icon(Icons.close, color: AppColors.colorText, size: 20),
                              )),
                          Padding(
                            padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 10),
                            child: SvgPicture.asset(
                              AppAssets.ic_camera,
                              height: 70,
                              width: 70,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
                Container(
                  margin: const EdgeInsets.symmetric(horizontal: 0, vertical: 7),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border.all(color: AppColors.colorGrey350),
                    borderRadius: BorderRadius.circular(5),
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: [
                      const Align(
                          alignment: Alignment.topRight,
                          child: Padding(
                            padding: EdgeInsets.only(top: 5, right: 5),
                            child: Icon(Icons.close, color: AppColors.colorText, size: 20),
                          )),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 10),
                        child: SvgPicture.asset(AppAssets.ic_camera, height: 70, width: 70),
                      ),
                    ],
                  ),
                ),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(TranslationKeys.makeTranslation(TranslationKeys.textTryAgain), style: Theme.of(context).textTheme.bodySmall?.copyWith(color: AppColors.colorText, fontWeight: FontWeight.w400, fontSize: 8)),
                Text(TranslationKeys.makeTranslation(TranslationKeys.textTryAgain), style: Theme.of(context).textTheme.bodySmall?.copyWith(color: AppColors.colorText, fontWeight: FontWeight.w400, fontSize: 8)),
              ],
            ),
          ],
        ),
      ),
    );
  }
  void showTransactionSuccess(BuildContext context) {
    Get.dialog(
        Dialog(
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
          child: SingleChildScrollView(
            child: Padding(
              padding: const EdgeInsets.all(2),
              child: ListView(
                physics: const NeverScrollableScrollPhysics(),
                shrinkWrap: true,
                children: [
                  Column(
                    children: [
                      Align(
                        alignment: Alignment.topRight,
                        child: InkWell(
                          onTap: () {
                            Navigator.of(context, rootNavigator: true).pop();
                          },
                          child: SvgPicture.asset(
                            AppAssets.ic_close,
                            height: 67,
                            width: 67,
                          ),
                        ),
                      ),
                      const SizedBox(height: 10),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textRequestSummary), style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w700, fontSize: 24)),
                      ),
                      const SizedBox(height: 8),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 5),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textNumberofLeaves), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 16)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 5),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textLeave20), style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w600, fontSize: 22)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textDeliveryAddress), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 16)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textChequeBookRequestAddress), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 12)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 5),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textCharges), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 16)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 5),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textScheduleCharges), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 16)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 5),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textDate), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 16)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 5),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textDateContent), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 16)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
                        child: Text(TranslationKeys.makeTranslation(TranslationKeys.textQueryContent), style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 10, color: AppColors.colorGrey800)),
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
                        child: CustomButton(
                          buttonColor: AppColors.colorPrimaryLight,
                          onPressed: () {
                            Navigator.of(context, rootNavigator: true).pop();
                            Get.offAndToNamed(Routes.CHEQUE_MANAGEMENT);
                          },
                          buttonText: TranslationKeys.makeTranslation(TranslationKeys.textDeposit),
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),
        ),
        barrierDismissible: false);
  }

}

