2025-08-19 11:22:34 +03:30
|
|
|
import 'package:rasadyar_app/presentation/routes/app_pages.dart';
|
2025-05-11 11:50:01 +03:30
|
|
|
import 'package:rasadyar_core/core.dart';
|
|
|
|
|
|
|
|
|
|
class ModulesLogic extends GetxController {
|
2025-07-28 15:57:30 +03:30
|
|
|
TokenStorageService tokenService = Get.find<TokenStorageService>();
|
2025-08-04 15:31:34 +03:30
|
|
|
RxBool isLoading = false.obs;
|
2025-05-11 11:50:01 +03:30
|
|
|
|
2025-07-28 15:57:30 +03:30
|
|
|
List<ModuleModel> moduleList = [
|
2025-05-19 16:16:33 +03:30
|
|
|
ModuleModel(title: 'بازرسی', icon: Assets.icons.inspection.path, module: Module.inspection),
|
2025-08-03 11:55:57 +03:30
|
|
|
ModuleModel(title: 'دام', icon: Assets.icons.liveStock.path, module: Module.liveStocks),
|
2025-06-03 16:55:49 +03:30
|
|
|
ModuleModel(title: 'مرغ', icon: Assets.icons.liveStock.path, module: Module.chicken),
|
2025-05-19 16:16:33 +03:30
|
|
|
];
|
|
|
|
|
|
|
|
|
|
RxnInt selectedIndex = RxnInt(null);
|
2025-05-11 11:50:01 +03:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onReady() {
|
|
|
|
|
super.onReady();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onClose() {
|
|
|
|
|
super.onClose();
|
|
|
|
|
}
|
2025-07-28 15:57:30 +03:30
|
|
|
|
|
|
|
|
void saveModule(Module module) {
|
|
|
|
|
tokenService.saveModule(module);
|
|
|
|
|
tokenService.appModule.value = module;
|
|
|
|
|
}
|
2025-08-04 15:31:34 +03:30
|
|
|
|
|
|
|
|
Future<void> navigateToModule(Module module) async {
|
2025-08-19 11:22:34 +03:30
|
|
|
var target = getTargetPage(module).entries.first;
|
|
|
|
|
|
|
|
|
|
if (target.value != null) {
|
|
|
|
|
await target.value;
|
2025-08-04 15:31:34 +03:30
|
|
|
}
|
2025-08-19 11:22:34 +03:30
|
|
|
|
|
|
|
|
Get.offAllNamed(target.key);
|
2025-08-04 15:31:34 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onTapCard(Module module, int index) async {
|
|
|
|
|
isLoading.value = true;
|
|
|
|
|
selectedIndex.value = index;
|
|
|
|
|
saveModule(module);
|
2025-08-19 11:22:34 +03:30
|
|
|
await Future.delayed(Duration(milliseconds: 500)); // Simulate loading delay
|
2025-08-04 15:31:34 +03:30
|
|
|
navigateToModule(module);
|
|
|
|
|
}
|
2025-05-11 11:50:01 +03:30
|
|
|
}
|