import 'package:rasadyar_chicken/presentation/routes/routes.dart'; import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_inspection/inspection.dart'; import 'package:rasadyar_livestock/injection/live_stock_di.dart'; import 'package:rasadyar_livestock/presentation/routes/app_pages.dart'; class ModulesLogic extends GetxController { TokenStorageService tokenService = Get.find(); RxBool isLoading = false.obs; List moduleList = [ ModuleModel(title: 'بازرسی', icon: Assets.icons.inspection.path, module: Module.inspection), ModuleModel(title: 'دام', icon: Assets.icons.liveStock.path, module: Module.liveStocks), ModuleModel(title: 'مرغ', icon: Assets.icons.liveStock.path, module: Module.chicken), ]; RxnInt selectedIndex = RxnInt(null); @override void onReady() { super.onReady(); } @override void onClose() { super.onClose(); } void saveModule(Module module) { tokenService.saveModule(module); tokenService.appModule.value = module; } Future navigateToModule(Module module) async { if (module == Module.inspection) { Get.offAllNamed(InspectionRoutes.init); } else if (module == Module.liveStocks) { await setupLiveStockDI(); Get.offAllNamed(LiveStockRoutes.init); } else if (module == Module.chicken) { Get.offAllNamed(ChickenRoutes.init); } } void onTapCard(Module module, int index) async { isLoading.value = true; selectedIndex.value = index; saveModule(module); await Future.delayed(Duration(milliseconds: 800)); // Simulate loading delay navigateToModule(module); } }