49 lines
1.3 KiB
Dart
49 lines
1.3 KiB
Dart
import 'package:rasadyar_app/presentation/routes/app_pages.dart';
|
|
import 'package:rasadyar_core/core.dart';
|
|
|
|
class ModulesLogic extends GetxController {
|
|
TokenStorageService tokenService = Get.find<TokenStorageService>();
|
|
RxBool isLoading = false.obs;
|
|
|
|
List<ModuleModel> 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<void> navigateToModule(Module module) async {
|
|
var target = getTargetPage(module).entries.first;
|
|
|
|
if (target.value != null) {
|
|
await target.value;
|
|
}
|
|
|
|
Get.offAllNamed(target.key);
|
|
}
|
|
|
|
void onTapCard(Module module, int index) async {
|
|
isLoading.value = true;
|
|
selectedIndex.value = index;
|
|
saveModule(module);
|
|
await Future.delayed(Duration(milliseconds: 500)); // Simulate loading delay
|
|
navigateToModule(module);
|
|
}
|
|
}
|