feat : first step request tagging
This commit is contained in:
@@ -16,7 +16,6 @@ class CustomNavigationObserver extends NavigatorObserver {
|
||||
|
||||
@override
|
||||
void didPush(Route route, Route? previousRoute) async {
|
||||
super.didPush(route, previousRoute);
|
||||
final routeName = route.settings.name;
|
||||
if (!_isWorkDone && (routeName == ChickenRoutes.init || routeName == ChickenRoutes.auth)) {
|
||||
_isWorkDone = true;
|
||||
@@ -31,6 +30,7 @@ class CustomNavigationObserver extends NavigatorObserver {
|
||||
_isWorkDone = true;
|
||||
await setupLiveStockDI();
|
||||
}
|
||||
super.didPush(route, previousRoute);
|
||||
tLog('CustomNavigationObserver: didPush - $routeName');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
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<TokenStorageService>();
|
||||
RxBool isLoading = false.obs;
|
||||
|
||||
List<ModuleModel> moduleList = [
|
||||
ModuleModel(title: 'بازرسی', icon: Assets.icons.inspection.path, module: Module.inspection),
|
||||
@@ -25,4 +30,23 @@ class ModulesLogic extends GetxController {
|
||||
tokenService.saveModule(module);
|
||||
tokenService.appModule.value = module;
|
||||
}
|
||||
|
||||
Future<void> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/chicken.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/inspection.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
@@ -16,39 +15,38 @@ class ModulesPage extends GetView<ModulesLogic> {
|
||||
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;
|
||||
controller.saveModule(module.module);
|
||||
|
||||
// Navigate to the appropriate route based on the selected module
|
||||
switch (module.module) {
|
||||
case Module.inspection:
|
||||
Get.toNamed(InspectionRoutes.init);
|
||||
break;
|
||||
case Module.liveStocks:
|
||||
//TODO: Implement liveStocks module navigation
|
||||
case Module.chicken:
|
||||
Get.toNamed(ChickenRoutes.init);
|
||||
break;
|
||||
}
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
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.onTapCard(module.module, index),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
),
|
||||
physics: BouncingScrollPhysics(),
|
||||
itemCount: controller.moduleList.length,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
),
|
||||
physics: BouncingScrollPhysics(),
|
||||
itemCount: controller.moduleList.length,
|
||||
),
|
||||
ObxValue((loading) {
|
||||
if (!controller.isLoading.value) return SizedBox.shrink();
|
||||
return Container(
|
||||
color: Colors.grey.withValues(alpha: 0.5),
|
||||
child: Center(
|
||||
child: CupertinoActivityIndicator(color: AppColor.greenNormal, radius: 30),
|
||||
),
|
||||
);
|
||||
}, controller.isLoading),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user