From bdf5344451ef5f3be232c87c05dc7c6e85173ebf Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Wed, 3 Sep 2025 12:04:57 +0330 Subject: [PATCH] fix : memory leak animation --- lib/presentation/pages/modules/logic.dart | 6 +- .../lib/presentation/pages/auth/logic.dart | 3 +- .../lib/presentation/pages/auth/view.dart | 163 +++++++++--------- 3 files changed, 88 insertions(+), 84 deletions(-) diff --git a/lib/presentation/pages/modules/logic.dart b/lib/presentation/pages/modules/logic.dart index 133e14d..0468593 100644 --- a/lib/presentation/pages/modules/logic.dart +++ b/lib/presentation/pages/modules/logic.dart @@ -89,7 +89,7 @@ class ModulesLogic extends GetxController { selectedIndex.value = index; await Future.delayed(Duration(milliseconds: 300)); selectedIndex.value = null; - // saveModule(module); + // saveModule(module); await navigateToModule(module); } @@ -102,9 +102,9 @@ class ModulesLogic extends GetxController { isLoading.value = !isLoading.value; } - await Get.toNamed(target.key, arguments: module); + var args = await Get.toNamed(target.key, arguments: module); - if (target.value?[1] != null) { + if (target.value?[1] != null && args == -1) { await target.value?[1]?.call(); } } diff --git a/packages/chicken/lib/presentation/pages/auth/logic.dart b/packages/chicken/lib/presentation/pages/auth/logic.dart index cba77c7..4ba6685 100644 --- a/packages/chicken/lib/presentation/pages/auth/logic.dart +++ b/packages/chicken/lib/presentation/pages/auth/logic.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_chicken/chicken.dart'; import 'package:rasadyar_chicken/data/common/dio_error_handler.dart'; import 'package:rasadyar_chicken/data/di/chicken_di.dart'; -import 'package:rasadyar_chicken/data/models/request/login_request/login_request_model.dart'; import 'package:rasadyar_chicken/data/models/response/user_info/user_info_model.dart'; import 'package:rasadyar_chicken/data/models/response/user_profile_model/user_profile_model.dart'; import 'package:rasadyar_chicken/data/repositories/auth/auth_repository.dart'; @@ -72,6 +71,7 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { @override void onClose() { + _textAnimationController.dispose(); _timer?.cancel(); super.onClose(); } @@ -105,7 +105,6 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { return isCaptchaValid && isFormValid; } - Future submitLoginForm() async { if (!_isFormValid()) return; AuthRepository authTmp = diChicken.get(); diff --git a/packages/chicken/lib/presentation/pages/auth/view.dart b/packages/chicken/lib/presentation/pages/auth/view.dart index 86ca51c..b99874a 100644 --- a/packages/chicken/lib/presentation/pages/auth/view.dart +++ b/packages/chicken/lib/presentation/pages/auth/view.dart @@ -10,95 +10,100 @@ class AuthPage extends GetView { @override Widget build(BuildContext context) { - iLog("AuthPage"); return Scaffold( - body: Stack( - alignment: Alignment.center, - fit: StackFit.expand, + body: PopScope( + canPop: false, + onPopInvokedWithResult: (didPop, result) { + Get.back(result: -1); + }, + child: Stack( + alignment: Alignment.center, + fit: StackFit.expand, - children: [ - Assets.vec.bgAuthSvg.svg(fit: BoxFit.fill), + children: [ + Assets.vec.bgAuthSvg.svg(fit: BoxFit.fill), - Center( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.r), - child: FadeTransition( - opacity: controller.textAnimation, - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - spacing: 12, - children: [ - Text( - 'به سامانه رصدیار خوش آمدید!', - textAlign: TextAlign.right, - style: AppFonts.yekan25Bold.copyWith(color: Colors.white), - ), - Text( - 'سامانه رصد و پایش زنجیره تامین، تولید و توزیع کالا های اساسی', - textAlign: TextAlign.center, - style: AppFonts.yekan16.copyWith(color: Colors.white), - ), - ], + Center( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 10.r), + child: FadeTransition( + opacity: controller.textAnimation, + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + spacing: 12, + children: [ + Text( + 'به سامانه رصدیار خوش آمدید!', + textAlign: TextAlign.right, + style: AppFonts.yekan25Bold.copyWith(color: Colors.white), + ), + Text( + 'سامانه رصد و پایش زنجیره تامین، تولید و توزیع کالا های اساسی', + textAlign: TextAlign.center, + style: AppFonts.yekan16.copyWith(color: Colors.white), + ), + ], + ), ), ), ), - ), - Obx(() { - final screenHeight = MediaQuery.of(context).size.height; - final targetTop = (screenHeight - 676) / 2; + Obx(() { + final screenHeight = MediaQuery.of(context).size.height; + final targetTop = (screenHeight - 676) / 2; - return AnimatedPositioned( - duration: const Duration(milliseconds: 1200), - curve: Curves.linear, - top: controller.showCard.value ? targetTop : screenHeight, - left: 10.r, - right: 10.r, - child: Container( - width: 381.w, - height: 676.h, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(40), - ), - child: Column( - children: [ - SizedBox(height: 50.h), - LogoWidget(), - SizedBox(height: 20.h), - useAndPassFrom(), - SizedBox(height: 24.h), - RichText( - text: TextSpan( - children: [ - TextSpan( - text: 'مطالعه بیانیه ', - style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyDark), - ), - TextSpan( - recognizer: TapGestureRecognizer() - ..onTap = () { - Get.bottomSheet( - privacyPolicyWidget(), - isScrollControlled: true, - enableDrag: true, - ignoreSafeArea: false, - ); - }, - text: 'حریم خصوصی', - style: AppFonts.yekan16.copyWith(color: AppColor.blueNormal), - ), - ], + return AnimatedPositioned( + duration: const Duration(milliseconds: 1200), + curve: Curves.linear, + top: controller.showCard.value ? targetTop : screenHeight, + left: 10.r, + right: 10.r, + child: Container( + width: 381.w, + height: 676.h, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(40), + ), + child: Column( + children: [ + SizedBox(height: 50.h), + LogoWidget(), + SizedBox(height: 20.h), + useAndPassFrom(), + SizedBox(height: 24.h), + RichText( + text: TextSpan( + children: [ + TextSpan( + text: 'مطالعه بیانیه ', + style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyDark), + ), + TextSpan( + recognizer: TapGestureRecognizer() + ..onTap = () { + Get.bottomSheet( + privacyPolicyWidget(), + isScrollControlled: true, + enableDrag: true, + ignoreSafeArea: false, + ); + }, + text: 'حریم خصوصی', + style: AppFonts.yekan16.copyWith(color: AppColor.blueNormal), + ), + ], + ), ), - ), - ], + ], + ), ), - ), - ); - }), - ], + ); + }), + ], + ), ), ); }