import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:taafee_mobile/common/const/const.dart';
import 'package:taafee_mobile/common/extensions/widget_extension.dart';
import 'package:taafee_mobile/common/widgets/gridview.dart';
import 'package:taafee_mobile/common/widgets/rx_viewer.dart';
import 'package:taafee_mobile/features/category/business_logic_layer/category_controller.dart';
import 'package:taafee_mobile/features/category/presentation_layer/widgets/category.dart';

import '../../../../common/widgets/header_screen.dart';

class CategoryScreen extends StatelessWidget {
  final CategoryController categoryController = Get.find<CategoryController>();
  CategoryScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.backGroundColor,
      body: SingleChildScrollView(
        child: Column(
          children: [
            if (Responsive.isTablet())
              const SizedBox(
                height: 20,
              ),
            HeaderScreen("all_categories".tr).paddingSymmetric(
                vertical: 25, horizontal: Responsive.isTablet() ? 50 : 20),
            if (Responsive.isTablet())
              const SizedBox(
                height: 20,
              ),
            RxViewer(
              rxFuture: categoryController.categoryState,
              child: () => GridViewWidget(
                mainAxisExtent: Responsive.isTablet() ? 155 : null,
                count: Responsive.isTablet() ? 4 : 3,
                itemCount: categoryController.categoryState.result.length,
                child: (index) => CategoryWidget(
                  categoryController.categoryState.result[index],
                  enableTabletDesign: false,
                ),
              ).paddingOnly(bottom: 20),
            ).paddingSymmetric(horizontal: Responsive.isTablet() ? 40 : 0)
          ],
        ),
      ),
    ).makeSafeArea();
  }
}
