Merge branch with resolved conflicts - restructured features and added new modules

This commit is contained in:
2025-12-17 10:26:39 +03:30
484 changed files with 55236 additions and 4255 deletions

View File

@@ -0,0 +1,313 @@
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:rasadyar_chicken/features/common/data/datasources/local/chicken_local.dart';
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
<<<<<<<< HEAD:packages/chicken/lib/features/steward/root/logic.dart
import 'package:rasadyar_chicken/data/models/local/widely_used_local_model.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_remain_weight/steward_remain_weight.dart';
import 'package:rasadyar_chicken/data/models/response/steward_sales_info_dashboard/steward_sales_info_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart'
hide ProductModel;
import 'package:rasadyar_chicken/data/repositories/chicken/chicken_repository.dart';
import 'package:rasadyar_chicken/features/common/profile/view.dart';
import 'package:rasadyar_chicken/features/steward/buy/view.dart';
import 'package:rasadyar_chicken/features/steward/home/view.dart';
import 'package:rasadyar_chicken/features/steward/sale/view.dart';
import 'package:rasadyar_chicken/features/steward/segmentation/view.dart';
========
import 'package:rasadyar_chicken/features/common/data/model/local/widely_used_local_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/inventory/inventory_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/iran_province_city/iran_province_city_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/features/steward/data/model/response/steward_remain_weight/steward_remain_weight.dart';
import 'package:rasadyar_chicken/features/steward/data/model/response/steward_sales_info_dashboard/steward_sales_info_dashboard.dart';
import 'package:rasadyar_chicken/features/steward/data/model/response/waiting_arrival/waiting_arrival.dart'
hide ProductModel;
import 'package:rasadyar_chicken/features/common/data/repositories/common/common_repository.dart';
import 'package:rasadyar_chicken/features/steward/data/repositories/steward_repository.dart';
import 'package:rasadyar_chicken/features/common/presentation/page/profile/view.dart';
import 'package:rasadyar_chicken/features/steward/presentation/pages/buy/view.dart';
import 'package:rasadyar_chicken/features/steward/presentation/pages/home/view.dart';
import 'package:rasadyar_chicken/features/steward/presentation/pages/sale/view.dart';
import 'package:rasadyar_chicken/features/steward/presentation/pages/segmentation/view.dart';
import 'package:rasadyar_chicken/features/steward/presentation/routes/routes.dart';
>>>>>>>> develop:packages/chicken/lib/features/steward/presentation/pages/root/logic.dart
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
import 'package:rasadyar_chicken/presentation/utils/utils.dart';
import 'package:rasadyar_core/core.dart';
enum ErrorLocationType { serviceDisabled, permissionDenied, none }
class StewardRootLogic extends GetxController {
DateTime? _lastBackPressed;
RxInt currentPage = 2.obs;
List<Widget> pages = [
BuyPage(),
SalePage(),
HomePage(),
SegmentationPage(),
ProfilePage(),
];
final defaultRoutes = <int, String>{
<<<<<<<< HEAD:packages/chicken/lib/features/steward/root/logic.dart
0: ChickenRoutes.buySteward,
1: ChickenRoutes.saleSteward,
========
0: StewardRoutes.buySteward,
1: StewardRoutes.saleSteward,
>>>>>>>> develop:packages/chicken/lib/features/steward/presentation/pages/root/logic.dart
};
RxList<ProductModel> rolesProductsModel = RxList<ProductModel>();
Rxn<WidelyUsedLocalModel> widelyUsedList = Rxn<WidelyUsedLocalModel>();
Rxn<StewardSalesInfoDashboard> stewardSalesInfoDashboard =
Rxn<StewardSalesInfoDashboard>();
Rxn<StewardRemainWeight> stewardRemainWeight = Rxn<StewardRemainWeight>();
late DioRemote dioRemote;
var tokenService = Get.find<TokenStorageService>();
late CommonRepository commonRepository;
late StewardRepository stewardRepository;
late ChickenLocalDataSource localDatasource;
RxList<ErrorLocationType> errorLocationType = RxList();
RxMap<int, dynamic> inventoryExpandedList = RxMap();
Rxn<ProductModel> inventoryModel = Rxn<ProductModel>();
RxList<IranProvinceCityModel> provinces = <IranProvinceCityModel>[].obs;
// Cancel tokens for API calls
CancelToken? _inventoryCancelToken;
CancelToken? _provincesCancelToken;
@override
void onInit() {
super.onInit();
localDatasource = diChicken.get<ChickenLocalDataSource>();
commonRepository = diChicken.get<CommonRepository>();
stewardRepository = diChicken.get<StewardRepository>();
}
@override
void onReady() {
super.onReady();
if (provinces.isEmpty) {
getProvinces();
}
if (inventoryModel.value == null) {
getRolesProduct();
}
if (rolesProductsModel.isEmpty) {
getRolesProducts();
}
getStewardSaleDashboard();
getStewardRemainWeightData();
if (widelyUsedList.value?.hasInit != true) {
//TODO
localDatasource.initWidleyUsed().then(
(value) => localDatasource.getAllWidely(),
);
}
}
@override
void onClose() {
// Cancel any ongoing requests when controller is disposed
_inventoryCancelToken?.cancel();
_provincesCancelToken?.cancel();
super.onClose();
}
Future<void> onRefresh() async {
await Future.wait([
getRolesProduct(),
getRolesProducts(),
getStewardSaleDashboard(),
getStewardRemainWeightData(),
getProvinces(),
getStewardRemainWeightData(),
]);
}
void toggleExpanded(int index) {
if (inventoryExpandedList.keys.contains(index)) {
inventoryExpandedList.remove(index);
} else {
inventoryExpandedList[index] = false;
}
}
Future<void> getRolesProduct() async {
// Cancel previous request if still running
_inventoryCancelToken?.cancel();
_inventoryCancelToken = CancelToken();
<<<<<<<< HEAD:packages/chicken/lib/features/steward/root/logic.dart
await safeCall<List<ProductModel>?>(
call: () async => await chickenRepository.getRolesProducts(
========
await safeCall<List<InventoryModel>?>(
call: () async => await commonRepository.getInventory(
>>>>>>>> develop:packages/chicken/lib/features/steward/presentation/pages/root/logic.dart
token: tokenService.accessToken.value!,
cancelToken: _inventoryCancelToken,
queryParameters: buildRawQueryParams(role: 'Steward'),
),
onSuccess: (result) {
if (result != null) {
inventoryModel.value = result.first;
}
},
onError: (error, stackTrace) {
if (error is DioException && error.type == DioExceptionType.cancel) {
// Request was cancelled, ignore the error
return;
}
},
);
}
void rootErrorHandler(DioException error) {
handleGeneric(error, () {
tokenService.deleteModuleTokens(Module.chicken);
});
}
void changePage(int index) {
currentPage.value = index;
}
Future<void> getProvinces() async {
// Cancel previous request if still running
_provincesCancelToken?.cancel();
_provincesCancelToken = CancelToken();
try {
<<<<<<<< HEAD:packages/chicken/lib/features/steward/root/logic.dart
final res = await chickenRepository.getProvince(
========
final res = await commonRepository.getProvince(
>>>>>>>> develop:packages/chicken/lib/features/steward/presentation/pages/root/logic.dart
cancelToken: _provincesCancelToken,
);
if (res != null) {
provinces.clear();
provinces.value = res;
}
} catch (e) {
if (e is DioException && e.type == DioExceptionType.cancel) {
// Request was cancelled, ignore the error
return;
}
provinces.clear();
}
}
Future<void> getRolesProducts() async {
safeCall(
<<<<<<<< HEAD:packages/chicken/lib/features/steward/root/logic.dart
call: () async => await chickenRepository.getRolesProducts(
token: tokenService.accessToken.value!,
queryParameters: buildQueryParams(role: 'Steward'),
========
call: () async => await commonRepository.getRolesProducts(
token: tokenService.accessToken.value!,
>>>>>>>> develop:packages/chicken/lib/features/steward/presentation/pages/root/logic.dart
),
onSuccess: (result) {
if (result != null) {
rolesProductsModel.value = result;
}
},
onError: (error, stacktrace) {},
);
}
Future<void> getStewardSaleDashboard() async {
safeCall(
call: () async => await stewardRepository.getStewardSalesInfoDashboard(
token: tokenService.accessToken.value!,
queryParameters: buildRawQueryParams(role: 'Steward'),
),
onSuccess: (result) {
if (result != null) {
stewardSalesInfoDashboard.value = result;
}
},
onError: (error, stacktrace) {},
);
}
Future<void> getStewardRemainWeightData() async {
safeCall(
<<<<<<<< HEAD:packages/chicken/lib/features/steward/root/logic.dart
call: () async => await chickenRepository.getStewardRemainWeight(
========
call: () async => await stewardRepository.getStewardRemainWeight(
>>>>>>>> develop:packages/chicken/lib/features/steward/presentation/pages/root/logic.dart
token: tokenService.accessToken.value!,
),
onSuccess: (result) {
if (result != null) {
stewardRemainWeight.value = result;
}
},
onError: (error, stacktrace) {},
);
}
int getNestedKey() {
switch (currentPage.value) {
case 0:
return stewardFirstKey;
case 1:
return stewardSecondKey;
case 2:
return stewardThirdKey;
case 3:
return stewardFourthKey;
case 4:
return stewardFourthKey;
default:
return stewardThirdKey;
}
}
void onPopScopTaped() async {
final nestedKeyId = getNestedKey();
GlobalKey<NavigatorState>? currentNestedKey = Get.nestedKey(nestedKeyId);
if (currentNestedKey?.currentState?.canPop() == true) {
iLog(currentNestedKey?.currentState?.canPop());
iLog(currentNestedKey?.currentContext);
currentNestedKey?.currentState?.popUntil((route) => route.isFirst);
} else {
final now = DateTime.now();
if (_lastBackPressed == null ||
now.difference(_lastBackPressed!) > Duration(seconds: 2)) {
_lastBackPressed = now;
Get.snackbar(
'خروج از برنامه',
'برای خروج دوباره بازگشت را بزنید',
snackPosition: SnackPosition.TOP,
duration: Duration(seconds: 2),
backgroundColor: AppColor.warning,
);
} else {
await SystemNavigator.pop();
}
}
}
bool isKillHouse(WaitingArrivalModel model) =>
model.allocationType?.split("_")[0].toLowerCase() == "killhouse";
}

View File

@@ -0,0 +1,697 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/chicken.dart';
<<<<<<<< HEAD:packages/chicken/lib/features/steward/root/view.dart
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
import 'package:rasadyar_chicken/features/steward/root/logic.dart';
========
import 'package:rasadyar_chicken/features/common/data/model/response/kill_house_distribution_info/kill_house_distribution_info.dart';
import 'package:rasadyar_chicken/features/steward/presentation/pages/root/logic.dart';
import 'package:rasadyar_chicken/features/steward/presentation/routes/routes.dart';
>>>>>>>> develop:packages/chicken/lib/features/steward/presentation/pages/root/view.dart
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
import 'package:rasadyar_core/core.dart';
class StewardRootPage extends GetView<StewardRootLogic> {
StewardRootPage({super.key});
@override
Widget build(BuildContext context) {
return ObxValue((data) {
return ChickenBasePage(
isFullScreen: true,
isBase: true,
onPopScopTaped: controller.onPopScopTaped,
child: Stack(
children: [
IndexedStack(
children: [
Navigator(
key: Get.nestedKey(stewardFirstKey),
onGenerateRoute: (settings) {
final page = ChickenPages.pages.firstWhere(
(e) => e.name == settings.name,
orElse: () => ChickenPages.pages.firstWhere(
(e) => e.name == StewardRoutes.buySteward,
),
);
return buildRouteFromGetPage(page);
},
),
Navigator(
key: Get.nestedKey(stewardSecondKey),
onGenerateRoute: (settings) {
final page = ChickenPages.pages.firstWhere(
(e) => e.name == settings.name,
orElse: () => ChickenPages.pages.firstWhere(
(e) => e.name == StewardRoutes.saleSteward,
),
);
return buildRouteFromGetPage(page);
},
),
Navigator(
key: Get.nestedKey(stewardThirdKey),
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[2]),
),
Navigator(
key: Get.nestedKey(stewardFourthKey),
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[3]),
),
Navigator(
key: Get.nestedKey(stewardFifthKey),
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[4]),
),
],
index: data.value,
),
Positioned(
bottom: 0,
right: 0,
left: 0,
child: RBottomNavigation(
items: [
RBottomNavigationItem(
label: 'خرید',
icon: Assets.vec.buySvg.path,
isSelected: controller.currentPage.value == 0,
onTap: () {
Get.nestedKey(
stewardFirstKey,
)?.currentState?.popUntil((route) => route.isFirst);
Get.nestedKey(
stewardSecondKey,
)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(0);
},
),
RBottomNavigationItem(
label: 'فروش',
icon: Assets.vec.saleSvg.path,
isSelected: controller.currentPage.value == 1,
onTap: () {
Get.nestedKey(
stewardFirstKey,
)?.currentState?.popUntil((route) => route.isFirst);
Get.nestedKey(
stewardSecondKey,
)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(1);
},
),
RBottomNavigationItem(
label: 'خانه',
icon: Assets.vec.homeSvg.path,
isSelected: controller.currentPage.value == 2,
onTap: () {
Get.nestedKey(
stewardSecondKey,
)?.currentState?.popUntil((route) => route.isFirst);
Get.nestedKey(
stewardFirstKey,
)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(2);
},
),
RBottomNavigationItem(
label: 'قطعه بندی',
icon: Assets.vec.convertCubeSvg.path,
isSelected: controller.currentPage.value == 3,
onTap: () {
Get.nestedKey(
stewardSecondKey,
)?.currentState?.popUntil((route) => route.isFirst);
Get.nestedKey(
stewardFirstKey,
)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(3);
},
),
RBottomNavigationItem(
label: 'پروفایل',
icon: Assets.vec.profileCircleSvg.path,
isSelected: controller.currentPage.value == 4,
onTap: () {
Get.nestedKey(
stewardSecondKey,
)?.currentState?.popUntil((route) => route.isFirst);
Get.nestedKey(
stewardFirstKey,
)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(4);
},
),
],
),
),
],
),
);
}, controller.currentPage);
}
Container _todayShipmentWidget() {
return Container(
height: 70,
width: Get.width / 2,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
clipBehavior: Clip.hardEdge,
child: Row(
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [const Color(0xFFEAEFFF), Colors.white],
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
Assets.icons.cubeScan.svg(width: 30.w, height: 30),
Text(
'بارهای امروز',
textAlign: TextAlign.right,
style: AppFonts.yekan14.copyWith(
color: AppColor.blueNormal,
),
),
],
),
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
Text(
'2،225،256',
textAlign: TextAlign.right,
style: AppFonts.yekan16.copyWith(color: AppColor.textColor),
),
Text(
'کیلوگرم',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.textColor),
),
],
),
),
],
),
);
}
Container _informationLabelCard({
required String title,
required String description,
String unit = 'کیلوگرم',
required String iconPath,
required Color iconColor,
required Color bgDescriptionColor,
required Color bgLabelColor,
}) {
return Container(
height: 82,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
clipBehavior: Clip.hardEdge,
child: Row(
children: [
// Left side with icon and title
Expanded(
child: Container(
height: 82,
decoration: BoxDecoration(
color: bgLabelColor,
borderRadius: BorderRadius.only(
topRight: Radius.circular(8),
bottomRight: Radius.circular(8),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn),
),
Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan14.copyWith(
color: AppColor.mediumGreyDarkActive,
),
),
],
),
),
),
// Right side with description and unit
Expanded(
child: Container(
decoration: BoxDecoration(
color: bgDescriptionColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
Text(
description,
textAlign: TextAlign.right,
style: AppFonts.yekan16.copyWith(
color: AppColor.mediumGreyDarkActive,
),
),
Text(
unit,
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(
color: AppColor.mediumGreyDarkActive,
),
),
],
),
),
),
],
),
);
}
Container _informationIconCard({
required String title,
required String description,
String unit = 'کیلوگرم',
required String iconPath,
required Color iconColor,
required Color bgDescriptionColor,
required Color bgLabelColor,
}) {
return Container(
height: 110,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
clipBehavior: Clip.hardEdge,
child: Stack(
alignment: Alignment.topCenter,
children: [
Positioned(
bottom: 0,
right: 0,
left: 0,
child: Container(
height: 91,
decoration: BoxDecoration(
color: bgDescriptionColor,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 0.25, color: const Color(0xFFB4B4B4)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan14.copyWith(
color: AppColor.mediumGreyDarkActive,
),
),
Text(
description,
textAlign: TextAlign.right,
style: AppFonts.yekan16.copyWith(
color: AppColor.mediumGreyDarkActive,
),
),
Text(
unit,
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(
color: AppColor.mediumGreyDarkActive,
),
),
],
),
),
),
Positioned(
top: 0,
child: Container(
width: 32,
height: 32,
decoration: ShapeDecoration(
color: bgLabelColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
side: BorderSide(width: 0.25, color: const Color(0xFFD5D5D5)),
),
),
child: Center(
child: SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn),
),
),
),
),
],
),
);
}
Widget widelyUsed({
required String title,
required String iconPath,
required VoidCallback onTap,
}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
spacing: 4,
children: [
Container(
width: 48,
height: 48,
padding: EdgeInsets.all(4),
decoration: ShapeDecoration(
color: const Color(0xFFBECDFF),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Container(
width: 40,
height: 40,
decoration: ShapeDecoration(
color: AppColor.blueNormal,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
fit: BoxFit.cover,
),
),
),
Text(
title,
style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal),
),
],
);
}
Widget addWidelyUsed({required VoidCallback onTap}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
spacing: 4,
children: [
Container(
width: 48,
height: 48,
padding: EdgeInsets.all(4),
decoration: ShapeDecoration(
color: const Color(0xFFD9F7F0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Assets.vec.messageAddSvg.svg(
width: 40,
height: 40,
colorFilter: ColorFilter.mode(
AppColor.greenNormal,
BlendMode.srcIn,
),
fit: BoxFit.cover,
),
),
Text(
'افزودن',
style: AppFonts.yekan10.copyWith(color: AppColor.greenDarkHover),
),
],
);
}
/*Column oldPage() {
return Column(
children: [
inventoryWidget(),
ObxValue((data) => broadcastInformationWidget(data.value), controller.killHouseDistributionInfo),
SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
cardWidget(
title: 'ورود به انبار',
iconPath: Assets.icons.whareHouse.path,
onTap: () {
Get.toNamed(ChickenRoutes.enteringTheWarehouse);
},
),
cardWidget(
title: 'فروش داخل استان',
iconPath: Assets.icons.inside.path,
onTap: () {
Get.toNamed(ChickenRoutes.salesInProvince);
},
),
cardWidget(
title: 'فروش خارج استان',
iconPath: Assets.icons.outside.path,
onTap: () {
Get.toNamed(ChickenRoutes.salesOutOfProvince);
},
),
],
),
),
],
);
}
Widget inventoryWidget() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Column(
children: [
const SizedBox(height: 20),
Align(
alignment: Alignment.centerRight,
child: Text('موجودی انبار', style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal)),
),
SizedBox(height: 4),
ObxValue(
(data) =>
data.isEmpty
? Container(
margin: const EdgeInsets.symmetric(vertical: 2),
height: 80,
padding: EdgeInsets.all(6),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.blueNormal, width: 1),
),
child: Center(child: CircularProgressIndicator()),
)
: ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: controller.inventoryList.length,
separatorBuilder: (context, index) => const SizedBox(height: 8),
itemBuilder: (context, index) {
return ObxValue((expand) {
return GestureDetector(
onTap: () {
controller.toggleExpanded(index);
},
behavior: HitTestBehavior.opaque,
child: AnimatedContainer(
onEnd: () {
controller.inventoryExpandedList[index] = !controller.inventoryExpandedList[index]!;
},
margin: const EdgeInsets.symmetric(vertical: 2),
padding: EdgeInsets.all(6),
curve: Curves.easeInOut,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.blueNormal, width: 1),
),
duration: const Duration(seconds: 1),
height: expand.keys.contains(index) ? 250 : 80,
child: inventoryItem(
isExpanded: expand.keys.contains(index) && expand[index]!,
index: index,
model: controller.inventoryList[index],
),
),
);
}, controller.inventoryExpandedList);
},
),
controller.inventoryList,
),
],
),
);
}
Widget inventoryItem({required bool isExpanded, required int index, required ProductModel model}) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 8,
children: [
buildRow('نام محصول', model.name ?? ''),
Visibility(
visible: isExpanded,
child: Column(
spacing: 8,
children: [
buildRow('وزن خریدهای دولتی داخل استان (کیلوگرم)', '0326598653'),
buildRow('وزن خریدهای آزاد داخل استان (کیلوگرم)', model.receiveFreeCarcassesWeight.toString()),
buildRow('وزن خریدهای خارج استان (کیلوگرم)', model.freeBuyingCarcassesWeight.toString()),
buildRow('کل ورودی به انبار (کیلوگرم)', model.totalFreeBarsCarcassesWeight.toString()),
buildRow('کل فروش (کیلوگرم)', model.realAllocatedWeight.toString()),
buildRow('مانده انبار (کیلوگرم)', model.totalRemainWeight.toString()),
],
),
),
],
);
}*/
Widget buildRow(String title, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 2,
child: Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
),
Flexible(
flex: 1,
child: Text(
value,
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
),
],
),
);
}
Widget broadcastInformationWidget(KillHouseDistributionInfo? model) {
return Container(
height: 140,
margin: const EdgeInsets.all(8),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.blueNormal, width: 1),
),
child: model != null
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 10,
children: [
Text(
'اطلاعات ارسالی',
textAlign: TextAlign.right,
style: AppFonts.yekan16Bold.copyWith(
color: AppColor.blueNormal,
),
),
const SizedBox(height: 12),
buildRow(
'فروش و توزیع داخل استان (کیلوگرم)',
model.stewardAllocationsWeight!.toInt().toString(),
),
buildRow(
'فروش و توزیع خارج استان (کیلوگرم)',
model.freeSalesWeight!.toInt().toString(),
),
],
)
: const Center(child: CircularProgressIndicator()),
);
}
Widget cardWidget({
required String title,
required String iconPath,
required VoidCallback onTap,
}) {
return Container(
width: Get.width / 4,
height: 130,
child: GestureDetector(
onTap: onTap,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(width: 1, color: AppColor.blueNormal),
),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SvgGenImage(iconPath).svg(width: 50, height: 50),
SizedBox(height: 4),
Text(
title,
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
],
),
),
),
),
);
}
}