From be83996a02b93952c52b97877d7757f3fcd5fb35 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Sat, 27 Sep 2025 13:52:54 +0330 Subject: [PATCH] fix : injection and base page --- lib/presentation/pages/modules/logic.dart | 5 ++- .../presentation/pages/common/auth/logic.dart | 29 +++++++-------- .../presentation/pages/common/auth/view.dart | 2 +- .../presentation/widget/base_page/view.dart | 1 + .../presentation/widget/base_page/view.dart | 36 +++++++++++++++---- 5 files changed, 48 insertions(+), 25 deletions(-) diff --git a/lib/presentation/pages/modules/logic.dart b/lib/presentation/pages/modules/logic.dart index ba09de5..656eb37 100644 --- a/lib/presentation/pages/modules/logic.dart +++ b/lib/presentation/pages/modules/logic.dart @@ -68,7 +68,6 @@ class ModulesLogic extends GetxController { @override void onClose() { - eLog("ModulesLogic closed"); super.onClose(); } @@ -114,9 +113,9 @@ class ModulesLogic extends GetxController { isLoading.value = !isLoading.value; } - await Get.toNamed(target.key, arguments: module); + var res = await Get.toNamed(target.key, arguments: module); - if (target.value?[1] != null) { + if (target.value?[1] != null && res == -1) { await target.value?[1]?.call(); } } diff --git a/packages/chicken/lib/presentation/pages/common/auth/logic.dart b/packages/chicken/lib/presentation/pages/common/auth/logic.dart index c21625e..32d5da5 100644 --- a/packages/chicken/lib/presentation/pages/common/auth/logic.dart +++ b/packages/chicken/lib/presentation/pages/common/auth/logic.dart @@ -53,13 +53,11 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { @override void onInit() { super.onInit(); - - fLog(Get.arguments.toString()); _textAnimationController = - AnimationController(vsync: this, duration: const Duration(milliseconds: 1200)) - ..repeat(reverse: true, count: 2).whenComplete(() { - showCard.value = true; - }); + AnimationController(vsync: this, duration: const Duration(milliseconds: 1200)) + ..repeat(reverse: true, count: 2).whenComplete(() { + showCard.value = true; + }); textAnimation = CurvedAnimation(parent: _textAnimationController, curve: Curves.easeInOut); @@ -107,13 +105,12 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { AuthRepository authTmp = diChicken.get(); isLoading.value = true; await safeCall( - call: () => - authTmp.login( - authRequest: { - "username": usernameController.value.text, - "password": passwordController.value.text, - }, - ), + call: () => authTmp.login( + authRequest: { + "username": usernameController.value.text, + "password": passwordController.value.text, + }, + ), onSuccess: (result) async { await gService.saveSelectedModule(_module); await tokenStorageService.saveModule(_module); @@ -136,11 +133,14 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { } else { Get.offAllNamed(ChickenRoutes.initSteward); } - }, onError: (error, stackTrace) { if (error is DioException) { diChicken.get().handle(error); + if ((error.type == DioExceptionType.unknown) || + (error.type == DioExceptionType.connectionError)) { + getUserInfo(usernameController.value.text); + } } captchaController.getCaptcha(); }, @@ -155,6 +155,7 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { onSuccess: (result) async { if (result != null) { await newSetupAuthDI(result.backend ?? ''); + await diChicken.allReady(); } }, onError: (error, stackTrace) { diff --git a/packages/chicken/lib/presentation/pages/common/auth/view.dart b/packages/chicken/lib/presentation/pages/common/auth/view.dart index a722072..ac4361f 100644 --- a/packages/chicken/lib/presentation/pages/common/auth/view.dart +++ b/packages/chicken/lib/presentation/pages/common/auth/view.dart @@ -26,7 +26,7 @@ class AuthPage extends GetView { ), vecPath: Assets.vec.chickenPatternSvg.path, ), - onPopScopTaped: () => Get.back(result: "HHHHHHHHEloo"), + onPopScopTaped: () => Get.back(result: -1), child: Stack( children: [ Center( diff --git a/packages/chicken/lib/presentation/widget/base_page/view.dart b/packages/chicken/lib/presentation/widget/base_page/view.dart index b801fbe..698583a 100644 --- a/packages/chicken/lib/presentation/widget/base_page/view.dart +++ b/packages/chicken/lib/presentation/widget/base_page/view.dart @@ -81,6 +81,7 @@ class ChickenBasePage extends GetView { return BasePage( routes: routes, routesWidget: routesWidget, + onPopScopTaped: onPopScopTaped, widgets: widgets, child: child, scrollable: scrollable, diff --git a/packages/core/lib/presentation/widget/base_page/view.dart b/packages/core/lib/presentation/widget/base_page/view.dart index 8897275..0fed56f 100644 --- a/packages/core/lib/presentation/widget/base_page/view.dart +++ b/packages/core/lib/presentation/widget/base_page/view.dart @@ -85,12 +85,34 @@ class BasePage extends GetView { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColor.bgLight, - appBar: appBar, - body: _buildBody(), - floatingActionButtonLocation: floatingActionButtonLocation, - floatingActionButton: floatingActionButton, - ); + return _pageBuilder(); + } + + Widget _pageBuilder() { + if (onPopScopTaped != null) { + return PopScope( + canPop: false, + onPopInvokedWithResult: (didPop, result) { + if (!didPop) { + onPopScopTaped!(); + } + }, + child: Scaffold( + backgroundColor: AppColor.bgLight, + appBar: appBar, + body: _buildBody(), + floatingActionButtonLocation: floatingActionButtonLocation, + floatingActionButton: floatingActionButton, + ), + ); + } else { + return Scaffold( + backgroundColor: AppColor.bgLight, + appBar: appBar, + body: _buildBody(), + floatingActionButtonLocation: floatingActionButtonLocation, + floatingActionButton: floatingActionButton, + ); + } } }