From d49bbf1e93c79bdccf11aca227a6d961a6d553bf Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Wed, 2 Jul 2025 08:50:19 +0330 Subject: [PATCH] fix :kiss and dray --- .../pages/buy_out_of_province/view.dart | 454 +++++++++--------- 1 file changed, 226 insertions(+), 228 deletions(-) diff --git a/packages/chicken/lib/presentation/pages/buy_out_of_province/view.dart b/packages/chicken/lib/presentation/pages/buy_out_of_province/view.dart index a7d6683..27e8a94 100644 --- a/packages/chicken/lib/presentation/pages/buy_out_of_province/view.dart +++ b/packages/chicken/lib/presentation/pages/buy_out_of_province/view.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart'; import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; +import 'package:rasadyar_chicken/data/models/response/steward_free_bar/steward_free_bar.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart'; import 'package:rasadyar_chicken/presentation/widget/list_row_item.dart'; @@ -35,235 +36,9 @@ class BuyOutOfProvincePage extends GetView { return ListItem2( selected: val.contains(index), onTap: () => controller.isExpandedList.toggle(index), - index: index, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - SizedBox(width: 20), - Expanded( - flex: 2, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - spacing: 3, - children: [ - Text( - item.killHouseName ?? 'N/A', - textAlign: TextAlign.start, - style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal), - ), - Text( - item.date?.formattedJalaliDate ?? 'N/A', - textAlign: TextAlign.center, - style: AppFonts.yekan14.copyWith(color: AppColor.bgDark), - ), - ], - ), - ), - - Expanded( - flex: 3, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - spacing: 3, - children: [ - Visibility( - visible: item.product?.name?.contains('مرغ گرم') ?? false, - child: Assets.vec.hotChickenSvg.svg( - width: 24, - height: 24, - colorFilter: ColorFilter.mode( - AppColor.blueNormal, - BlendMode.srcIn, - ), - ), - ), - Text( - '${item.weightOfCarcasses?.separatedByComma}kg', - textAlign: TextAlign.left, - style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal), - ), - ], - ), - - SizedBox(height: 2), - - Text( - '${item.province}', - textAlign: TextAlign.center, - style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), - ), - ], - ), - ), - Expanded( - flex: 1, - child: Assets.vec.scanSvg.svg( - width: 32.w, - height: 32.h, - colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), - ), - ), - ], - ), - secondChild: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - ), - child: Column( - spacing: 8, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - '${item.province}-${item.city}', - textAlign: TextAlign.center, - style: AppFonts.yekan16.copyWith(color: AppColor.greenDark), - ), - ], - ), - Container( - height: 32, - padding: EdgeInsets.symmetric(horizontal: 4), - decoration: ShapeDecoration( - color: AppColor.blueLight, - shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: AppColor.blueLightHover), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - spacing: 3, - children: [ - Text( - item.date?.toJalali.formatter.wN ?? 'N/A', - style: AppFonts.yekan14.copyWith(color: AppColor.textColor), - ), - - Text( - '${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'N/A'}', - style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), - ), - ], - ), - - Text( - '${item.date?.toJalali.formatter.y}', - style: AppFonts.yekan20.copyWith(color: AppColor.textColor), - ), - - Text( - '${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'N/A'}', - style: AppFonts.yekan14.copyWith(color: AppColor.textColor), - ), - ], - ), - ), - - buildRow(title: 'مشخصات فروشنده', value: item.killHouseName ?? 'N/A'), - - buildRow( - title: 'تلفن فروشنده', - value: item.killHouseMobile ?? 'N/A', - valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), - ), - buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'), - buildRow( - title: 'وزن خریداری شده', - value: '${item.weightOfCarcasses?.separatedByComma} کیلوگرم', - ), - buildRowOnTapped( - title: 'مشاهده بارنامه', - titleStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), - valueWidget: Assets.vec.clipboardEyeSvg.svg( - width: 20, - height: 24, - colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), - ), - onTap: () { - Get.bottomSheet( - BaseBottomSheet( - height: 400, - child: Column( - spacing: 16, - children: [ - Text( - 'بارنامه', - style: AppFonts.yekan16Bold.copyWith( - color: AppColor.darkGreyDarkHover, - ), - ), - - Image.network( - item.barImage ?? '', - fit: BoxFit.cover, - height: 300, - errorBuilder: (context, error, stackTrace) { - eLog(error.toString()); - return Center(child: Text('خطایی پیش آمده!')); - }, - loadingBuilder: (context, child, loadingProgress) { - if (loadingProgress == null) return child; - print('Loading progress: $loadingProgress'); - return CupertinoActivityIndicator(); - }, - ), - ], - ), - ), - ); - }, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - spacing: 16.w, - children: [ - RElevated( - text: 'ویرایش', - width: 150.w, - height: 40.h, - onPressed: () { - controller.setEditData(item); - Get.bottomSheet( - addPurchasedInformationBottomSheet(true), - isScrollControlled: true, - ).whenComplete(() { - controller.resetSubmitForm(); - }); - }, - textStyle: AppFonts.yekan20.copyWith(color: Colors.white), - backgroundColor: AppColor.greenNormal, - ), - ROutlinedElevated( - text: 'حذف', - textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal), - width: 150.w, - height: 40.h, - onPressed: () { - buildDeleteDialog( - onConfirm: () => - controller.deleteStewardPurchaseOutOfProvince(item.key!), - ); - }, - borderColor: AppColor.redNormal, - ), - ], - ), - ], - ), - ), + child: itemListWidget(item), + secondChild: itemListExpandedWidget(item), labelColor: AppColor.blueLight, labelIcon: Assets.vec.truckFastOutlinedSvg.path, ); @@ -285,6 +60,229 @@ class BuyOutOfProvincePage extends GetView { ); } + Container itemListExpandedWidget(StewardFreeBar item) { + return Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)), + child: Column( + spacing: 8, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '${item.province}-${item.city}', + textAlign: TextAlign.center, + style: AppFonts.yekan16.copyWith(color: AppColor.greenDark), + ), + ], + ), + Container( + height: 32, + padding: EdgeInsets.symmetric(horizontal: 4), + decoration: ShapeDecoration( + color: AppColor.blueLight, + shape: RoundedRectangleBorder( + side: BorderSide(width: 1, color: AppColor.blueLightHover), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + spacing: 3, + children: [ + Text( + item.date?.toJalali.formatter.wN ?? 'N/A', + style: AppFonts.yekan14.copyWith(color: AppColor.textColor), + ), + + Text( + '${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'N/A'}', + style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + ), + ], + ), + + Text( + '${item.date?.toJalali.formatter.y}', + style: AppFonts.yekan20.copyWith(color: AppColor.textColor), + ), + + Text( + '${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'N/A'}', + style: AppFonts.yekan14.copyWith(color: AppColor.textColor), + ), + ], + ), + ), + + buildRow(title: 'مشخصات فروشنده', value: item.killHouseName ?? 'N/A'), + + buildRow( + title: 'تلفن فروشنده', + value: item.killHouseMobile ?? 'N/A', + valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + ), + buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'), + buildRow( + title: 'وزن خریداری شده', + value: '${item.weightOfCarcasses?.separatedByComma} کیلوگرم', + ), + buildRowOnTapped( + title: 'مشاهده بارنامه', + titleStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + valueWidget: Assets.vec.clipboardEyeSvg.svg( + width: 20, + height: 24, + colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), + ), + onTap: () { + Get.bottomSheet( + BaseBottomSheet( + height: 400, + child: Column( + spacing: 16, + children: [ + Text( + 'بارنامه', + style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover), + ), + + Image.network( + item.barImage ?? '', + fit: BoxFit.cover, + height: 300, + errorBuilder: (context, error, stackTrace) { + eLog(error.toString()); + return Center(child: Text('خطایی پیش آمده!')); + }, + loadingBuilder: (context, child, loadingProgress) { + if (loadingProgress == null) return child; + print('Loading progress: $loadingProgress'); + return CupertinoActivityIndicator(); + }, + ), + ], + ), + ), + ); + }, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 16.w, + children: [ + RElevated( + text: 'ویرایش', + width: 150.w, + height: 40.h, + onPressed: () { + controller.setEditData(item); + Get.bottomSheet( + addPurchasedInformationBottomSheet(true), + isScrollControlled: true, + ).whenComplete(() { + controller.resetSubmitForm(); + }); + }, + textStyle: AppFonts.yekan20.copyWith(color: Colors.white), + backgroundColor: AppColor.greenNormal, + ), + ROutlinedElevated( + text: 'حذف', + textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal), + width: 150.w, + height: 40.h, + onPressed: () { + buildDeleteDialog( + onConfirm: () => controller.deleteStewardPurchaseOutOfProvince(item.key!), + ); + }, + borderColor: AppColor.redNormal, + ), + ], + ), + ], + ), + ); + } + + Row itemListWidget(StewardFreeBar item) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + SizedBox(width: 20), + Expanded( + flex: 2, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 3, + children: [ + Text( + item.killHouseName ?? 'N/A', + textAlign: TextAlign.start, + style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal), + ), + Text( + item.date?.formattedJalaliDate ?? 'N/A', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.bgDark), + ), + ], + ), + ), + Expanded( + flex: 3, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + spacing: 3, + children: [ + Visibility( + visible: item.product?.name?.contains('مرغ گرم') ?? false, + child: Assets.vec.hotChickenSvg.svg( + width: 24, + height: 24, + colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), + ), + ), + Text( + '${item.weightOfCarcasses?.separatedByComma}kg', + textAlign: TextAlign.left, + style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal), + ), + ], + ), + + SizedBox(height: 2), + + Text( + '${item.province}', + textAlign: TextAlign.center, + style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), + ), + ], + ), + ), + Expanded( + flex: 1, + child: Assets.vec.scanSvg.svg( + width: 32.w, + height: 32.h, + colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), + ), + ), + ], + ); + } + Widget addPurchasedInformationBottomSheet([bool isOnEdit = false]) { return BaseBottomSheet( child: SingleChildScrollView(