From 0a98c57d755e388fc7721a75ce705b676b617818 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Sat, 27 Sep 2025 12:39:25 +0330 Subject: [PATCH] refactor : inspection fix : module list remove injection --- lib/presentation/pages/modules/logic.dart | 16 +- .../presentation/pages/common/auth/logic.dart | 1 + .../presentation/pages/common/auth/view.dart | 2 +- .../active_hatching/logic.dart | 15 +- .../poultry_science/active_hatching/view.dart | 23 +-- .../pages/poultry_science/farm/logic.dart | 10 +- .../pages/poultry_science/farm/view.dart | 166 +++++++++--------- .../pages/poultry_science/genocide/logic.dart | 31 ++-- .../pages/poultry_science/genocide/view.dart | 13 +- .../killing_registration/logic.dart | 7 +- .../lib/presentation/widget/label_item.dart | 55 ++++++ pubspec.yaml | 2 +- 12 files changed, 210 insertions(+), 131 deletions(-) create mode 100644 packages/chicken/lib/presentation/widget/label_item.dart diff --git a/lib/presentation/pages/modules/logic.dart b/lib/presentation/pages/modules/logic.dart index 0468593..ba09de5 100644 --- a/lib/presentation/pages/modules/logic.dart +++ b/lib/presentation/pages/modules/logic.dart @@ -66,6 +66,18 @@ class ModulesLogic extends GetxController { getSliders(); } + @override + void onClose() { + eLog("ModulesLogic closed"); + super.onClose(); + } + + @override + void dispose() { + eLog("ModulesLogic disposed"); + super.dispose(); + } + void saveModule(Module module) { tokenService.saveModule(module); tokenService.appModule.value = module; @@ -102,9 +114,9 @@ class ModulesLogic extends GetxController { isLoading.value = !isLoading.value; } - var args = await Get.toNamed(target.key, arguments: module); + await Get.toNamed(target.key, arguments: module); - if (target.value?[1] != null && args == -1) { + if (target.value?[1] != null) { 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 d65daa8..c21625e 100644 --- a/packages/chicken/lib/presentation/pages/common/auth/logic.dart +++ b/packages/chicken/lib/presentation/pages/common/auth/logic.dart @@ -54,6 +54,7 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { void onInit() { super.onInit(); + fLog(Get.arguments.toString()); _textAnimationController = AnimationController(vsync: this, duration: const Duration(milliseconds: 1200)) ..repeat(reverse: true, count: 2).whenComplete(() { diff --git a/packages/chicken/lib/presentation/pages/common/auth/view.dart b/packages/chicken/lib/presentation/pages/common/auth/view.dart index ac4361f..a722072 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: -1), + onPopScopTaped: () => Get.back(result: "HHHHHHHHEloo"), child: Stack( children: [ Center( diff --git a/packages/chicken/lib/presentation/pages/poultry_science/active_hatching/logic.dart b/packages/chicken/lib/presentation/pages/poultry_science/active_hatching/logic.dart index b472c8d..4264a02 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/active_hatching/logic.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/active_hatching/logic.dart @@ -4,7 +4,7 @@ import 'package:rasadyar_core/core.dart'; class ActiveHatchingLogic extends GetxController { PoultryScienceRootLogic rootLogic = Get.find(); - + BaseLogic baseLogic = Get.find(); Rx>> activeHatchingList = Resource>.loading().obs; @@ -13,17 +13,22 @@ class ActiveHatchingLogic extends GetxController { RxInt expandedIndex = RxInt(-1); List routesName = ['اقدام', 'جوجه ریزی فعال']; + Rx fromDateFilter = Jalali.now().obs; + Rx toDateFilter = Jalali.now().obs; + RxnString searchedValue = RxnString(); + @override void onReady() { super.onReady(); - getHatchingList(); } @override void onClose() { - // TODO: implement onClose super.onClose(); + baseLogic.searchValue.value = null; + baseLogic.isSearchSelected.value = false; + baseLogic.textEditingController.clear(); } Future getHatchingList([bool isLoadingMore = false]) async { @@ -32,12 +37,12 @@ class ActiveHatchingLogic extends GetxController { } else { activeHatchingList.value = Resource>.loading(); } - /* + if (searchedValue.value != null && searchedValue.value!.trim().isNotEmpty && currentPage.value > 1) { currentPage.value = 1; - }*/ + } safeCall( call: () async => await rootLogic.poultryRepository.getHatchingPoultry( diff --git a/packages/chicken/lib/presentation/pages/poultry_science/active_hatching/view.dart b/packages/chicken/lib/presentation/pages/poultry_science/active_hatching/view.dart index 5f2c601..672dc6a 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/active_hatching/view.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/active_hatching/view.dart @@ -3,7 +3,6 @@ import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.d import 'package:rasadyar_chicken/presentation/pages/poultry_science/active_hatching/logic.dart'; import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; -import 'package:rasadyar_chicken/presentation/widget/page_route.dart'; import 'package:rasadyar_core/core.dart'; class ActiveHatchingPage extends GetView { @@ -12,23 +11,15 @@ class ActiveHatchingPage extends GetView { @override Widget build(BuildContext context) { return ChickenBasePage( - hasSearch: false, + hasSearch: true, hasFilter: false, backId: poultryFirstKey, - - //routesWidget: buildContainerPageRoute(controller.routesName), - - child: Stack( - children: [ - Positioned.fill( - child: Assets.vec.chickenPatternSvg.svg( - fit: BoxFit.cover, - colorFilter: ColorFilter.mode(Colors.grey.shade400, BlendMode.srcIn), - ), - ), - Positioned.fill(child: Column(children: [hatchingWidget()])), - ], - ), + routes: controller.routesName, + onSearchChanged: (data) { + controller.searchedValue.value = data; + controller.getHatchingList(); + }, + child: hatchingWidget(), /*widgets: [ hatchingWidget() ],*/ diff --git a/packages/chicken/lib/presentation/pages/poultry_science/farm/logic.dart b/packages/chicken/lib/presentation/pages/poultry_science/farm/logic.dart index 3c62afa..b248f9c 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/farm/logic.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/farm/logic.dart @@ -5,8 +5,9 @@ import 'package:rasadyar_chicken/presentation/pages/poultry_science/root/logic.d import 'package:rasadyar_core/core.dart'; class FarmLogic extends GetxController { - List routesName = ['اقدام', 'فارم ها']; + List routes = ['اقدام', 'فارم ها']; PoultryScienceRootLogic rootLogic = Get.find(); + BaseLogic baseLogic = Get.find(); final PoultryScienceHomeLogic _homeLogic = Get.find(); RxList tagInfo = [ InformationTagData( @@ -42,6 +43,10 @@ class FarmLogic extends GetxController { final RxBool isLoadingMoreList = false.obs; RxInt expandedIndex = RxInt(-1); + Rx fromDateFilter = Jalali.now().obs; + Rx toDateFilter = Jalali.now().obs; + RxnString searchedValue = RxnString(); + @override void onReady() { super.onReady(); @@ -60,6 +65,9 @@ class FarmLogic extends GetxController { @override void onClose() { super.onClose(); + baseLogic.searchValue.value = null; + baseLogic.isSearchSelected.value = false; + baseLogic.textEditingController.clear(); } Future getFarmList([bool isLoadingMore = false]) async { diff --git a/packages/chicken/lib/presentation/pages/poultry_science/farm/view.dart b/packages/chicken/lib/presentation/pages/poultry_science/farm/view.dart index 5f0148a..d7883fd 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/farm/view.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/farm/view.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_chicken/data/models/response/poultry_farm/poultry_farm.dart'; import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; +import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart'; +import 'package:rasadyar_chicken/presentation/widget/label_item.dart'; import 'package:rasadyar_core/core.dart'; import 'logic.dart'; @@ -13,10 +15,19 @@ class FarmPage extends GetView { Widget build(BuildContext context) { return ChickenBasePage( hasFilter: false, - hasSearch: false, - isBase: true, - - routes: [], + hasSearch: true, + onFilterTap: () { + Get.bottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + filterBottomSheet(), + ); + }, + onSearchChanged: (data) { + controller.searchedValue.value = data; + controller.getFarmList(); + }, + routes: controller.routes, backId: poultryFirstKey, widgets: [firstTagInformation(), farmListWidget()], ); @@ -56,7 +67,7 @@ class FarmPage extends GetView { onTap: () => controller.toggleExpanded(index), index: index, child: itemListWidget(item), - secondChild: itemListExpandedWidget(item), + secondChild: itemListExpandedWidget2(item), labelColor: AppColor.blueLight, labelIcon: Assets.vec.cubeScanSvg.path, ); @@ -74,25 +85,21 @@ class FarmPage extends GetView { ); } - Container itemListExpandedWidget(PoultryFarm item) { + Container itemListExpandedWidget2(PoultryFarm item) { return Container( padding: EdgeInsets.symmetric(horizontal: 8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - ), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)), child: Column( spacing: 8, children: [ Row( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( item.unitName ?? 'N/A', textAlign: TextAlign.center, style: AppFonts.yekan16.copyWith(color: AppColor.greenDark), ), - Spacer(), Visibility( child: Text( @@ -101,86 +108,63 @@ class FarmPage extends GetView { style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), ), ), + + GestureDetector( + onTap: () { + Get.bottomSheet(BaseBottomSheet( + child: Container( + color: AppColor.blueDark, + ), + )); + }, + child: Row( + children: [ + Text( + 'جزئیات', + style: AppFonts.yekan10.copyWith(color: AppColor.iconColor), + ), + SizedBox(width: 4.w), + Assets.vec.arrowLeftSvg.svg( + width: 10.w, + height: 10.h, + colorFilter: ColorFilter.mode(AppColor.iconColor, BlendMode.srcIn), + ), + ], + ), + ), ], ), - Container( - height: 32, - padding: EdgeInsets.symmetric(horizontal: 8), - decoration: ShapeDecoration( - color: AppColor.blueLight, - shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: AppColor.blueLightHover), - borderRadius: BorderRadius.circular(8), + Wrap( + spacing: 8, + runSpacing: 8, + children: [ + labelItem(label: 'تعاونی', value: item.cityOperator ?? 'ندارد'), + labelItem(label: 'تعداد سالن ', value: item.numberOfHalls?.toString() ?? 'ندارد'), + + labelItem( + label: 'مالک/ تلفن', + value: '${item.user?.fullname} (${item.user?.mobile})', + ), + labelItem(label: 'شناسه یکتا', value: item.breedingUniqueId ?? 'N/A'), + labelItem(label: 'کد اپیدمیولوژیک', value: item.epidemiologicalCode ?? 'N/A'), + labelItem(label: 'کد بهداشتی', value: item.healthCertificateNumber ?? 'N/A'), + labelItem( + label: 'دامپزشک فارم', + value: '${item.vetFarm?.fullName} (${item.vetFarm?.mobile ?? '-'})', ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'تعاونی : ${item.cityOperator ?? 'ندارد'}', - style: AppFonts.yekan14.copyWith(color: AppColor.textColor), - ), - Text( - ' تعداد سالن : ${item.numberOfHalls}', - style: AppFonts.yekan14.copyWith(color: AppColor.textColor), - ), - ], - ), + labelItem( + label: 'ظرفیت فارم', + value: item.totalCapacity.separatedByCommaFa, + unit: 'قطعه', + ), + labelItem( + label: 'جوجه ریزی فعال (تعداد دوره)', + value: + '${(item.hatchingInfo?.activeHatching ?? false) ? 'دارد' : 'ندارد'} (${item.hatchingInfo?.period ?? 0})', + ), + ], ), - - buildRow( - title: 'مالک/ تلفن', - value: '${item.user?.fullname} (${item.user?.mobile})', - ), - buildRow(title: 'شناسه یکتا', value: item.breedingUniqueId ?? 'N/A'), - buildRow( - title: 'کد اپیدمیولوژیک', - value: item.epidemiologicalCode ?? 'N/A', - ), - buildRow( - title: 'کد بهداشتی', - value: item.healthCertificateNumber ?? 'N/A', - ), - buildRow( - title: 'دامپزشک فارم', - value: '${item.vetFarm?.fullName} (${item.vetFarm?.mobile ?? '-'})', - ), - buildUnitRow( - title: 'ظرفیت فارم', - value: item.totalCapacity.separatedByCommaFa, - unit: '(قطعه)', - ), - buildRow( - title: 'جوجه ریزی فعال (تعداد دوره) ', - value: - '${(item.hatchingInfo?.activeHatching ?? false) ? 'دارد' : 'ندارد'} (${item.hatchingInfo?.period ?? 0})', - ), - - /* buildRow( - title: 'شرح بازرسی', - value: item.reportInfo?.image == false ? 'ارسال تصویر جوجه ریزی فارم ' : 'تکمیل شده', - titleStyle: AppFonts.yekan14.copyWith( - color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark, - ), - valueStyle: AppFonts.yekan14.copyWith( - color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark, - ), - ),*/ - /* Visibility( - visible: (item.reportInfo?.image == false), - child: RElevated( - text: 'ثبت بازرسی', - isFullWidth: true, - width: 150.w, - height: 40.h, - onPressed: () { - cameraBottomSheet(item.id!); - }, - textStyle: AppFonts.yekan20.copyWith(color: Colors.white), - backgroundColor: AppColor.greenNormal, - ), - ),*/ ], ), ); @@ -243,4 +227,12 @@ class FarmPage extends GetView { ], ); } + + Widget filterBottomSheet() => filterBottomSheetWidget( + fromDate: controller.fromDateFilter, + onChangedFromDate: (jalali) => controller.fromDateFilter.value = jalali, + toDate: controller.toDateFilter, + onChangedToDate: (jalali) => controller.toDateFilter.value = jalali, + onSubmit: () => controller.getFarmList(), + ); } diff --git a/packages/chicken/lib/presentation/pages/poultry_science/genocide/logic.dart b/packages/chicken/lib/presentation/pages/poultry_science/genocide/logic.dart index 52d9027..36e0170 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/genocide/logic.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/genocide/logic.dart @@ -6,6 +6,7 @@ import 'package:rasadyar_core/core.dart'; class GenocideLogic extends GetxController { List routesName = ['اقدام', 'درخواست کشتارها']; var tokenService = Get.find(); + BaseLogic baseLogic = Get.find(); var gService = Get.find(); var rootLogic = Get.find(); var killRegistration = Get.find(); @@ -37,6 +38,9 @@ class GenocideLogic extends GetxController { void onClose() { // TODO: implement onClose super.onClose(); + baseLogic.searchValue.value = null; + baseLogic.isSearchSelected.value = false; + baseLogic.textEditingController.clear(); } Future getPoultryOrderList([bool loadingMore = false]) async { @@ -70,23 +74,26 @@ class GenocideLogic extends GetxController { if ((res?.count ?? 0) == 0) { poultryOrderList.value = Resource>.empty(); } else { - poultryOrderList.value = Resource>.success( - PaginationModel( - count: res?.count ?? 0, - next: res?.next, - previous: res?.previous, - results: [...(poultryOrderList.value.data?.results ?? []), ...(res?.results ?? [])], - ), - ); + if (loadingMore) { + poultryOrderList.value = Resource>.success( + PaginationModel( + count: res?.count ?? 0, + next: res?.next, + previous: res?.previous, + results: [...(poultryOrderList.value.data?.results ?? []), ...(res?.results ?? [])], + ), + ); + } else { + + poultryOrderList.value = Resource>.success(res!); + } } }, ); } - - Future deletePoultryOrder(int id) async { - toggleExpanded(-1); + toggleExpanded(-1); await safeCall( call: () async => await rootLogic.poultryRepository.deletePoultryOder( token: rootLogic.tokenService.accessToken.value!, @@ -98,12 +105,10 @@ class GenocideLogic extends GetxController { ); } - void toggleExpanded(int index) { expandedIndex.value = expandedIndex.value == index ? -1 : index; } - String getRequestType(PoultryOrder item) { if (item.market ?? false) { return 'پنل معاملات'; diff --git a/packages/chicken/lib/presentation/pages/poultry_science/genocide/view.dart b/packages/chicken/lib/presentation/pages/poultry_science/genocide/view.dart index 81f50cf..71a7113 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/genocide/view.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/genocide/view.dart @@ -4,7 +4,6 @@ import 'package:rasadyar_chicken/presentation/pages/poultry_science/killing_regi import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart'; -import 'package:rasadyar_chicken/presentation/widget/page_route.dart'; import 'package:rasadyar_core/core.dart'; import 'logic.dart'; @@ -15,7 +14,7 @@ class GenocidePage extends GetView { @override Widget build(BuildContext context) { return ChickenBasePage( - routes:controller.routesName, + routes: controller.routesName, hasSearch: true, hasFilter: true, onSearchChanged: (data) { @@ -23,7 +22,13 @@ class GenocidePage extends GetView { controller.getPoultryOrderList(); }, backId: poultryFirstKey, - filteringWidget: filterBottomSheet(), + onFilterTap: () { + Get.bottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + filterBottomSheet(), + ); + }, child: Stack( fit: StackFit.expand, children: [ @@ -67,7 +72,7 @@ class GenocidePage extends GetView { child: itemListWidget(item), secondChild: itemListExpandedWidget(item), labelColor: AppColor.blueLight, - labelIcon: Assets.vec.cubeScanSvg.path, + labelIcon: Assets.vec.timerSvg.path, ); }, controller.expandedIndex); }, diff --git a/packages/chicken/lib/presentation/pages/poultry_science/killing_registration/logic.dart b/packages/chicken/lib/presentation/pages/poultry_science/killing_registration/logic.dart index 82290c5..42665cc 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/killing_registration/logic.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/killing_registration/logic.dart @@ -7,6 +7,7 @@ import 'package:rasadyar_chicken/data/models/response/kill_house_poultry/kill_ho import 'package:rasadyar_chicken/data/models/response/kill_request_poultry/kill_request_poultry.dart'; import 'package:rasadyar_chicken/data/models/response/poultry_hatching/poultry_hatching.dart'; import 'package:rasadyar_chicken/data/models/response/sell_for_freezing/sell_for_freezing.dart'; +import 'package:rasadyar_chicken/presentation/pages/poultry_science/genocide/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/poultry_science/root/logic.dart'; import 'package:rasadyar_core/core.dart'; @@ -320,6 +321,8 @@ class KillingRegistrationLogic extends GetxController { if (!formKey.currentState!.validate()) { return; } + + dLog(double.parse(averageWeightKillsController.text)); KillRegistrationRequest registrationRequest = KillRegistrationRequest( indexWeight: double.parse(averageWeightKillsController.text), amount: generatedApprovedPrice.value, @@ -343,7 +346,7 @@ class KillingRegistrationLogic extends GetxController { operatorKey: "", poultryHatchingKey: selectedPoultryHatching.value?.key, poultryKey: selectedPoultry.value?.key, - quantity: int.parse(quantityKillsController.text), + quantity: int.parse(quantityKillsController.text.clearComma), role: gService.getRole(Module.chicken), sendDate: killsDate.value.toDateTime().formattedDashedGregorian, ); @@ -358,9 +361,11 @@ class KillingRegistrationLogic extends GetxController { 'ثبت با موفقیت انجام شد', durationInSeconds: 2, onDismissed: () async { + Get.find().getPoultryOrderList(); Future.delayed(Duration(milliseconds: 300), () { Get.back(); }); + Get.find().getPoultryOrderList(); }, ); }, diff --git a/packages/chicken/lib/presentation/widget/label_item.dart b/packages/chicken/lib/presentation/widget/label_item.dart new file mode 100644 index 0000000..a915146 --- /dev/null +++ b/packages/chicken/lib/presentation/widget/label_item.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; +import 'package:rasadyar_core/core.dart'; + +Widget labelItem({required String label, String? value, String? unit}) { + String getLabelText(String? value, String? unit) { + if (value != null && unit != null) { + return '$value ($unit)'; + } else if (value != null) { + return value; + } else { + return 'بدون مقدار'; + } + } + + return Container( + height: 49.h, + clipBehavior: Clip.antiAlias, + padding: EdgeInsets.fromLTRB(8.w, 7.h, 8.w, 7.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(width: 1, color: const Color(0xFFB9B9B9)), + ), + child: Column( + spacing: 6, + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + spacing: 4, + children: [ + Text( + label, + textAlign: TextAlign.right, + style: AppFonts.yekan10.copyWith(color: AppColor.unselectTextColor), + ), + + Assets.vec.arrowLeftSvg.svg( + width: 10.w, + height: 10.h, + colorFilter: ColorFilter.mode(AppColor.unselectTextColor, BlendMode.srcIn), + ), + ], + ), + Text( + getLabelText(value, unit), + textAlign: TextAlign.right, + style: AppFonts.yekan10.copyWith(color: AppColor.iconColor), + ), + ], + ), + ); +} diff --git a/pubspec.yaml b/pubspec.yaml index 37e2584..c05f5e3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: rasadyar_app description: "A new Flutter project." publish_to: 'none' -version: 1.3.8+6 +version: 1.3.10+7 environment: sdk: ^3.9.2