fix : chicken app login and new module logic
This commit is contained in:
@@ -17,7 +17,7 @@ class CustomNavigationObserver extends NavigatorObserver {
|
||||
@override
|
||||
void didPush(Route route, Route? previousRoute) async {
|
||||
final routeName = route.settings.name;
|
||||
if (!_isWorkDone && (routeName == ChickenRoutes.init || routeName == ChickenRoutes.auth)) {
|
||||
/* if (!_isWorkDone && (routeName == ChickenRoutes.init || routeName == ChickenRoutes.auth)) {
|
||||
_isWorkDone = true;
|
||||
await setupChickenDI();
|
||||
} else if (!_isWorkDone &&
|
||||
@@ -28,7 +28,7 @@ class CustomNavigationObserver extends NavigatorObserver {
|
||||
} else if (!_isWorkDone &&
|
||||
(routeName == LiveStockRoutes.init || routeName == LiveStockRoutes.auth)) {
|
||||
|
||||
}
|
||||
}*/
|
||||
super.didPush(route, previousRoute);
|
||||
// tLog('CustomNavigationObserver: didPush - $routeName');
|
||||
}
|
||||
|
||||
@@ -28,21 +28,20 @@ class ModulesLogic extends GetxController {
|
||||
tokenService.appModule.value = module;
|
||||
}
|
||||
|
||||
void onTapCard(Module module, int index) async {
|
||||
isLoading.value = !isLoading.value;
|
||||
selectedIndex.value = index;
|
||||
await Future.delayed(Duration(milliseconds: 200)); // Simulate loading delay
|
||||
navigateToModule(module);
|
||||
}
|
||||
|
||||
Future<void> navigateToModule(Module module) async {
|
||||
var target = getTargetPage(module).entries.first;
|
||||
var target = getAuthTargetPage(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);
|
||||
isLoading.value = !isLoading.value;
|
||||
Get.toNamed(target.key, arguments: module);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ class SplashLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
if (isUpdateNeeded) return;
|
||||
tokenService.getModule();
|
||||
final module = tokenService.appModule.value;
|
||||
final target = getTargetPage(module);
|
||||
final target = getTargetModule(module);
|
||||
if (target.values.first != null) {
|
||||
await target.values.first;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:rasadyar_app/presentation/pages/system_design/system_design.dart
|
||||
import 'package:rasadyar_chicken/chicken.dart';
|
||||
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/injection/inspection_di.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';
|
||||
@@ -40,14 +41,28 @@ sealed class AppPages {
|
||||
];
|
||||
}
|
||||
|
||||
Map<String, Future<void>?> getTargetPage(Module? value) {
|
||||
|
||||
Map<String, Future<void>?> getTargetModule(Module? value) {
|
||||
switch (value) {
|
||||
case Module.inspection:
|
||||
return {InspectionRoutes.init:null};
|
||||
return {InspectionRoutes.init:setupInspectionDI()};
|
||||
case Module.liveStocks:
|
||||
return {LiveStockRoutes.init: setupLiveStockDI()};
|
||||
case Module.chicken:
|
||||
return {ChickenRoutes.init : null};
|
||||
return {ChickenRoutes.init : setupChickenDI()};
|
||||
default:
|
||||
return {AppPaths.moduleList : null};
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Future<void>?> getAuthTargetPage(Module? value) {
|
||||
switch (value) {
|
||||
case Module.inspection:
|
||||
return {InspectionRoutes.auth:setupInspectionDI()};
|
||||
case Module.liveStocks:
|
||||
return {LiveStockRoutes.auth: setupLiveStockDI()};
|
||||
case Module.chicken:
|
||||
return {ChickenRoutes.auth : setupChickenDI()};
|
||||
default:
|
||||
return {AppPaths.moduleList : null};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user