Files
rasadyar_application/packages/chicken/lib/presentation/pages/root/view.dart

643 lines
21 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/chicken.dart';
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
import 'package:rasadyar_core/core.dart';
class RootPage extends GetView<RootLogic> {
const RootPage({super.key});
@override
Widget build(BuildContext context) {
2025-06-15 09:48:52 +03:30
return ObxValue((data) {
return Scaffold(
backgroundColor: AppColor.bgLight,
body: IndexedStack(
children: [
Navigator(
2025-06-22 16:51:22 +03:30
key: Get.nestedKey(0),
2025-06-17 11:46:09 +03:30
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[0]),
),
Navigator(
key: Get.nestedKey(1),
onGenerateRoute: (settings) {
2025-06-17 11:46:09 +03:30
final page = ChickenPages.pages.firstWhere(
(e) => e.name == settings.name,
orElse: () => ChickenPages.pages.firstWhere(
(e) => e.name == ChickenRoutes.outOfProvince,
),
);
return buildRouteFromGetPage(page);
},
),
Navigator(
2025-06-22 16:51:22 +03:30
key: Get.nestedKey(2),
2025-06-17 11:46:09 +03:30
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[2]),
),
Navigator(
2025-06-22 16:51:22 +03:30
key: Get.nestedKey(3),
2025-06-17 11:46:09 +03:30
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[3]),
),
Navigator(
2025-06-22 16:51:22 +03:30
key: Get.nestedKey(4),
2025-06-17 11:46:09 +03:30
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[4]),
),
],
2025-06-15 09:48:52 +03:30
index: data.value,
),
bottomNavigationBar: WaveBottomNavigation(
initPage: controller.currentPage.value,
items: [
WaveBottomNavigationItem(
title: 'بارها',
icon: Assets.vec.truckFastSvg.svg(
width: 32,
height: 32,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
),
2025-06-15 09:48:52 +03:30
WaveBottomNavigationItem(
title: 'خارج استان',
icon: Assets.vec.cubeSearchSvg.svg(
width: 32,
height: 32,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
2025-06-08 11:35:22 +03:30
),
2025-06-15 09:48:52 +03:30
WaveBottomNavigationItem(
title: 'خانه',
icon: Assets.vec.homeSvg.svg(
width: 32,
height: 32,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
2025-06-08 11:35:22 +03:30
),
2025-06-15 09:48:52 +03:30
WaveBottomNavigationItem(
title: 'قطعه بندی',
icon: Assets.vec.convertCubeSvg.svg(
width: 32,
height: 32,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
2025-06-08 11:35:22 +03:30
),
2025-06-15 09:48:52 +03:30
WaveBottomNavigationItem(
title: 'پروفایل',
icon: Assets.vec.userSvg.svg(
width: 32,
height: 32,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
2025-06-08 11:35:22 +03:30
),
2025-06-15 09:48:52 +03:30
],
onPageChanged: (index) {
controller.changePage(index);
2025-06-15 09:48:52 +03:30
},
),
);
}, controller.currentPage);
2025-06-08 11:35:22 +03:30
}
Container _todayShipmentWidget() {
return Container(
height: 70,
width: Get.width / 2,
2025-06-17 11:46:09 +03:30
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
2025-06-08 11:35:22 +03:30
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, height: 30),
Text(
'بارهای امروز',
textAlign: TextAlign.right,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan14.copyWith(
color: AppColor.blueNormal,
),
2025-06-08 11:35:22 +03:30
),
],
),
),
),
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,
2025-06-17 11:46:09 +03:30
borderRadius: BorderRadius.only(
topRight: Radius.circular(8),
bottomRight: Radius.circular(8),
),
2025-06-08 11:35:22 +03:30
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
2025-06-17 11:46:09 +03:30
SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn),
),
2025-06-08 11:35:22 +03:30
Text(
title,
textAlign: TextAlign.right,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan14.copyWith(
color: AppColor.mediumGreyDarkActive,
),
2025-06-08 11:35:22 +03:30
),
],
),
),
),
// Right side with description and unit
Expanded(
child: Container(
decoration: BoxDecoration(
color: bgDescriptionColor,
2025-06-17 11:46:09 +03:30
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8),
),
2025-06-08 11:35:22 +03:30
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
Text(
description,
textAlign: TextAlign.right,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan16.copyWith(
color: AppColor.mediumGreyDarkActive,
),
2025-06-08 11:35:22 +03:30
),
Text(
unit,
textAlign: TextAlign.center,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan12.copyWith(
color: AppColor.mediumGreyDarkActive,
),
2025-06-08 11:35:22 +03:30
),
],
),
),
),
],
),
);
}
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,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan14.copyWith(
color: AppColor.mediumGreyDarkActive,
),
2025-06-08 11:35:22 +03:30
),
Text(
description,
textAlign: TextAlign.right,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan16.copyWith(
color: AppColor.mediumGreyDarkActive,
),
2025-06-08 11:35:22 +03:30
),
Text(
unit,
textAlign: TextAlign.center,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan12.copyWith(
color: AppColor.mediumGreyDarkActive,
),
2025-06-08 11:35:22 +03:30
),
],
),
),
),
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(
2025-06-17 11:46:09 +03:30
child: SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn),
),
2025-06-08 11:35:22 +03:30
),
),
),
],
),
);
}
2025-06-17 11:46:09 +03:30
Widget widelyUsed({
required String title,
required String iconPath,
required VoidCallback onTap,
}) {
2025-06-08 11:35:22 +03:30
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),
2025-06-17 11:46:09 +03:30
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
2025-06-08 11:35:22 +03:30
),
child: Container(
width: 40,
height: 40,
decoration: ShapeDecoration(
color: AppColor.blueNormal,
2025-06-17 11:46:09 +03:30
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
2025-06-08 11:35:22 +03:30
),
child: SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
fit: BoxFit.cover,
),
),
),
2025-06-17 11:46:09 +03:30
Text(
title,
style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal),
),
2025-06-08 11:35:22 +03:30
],
);
}
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),
2025-06-17 11:46:09 +03:30
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
2025-06-08 11:35:22 +03:30
),
child: Assets.vec.messageAddSvg.svg(
width: 40,
height: 40,
2025-06-17 11:46:09 +03:30
colorFilter: ColorFilter.mode(
AppColor.greenNormal,
BlendMode.srcIn,
),
2025-06-08 11:35:22 +03:30
fit: BoxFit.cover,
),
),
2025-06-17 11:46:09 +03:30
Text(
'افزودن',
style: AppFonts.yekan10.copyWith(color: AppColor.greenDarkHover),
),
2025-06-08 11:35:22 +03:30
],
);
}
2025-06-15 17:16:04 +03:30
/*Column oldPage() {
2025-06-08 11:35:22 +03:30
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);
2025-06-08 11:35:22 +03:30
},
),
cardWidget(
title: 'فروش خارج استان',
iconPath: Assets.icons.outside.path,
onTap: () {
Get.toNamed(ChickenRoutes.salesOutOfProvince);
2025-06-08 11:35:22 +03:30
},
),
],
),
),
],
);
}
Widget inventoryWidget() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Column(
children: [
const SizedBox(height: 20),
Align(
alignment: Alignment.centerRight,
2025-06-08 11:35:22 +03:30
child: Text('موجودی انبار', style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal)),
),
SizedBox(height: 4),
ObxValue(
2025-06-15 09:48:52 +03:30
(data) =>
data.isEmpty
? Container(
2025-06-15 09:48:52 +03:30
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(
2025-06-15 09:48:52 +03:30
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);
},
2025-06-15 09:48:52 +03:30
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,
),
],
),
);
}
2025-06-08 11:35:22 +03:30
Widget inventoryItem({required bool isExpanded, required int index, required InventoryModel model}) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 8,
children: [
buildRow('نام محصول', model.name ?? ''),
Visibility(
visible: isExpanded,
child: Column(
spacing: 8,
children: [
buildRow('وزن خریدهای دولتی داخل استان (کیلوگرم)', '0326598653'),
2025-06-08 11:35:22 +03:30
buildRow('وزن خریدهای آزاد داخل استان (کیلوگرم)', model.receiveFreeCarcassesWeight.toString()),
buildRow('وزن خریدهای خارج استان (کیلوگرم)', model.freeBuyingCarcassesWeight.toString()),
buildRow('کل ورودی به انبار (کیلوگرم)', model.totalFreeBarsCarcassesWeight.toString()),
buildRow('کل فروش (کیلوگرم)', model.realAllocatedWeight.toString()),
buildRow('مانده انبار (کیلوگرم)', model.totalRemainWeight.toString()),
],
),
),
],
);
2025-06-15 17:16:04 +03:30
}*/
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,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
),
Flexible(
flex: 1,
child: Text(
value,
textAlign: TextAlign.center,
2025-06-17 11:46:09 +03:30
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,
2025-06-17 11:46:09 +03:30
style: AppFonts.yekan16Bold.copyWith(
color: AppColor.blueNormal,
),
),
const SizedBox(height: 12),
2025-06-17 11:46:09 +03:30
buildRow(
'فروش و توزیع داخل استان (کیلوگرم)',
model.stewardAllocationsWeight!.toInt().toString(),
),
buildRow(
'فروش و توزیع خارج استان (کیلوگرم)',
model.freeSalesWeight!.toInt().toString(),
),
],
)
: const Center(child: CircularProgressIndicator()),
);
}
2025-06-17 11:46:09 +03:30
Widget cardWidget({
required String title,
required String iconPath,
required VoidCallback onTap,
}) {
2025-06-15 09:48:52 +03:30
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),
),
2025-06-15 09:48:52 +03:30
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
2025-06-15 09:48:52 +03:30
SvgGenImage(iconPath).svg(width: 50, height: 50),
SizedBox(height: 4),
Text(
2025-06-15 09:48:52 +03:30
title,
textAlign: TextAlign.center,
2025-06-15 09:48:52 +03:30
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
],
),
),
),
),
2025-06-15 09:48:52 +03:30
);
}
}