feat : new dashboard and inventory_widget

This commit is contained in:
2025-10-08 17:01:33 +03:30
parent 665ef9abf7
commit be6e16f54e
28 changed files with 1020 additions and 126 deletions

View File

@@ -1,5 +1,6 @@
import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart';
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/presentation/pages/steward/root/logic.dart';
import 'package:rasadyar_core/core.dart';
@@ -9,16 +10,42 @@ class HomeLogic extends GetxController {
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo = Rxn<KillHouseDistributionInfo>();
Rxn<BarInformation> barInformation = Rxn();
RxList<Map<String, String?>> inventoryItems = [
{'خریدهای دولتی داخل استان': null},
{'خریدهای آزاد داخل استان': null},
{'وزن خریدهای خارج استان': null},
{'کل ورودی به انبار': null},
{'کل فروش': null},
{'مانده انبار': null},
].obs;
RxList<Map<String, String>> broadcastItems = [
{'وزن دولتی': '2،225،256'},
{'وزن آزاد': '2،225،256'},
{'فروش دولتی': '2،225،256'},
{'فروش آزاد': '2،225،256'},
{'توزیع داخل استان': '2،225،256'},
{'توزیع خارج استان': '2،225،256'},
{'قطعه بندی': '2،225،256'},
].obs;
RxBool isExpanded = false.obs;
@override
void onReady() {
super.onReady();
refreshData();
}
Future<void> refreshData() async {
await Future.wait([getGeneralBarsInformation(), getTodayBars(), getDistributionInformation()]);
await Future.wait([
getGeneralBarsInformation(),
getTodayBars(),
getDistributionInformation(),
rootLogic.getRolesProducts(),
rootLogic.getInventory(),
]);
}
Future<void> getGeneralBarsInformation() async {

View File

@@ -17,14 +17,16 @@ class HomePage extends GetView<HomeLogic> {
scrollable: true,
isBase: true,
onRefresh: controller.refreshData,
child: Column(
children: [
SizedBox(height: 18.h),
mainInformation(),
SizedBox(height: 8.h),
WidelyUsedWidget(),
SizedBox(height: 20),
],
child: SingleChildScrollView(
child: Column(
children: [
SizedBox(height: 18.h),
mainInformation(),
SizedBox(height: 8.h),
WidelyUsedWidget(),
SizedBox(height: 20),
],
),
),
);
}
@@ -68,32 +70,13 @@ class HomePage extends GetView<HomeLogic> {
),
SizedBox(height: 8),
_todayShipmentWidget(),
//_todayShipmentWidget2(),
_todayShipmentWidget2(),
_inventoryWidget(),
Row(
children: [
Text(
'اطلاعات بارها',
textAlign: TextAlign.right,
style: AppFonts.yekan16,
),
],
),
_informationShipment(),
Row(
children: [
Text(
'اطلاعات توزیع',
textAlign: TextAlign.right,
style: AppFonts.yekan16,
),
],
),
distributionInformationWidget(),
_inventoryListWidget(),
SizedBox(height: 8),
broadCastList(),
SizedBox(height: 8),
commitmentsList(),
],
),
)
@@ -108,7 +91,7 @@ class HomePage extends GetView<HomeLogic> {
children: [Icon(CupertinoIcons.chevron_down, size: 18)],
),
_todayShipmentWidget(),
// _todayShipmentWidget2(),
_todayShipmentWidget2(),
_inventoryWidget(),
],
),
@@ -149,6 +132,93 @@ class HomePage extends GetView<HomeLogic> {
);
}
//todo
Widget broadCastList() {
return ObxValue((data) {
return Column(
children: [
Row(
children: [
SizedBox(width: 5.w),
Text('اطلاعات پخش', textAlign: TextAlign.right, style: AppFonts.yekan16),
],
),
SizedBox(height: 8.h),
Row(
spacing: 8,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: broadcastItem(
title: 'وزن دولتی',
titleBgColor: const Color(0xFFB8E7DC),
valueBgColor: const Color(0xFFE6FAF5),
value: data.value?.totalGovernmentalInputWeight.separatedByComma,
),
),
Expanded(
child: broadcastItem(
title: 'وزن آزاد',
value: data.value?.totalFreeInputWeight.separatedByComma,
titleBgColor: const Color(0xFFDDE2F0),
valueBgColor: const Color(0xFFEAEFFF),
),
),
Expanded(
child: broadcastItem(
title: 'فروش دولتی',
value: data.value?.totalGovernmentalOutputWeight.separatedByComma,
titleBgColor: const Color(0xFFEBC4CE),
valueBgColor: const Color(0xFFEDDCE0),
),
),
Expanded(
child: broadcastItem(
title: 'فروش آزاد',
value: data.value?.totalFreeOutputWeight.separatedByComma,
titleBgColor: const Color(0xFFC2D3F2),
valueBgColor: const Color(0xFFECF2FF),
),
),
],
),
SizedBox(height: 8.h),
Row(
spacing: 8,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: broadcastItem(
title: 'مانده دولتی',
value: data.value?.totalGovernmentalRemainWeight.separatedByComma,
titleBgColor: const Color(0xFFB8E7DC),
valueBgColor: const Color(0xFFE6FAF5),
),
),
Expanded(
child: broadcastItem(
title: 'مانده آزاد',
value: data.value?.totalFreeRemainWeight.separatedByComma,
titleBgColor: const Color(0xFFDDE2F0),
valueBgColor: const Color(0xFFEAEFFF),
),
),
Expanded(
child: broadcastItem(
title: 'فروش خارج استان',
value: data.value?.totalStewardFreeSaleBarCarcassesWeight.separatedByComma,
titleBgColor: const Color(0xFFEBC4CE),
valueBgColor: const Color(0xFFEDDCE0),
),
),
],
),
],
);
}, controller.rootLogic.stewardSalesInfoDashboard);
}
Widget distributionInformationWidget() {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
@@ -247,9 +317,9 @@ class HomePage extends GetView<HomeLogic> {
isLoading: data.value == null,
description: data.value?.totalRemainWeight.separatedByCommaFa ?? '0',
iconPath: Assets.vec.cubeSearchSvg.path,
iconColor: const Color(0xFF426060),
bgDescriptionColor: const Color(0xFFC7DFE0),
bgLabelColor: const Color(0xFFA5D1D2),
bgDescriptionColor: const Color(0xFFEAEFFF),
bgLabelColor: const Color(0xFFBDD4FF),
iconColor: AppColor.textColor,
),
),
Expanded(
@@ -279,16 +349,29 @@ class HomePage extends GetView<HomeLogic> {
child: ObxValue(
(data) => _informationLabelCard(
title: 'بارهای امروز',
titleColor: AppColor.blueNormal,
borderColor: Color(0xFF77A6FF),
titleColor: AppColor.textColor,
borderColor: Color(0xFFFFAE00),
isLoading: data.value == null,
description: data.value?.separatedByCommaFa ?? '0',
iconPath: Assets.vec.cubeScanWithLabelSvg.path,
icon: Container(
width: 24.w,
height: 24.h,
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
color: const Color(0xFFFFAE00),
borderRadius: BorderRadius.circular(8),
),
child: Assets.vec.cubeScanSvg.svg(
width: 12.w,
height: 12.h,
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
),
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [AppColor.blueLight, Colors.white],
colors: [const Color(0xFFFFD883), const Color(0xFFFFFBF1)],
),
),
controller.totalWeightTodayBars,
@@ -298,18 +381,31 @@ class HomePage extends GetView<HomeLogic> {
Expanded(
child: ObxValue((data) {
return _informationLabelCard(
title: 'درانتظار تایید',
borderColor: AppColor.greenNormal,
title: 'درانتظار',
borderColor: const Color(0xFF9758FF),
isLoading: data.value == null,
description: data.value?.totalNotEnteredBars.separatedByCommaFa ?? '0',
unit:
'(${data.value?.totalNotEnteredKillHouseRequestsWeight.separatedByCommaFa})\nکیلوگرم',
iconPath: Assets.vec.cubeCardSvg.path,
icon: Container(
width: 24.w,
height: 24.h,
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
color: const Color(0xFF9758FF),
borderRadius: BorderRadius.circular(8),
),
child: Assets.vec.cubeCardFreeSvg.svg(
width: 12.w,
height: 12.h,
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
),
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [const Color(0xFFD9F7F0), Colors.white],
colors: [const Color(0xFFD8C1FF), const Color(0xFFFBF9FF)],
),
);
}, controller.barInformation),
@@ -320,50 +416,103 @@ class HomePage extends GetView<HomeLogic> {
}
Widget _todayShipmentWidget2() {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
child: Row(
spacing: 8,
children: [
Expanded(
child: ObxValue(
(data) => _informationLabelCard(
return ObxValue((data) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
child: Row(
spacing: 8,
children: [
Expanded(
child: _informationLabelCard(
title: 'مانده دولتی',
titleColor: AppColor.blueNormal,
borderColor: Color(0xFFFFAE00),
isLoading: data.value == null,
description: data.value?.separatedByCommaFa ?? '0',
description: data.value?.totalGovernmentalRemainWeight?.separatedByCommaFa ?? '0',
iconPath: Assets.vec.cubeCardGovermentSvg.path,
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFD47A), Colors.white],
),
iconColor: AppColor.textColor,
bgDescriptionColor: const Color(0xFFF5ECEE),
bgLabelColor: const Color(0xFFDEC1C7),
),
controller.totalWeightTodayBars,
),
),
Expanded(
child: ObxValue((data) {
return _informationLabelCard(
Expanded(
child: _informationLabelCard(
title: 'مانده آزاد',
borderColor: const Color(0xFF9758FF),
isLoading: data.value == null,
description: data.value?.totalNotEnteredBars.separatedByCommaFa ?? '0',
unit:
'(${data.value?.totalNotEnteredKillHouseRequestsWeight.separatedByCommaFa})\nکیلوگرم',
description: data.value?.totalFreeRemainWeight.separatedByCommaFa ?? '0',
unit: 'کیلوگرم',
iconPath: Assets.vec.cubeCardFreeSvg.path,
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [const Color(0xFFD3B9FF), Colors.white],
),
);
}, controller.barInformation),
iconColor: AppColor.textColor,
bgDescriptionColor: const Color(0xFFD0ECED),
bgLabelColor: const Color(0xFFA5D1D2),
),
),
],
),
);
}, controller.rootLogic.stewardSalesInfoDashboard);
}
Widget _inventoryListWidget() {
return ObxValue((data) {
var model = data[0];
return Container(
padding: EdgeInsets.fromLTRB(16.w, 0, 11.w, 0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: const Color(0xB2EDF1FF),
),
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
inventoryListItem(
title: 'خریدهای دولتی داخل استان',
value: model.receiveGovernmentalCarcassesWeight.separatedByComma,
),
Divider(),
inventoryListItem(
title: 'خریدهای آزاد داخل استان',
value: model.receiveFreeCarcassesWeight?.separatedByComma,
),
Divider(),
inventoryListItem(
title: 'وزن خریدهای خارج استان',
value: model.freeBuyingCarcassesWeight?.separatedByComma,
),
Divider(),
inventoryListItem(
title: 'کل ورودی به انبار',
value: model.totalCarcassesWeight?.separatedByComma,
),
Divider(),
inventoryListItem(title: 'کل فروش', value: model.realAllocatedWeight?.separatedByComma),
Divider(),
inventoryListItem(
title: 'مانده انبار',
value: model.totalRemainWeight?.separatedByComma,
),
],
),
);
}, controller.rootLogic.rolesProductsModel);
}
Widget inventoryListItem({required String title, required String? value}) {
return Container(
height: 45.h,
child: Row(
children: [
Text(
title,
style: AppFonts.yekan14.copyWith(color: const Color(0xFF353535), height: 1.2),
),
Spacer(),
value == null
? Center(child: CupertinoActivityIndicator())
: Text(value, style: AppFonts.yekan14.copyWith(color: const Color(0xFF353535))),
SizedBox(width: 20.w),
Text('کیلوگرم', style: AppFonts.yekan10.copyWith(color: const Color(0xFF353535))),
],
),
);
@@ -372,8 +521,9 @@ class HomePage extends GetView<HomeLogic> {
Container _informationLabelCard({
required String title,
required String description,
required String iconPath,
required Color bgDescriptionColor,
String? iconPath,
Widget? icon,
Color? borderColor,
String unit = 'کیلوگرم',
bool isLoading = false,
@@ -383,7 +533,7 @@ class HomePage extends GetView<HomeLogic> {
LinearGradient? gradient,
}) {
return Container(
height: 82,
height: 65.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: borderColor != null ? Border.all(width: 1, color: borderColor) : null,
@@ -405,15 +555,16 @@ class HomePage extends GetView<HomeLogic> {
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
spacing: 5,
children: [
SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: iconColor != null
? ColorFilter.mode(iconColor, BlendMode.srcIn)
: null,
),
icon ??
SvgGenImage.vec(iconPath!).svg(
width: 24.w,
height: 24.h,
colorFilter: iconColor != null
? ColorFilter.mode(iconColor, BlendMode.srcIn)
: null,
),
Text(
title,
textAlign: TextAlign.right,
@@ -639,6 +790,64 @@ class HomePage extends GetView<HomeLogic> {
);
}
Widget broadcastItem({
int? width,
int? height,
String? title,
String? value,
String? unit,
Color? titleBgColor,
Color? valueBgColor,
Color? unitBgColor,
TextStyle? titleStyle,
TextStyle? valueStyle,
TextStyle? unitStyle,
}) {
return Container(
height: height?.h ?? 73.h,
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(color: valueBgColor, borderRadius: BorderRadius.circular(8)),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
padding: EdgeInsets.symmetric(vertical: 4.h),
decoration: BoxDecoration(color: titleBgColor),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title ?? 'بدون تیتر',
textAlign: TextAlign.center,
style: titleStyle ?? AppFonts.yekan12.copyWith(color: const Color(0xFF3E3E3E)),
),
],
),
),
SizedBox(height: 4),
(value != null)
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 11.0),
child: Text(
value,
textAlign: TextAlign.right,
style: valueStyle ?? AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
)
: Center(child: CupertinoActivityIndicator()),
Text(
unit ?? 'کیلوگرم',
textAlign: TextAlign.center,
style: unitStyle ?? AppFonts.yekan10.copyWith(color: Color(0xFF717171)),
),
SizedBox(height: 4.h),
],
),
);
}
Widget cardWidget({
required String title,
required String iconPath,
@@ -674,4 +883,114 @@ class HomePage extends GetView<HomeLogic> {
),
);
}
Widget commitmentsList() {
return ObxValue((data) {
return Column(
spacing: 2.h,
children: [
Row(
children: [
SizedBox(width: 5.w),
Text('تعهدات', textAlign: TextAlign.right, style: AppFonts.yekan16),
],
),
commitmentsItemList(
title: 'تعهد دولتی توزیع داخل استان',
value: data.value?.totalCommitmentSellingInProvinceGovernmentalWeight.separatedByComma,
labelColor: const Color(0xFFB9E8DC),
bgColor: const Color(0xFFF3F9F8),
),
commitmentsItemList(
title: 'توزیع دولتی داخل استان',
value: data.value?.totalSellingInProvinceGovernmentalWeight.separatedByComma,
labelColor: const Color(0xFFC3D4F3),
bgColor: const Color(0xFFECF3FF),
),
commitmentsItemList(
title: 'باقیمانده تعهد دولتی توزیع داخل استان',
value: data
.value
?.totalCommitmentSellingInProvinceGovernmentalRemainWeight
.separatedByComma,
labelColor: const Color(0xFFEBC5CE),
bgColor: const Color(0xFFFFF1F4),
),
commitmentsItemList(
title: 'تعهد آزاد توزیع داخل استان',
value: data.value?.totalCommitmentSellingInProvinceFreeWeight.separatedByComma,
labelColor: const Color(0xFFC7DADA),
bgColor: const Color(0xFFE5F7F7),
),
commitmentsItemList(
title: 'توزیع آزاد داخل استان',
value: data.value?.totalSellingInProvinceFreeWeight.separatedByComma,
labelColor: const Color(0xFFE0D6ED),
bgColor: const Color(0xFFF5EDFF),
),
commitmentsItemList(
title: 'باقیمانده تعهد آزاد توزیع داخل استان',
value: data.value?.totalCommitmentSellingInProvinceFreeRemainWeight.separatedByComma,
labelColor: const Color(0xFFEBC5CE),
bgColor: const Color(0xFFFFF1F4),
),
],
);
}, controller.rootLogic.stewardSalesInfoDashboard);
}
Container commitmentsItemList({
required String title,
required String? value,
required Color labelColor,
required Color bgColor,
}) {
return Container(
width: Get.width,
child: Row(
children: [
Container(height: 48.h, width: 4.w, color: labelColor),
Expanded(
child: Container(
height: 48.h,
padding: EdgeInsets.symmetric(horizontal: 14.w),
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8),
),
),
child: Row(
children: [
Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan12.copyWith(color: AppColor.textColor),
),
Spacer(),
value == null
? Center(child: CupertinoActivityIndicator())
: Text(
value,
textAlign: TextAlign.right,
style: AppFonts.yekan16.copyWith(color: AppColor.textColor),
),
SizedBox(width: 8.w),
Text(
'کیلوگرم',
textAlign: TextAlign.right,
style: AppFonts.yekan10.copyWith(color: AppColor.textColor),
),
],
),
),
),
],
),
);
}
}