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 '../../bill_management/views/bill_management_view.dart';
import '../../login/views/shared/bottom_sheet_login.dart';
import '../controllers/bill_management_category_controller.dart';

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

  @override
  Widget build(BuildContext context) {
    BillType? selectedBillType = Get.arguments;

    String category = controller.getBillTypeCategory(selectedBillType);

    List<BottomSheetLogin> options = controller.getOptions(selectedBillType);

    return Scaffold(
      appBar: DashBoardAppBar(
        title: TranslationKeys.makeTranslation(category),
        onBackButtonPressed: () {
          Get.back();
        },
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              margin: const EdgeInsets.symmetric(horizontal: 30, vertical: 18),
              height: 40,
              padding: const EdgeInsets.symmetric(horizontal: 12.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.textSelectCompany),
                      ),
                      // onChanged: (value) => controller.filterList(value),
                    ),
                  ),
                  Icon(
                    Icons.search,
                    size: 15.0,
                    color: Colors.grey[800],
                  ),
                ],
              ),
            ),
            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 = controller.getOptions(selectedBillType)[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(
                                  image: AssetImage(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,
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
