import 'package:flutter/material.dart';
import 'package:rasadyar_auth/presentation/routes/pages.dart';
import 'package:rasadyar_core/core.dart';

import 'logic.dart';

class ModulesPage extends GetView<ModulesLogic> {
  const ModulesPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'انتخاب سامانه',
          style: AppFonts.yekan18.copyWith(color: Colors.white),
        ),
        centerTitle: true,
        backgroundColor: AppColor.blueNormal,
      ),
      body: GridView.builder(
        padding: EdgeInsets.symmetric(horizontal: 10, vertical: 20),

        itemBuilder: (context, index) {
          final module = controller.moduleList[index];
          return CardIcon(
            title: module.title,
            icon: module.icon,
            onTap: () {
              controller.selectedIndex.value = index;
              Get.toNamed(AuthPaths.auth, arguments: module.module);
            },
          );
        },
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,
          mainAxisSpacing: 10,
          crossAxisSpacing: 10,
        ),
        physics: BouncingScrollPhysics(),
        itemCount: controller.moduleList.length,
      ),
    );
  }
}
