Files
rasadyar_application/packages/chicken/lib/features/poultry_science/home/view.dart

449 lines
14 KiB
Dart
Raw Normal View History

2025-09-06 17:22:19 +03:30
import 'package:flutter/cupertino.dart' hide LinearGradient;
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/features/poultry_science/presentation/routes/routes.dart';
2025-09-20 13:12:16 +03:30
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
2025-09-25 17:25:55 +03:30
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
2025-09-06 17:22:19 +03:30
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/widget/custom/information_card_widget.dart';
2025-09-06 17:22:19 +03:30
import 'logic.dart';
class PoultryScienceHomePage extends GetView<PoultryScienceHomeLogic> {
const PoultryScienceHomePage({super.key});
@override
Widget build(BuildContext context) {
2025-09-25 17:25:55 +03:30
return ChickenBasePage(
isBase: true,
hasNotification: true,
hasNews: true,
scrollable: true,
2025-09-24 16:24:45 +03:30
2025-10-07 14:21:09 +03:30
child: Column(
children: [
2025-10-14 16:24:46 +03:30
SizedBox(height: 18.h),
2025-10-07 14:21:09 +03:30
InkWell(
onTap: () {
controller.isExpanded.value = !controller.isExpanded.value;
},
child: Stack(
clipBehavior: Clip.none,
children: [
Container(
margin: EdgeInsetsGeometry.all(6),
2025-09-25 17:25:55 +03:30
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(
width: 0.50,
color: const Color(0xFFA9A9A9),
),
2025-09-22 16:21:17 +03:30
),
2025-10-07 14:21:09 +03:30
child: ObxValue((data) {
return AnimatedSize(
duration: Duration(milliseconds: 300),
child: data.value
? mainItemWidget()
: mainItemWidgetExpanded(),
2025-10-07 14:21:09 +03:30
);
}, controller.isExpanded),
),
Positioned(
top: -10,
right: 20,
child: Container(
height: 32.h,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(
width: 0.50,
color: const Color(0xFFA9A9A9),
),
2025-10-07 14:21:09 +03:30
),
padding: EdgeInsets.symmetric(horizontal: 8),
child: Row(
spacing: 8,
children: [
Assets.vec.chicken2Svg.svg(
width: 16.w,
height: 16.h,
colorFilter: ColorFilter.mode(
AppColor.blueDark,
BlendMode.srcIn,
),
2025-10-07 14:21:09 +03:30
),
Text(
'اطلاعات فارم‌ها',
textAlign: TextAlign.right,
style: AppFonts.yekan16Bold.copyWith(
color: AppColor.iconColor,
),
2025-10-07 14:21:09 +03:30
),
],
),
2025-09-22 16:21:17 +03:30
),
2025-09-25 17:25:55 +03:30
),
2025-10-07 14:21:09 +03:30
],
),
2025-09-25 17:25:55 +03:30
),
2025-10-07 14:21:09 +03:30
SizedBox(height: 10),
widelyWidget(),
SizedBox(height: 20),
],
),
2025-09-06 17:22:19 +03:30
);
}
Padding mainItemWidget() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 8),
firstTagInformation(),
secondTagInformation(),
],
),
);
}
Padding mainItemWidgetExpanded() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
2025-09-22 16:21:17 +03:30
SizedBox(height: 8),
/* Row(
spacing: 8,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: 40,
height: 40,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
side: BorderSide(width: 0.25, color: const Color(0xFFB0B0B0)),
borderRadius: BorderRadius.circular(4),
),
),
2025-09-20 12:25:10 +03:30
child: Assets.images.liveChicken.image(
width: 40.w,
height: 40.h,
fit: BoxFit.cover,
),
),
Text(
2025-09-20 12:25:10 +03:30
'فارم ها',
textAlign: TextAlign.right,
style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyDarkActive),
),
Spacer(),
AnimatedRotation(
turns: 180,
duration: Duration(milliseconds: 3000),
child: Icon(CupertinoIcons.chevron_up, size: 18),
),
],
2025-09-22 16:21:17 +03:30
),*/
SizedBox(height: 8),
firstTagInformation(),
Row(
children: [
Text(
'اطلاعات جوجه‌ریزی',
textAlign: TextAlign.right,
style: AppFonts.yekan16,
),
],
),
secondTagInformation(),
thirdTagInformation(),
ageCardInformation(),
],
),
);
}
Widget firstTagInformation() {
2025-09-06 17:22:19 +03:30
return Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
child: ObxValue((data) {
List<InformationTagData>? items = data['first']!;
2025-09-06 17:22:19 +03:30
return Row(
spacing: 8,
children: List.generate(
items.length,
(index) => Expanded(child: InformationTag(data: items[index])),
),
2025-09-06 17:22:19 +03:30
);
}, controller.tagInfo),
2025-09-06 17:22:19 +03:30
);
}
Widget secondTagInformation() {
2025-09-06 17:22:19 +03:30
return Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
child: ObxValue((data) {
List<InformationTagData>? items = data['second']!;
return Row(
spacing: 8,
children: List.generate(
items.length,
(index) => Expanded(child: InformationTag(data: items[index])),
2025-09-06 17:22:19 +03:30
),
);
}, controller.tagInfo),
2025-09-06 17:22:19 +03:30
);
}
Widget thirdTagInformation() {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
child: ObxValue((data) {
List<InformationTagData>? items = data['third']!;
return Row(
spacing: 8,
children: List.generate(
items.length,
(index) => Expanded(child: InformationTag(data: items[index])),
2025-09-06 17:22:19 +03:30
),
);
}, controller.tagInfo),
2025-09-06 17:22:19 +03:30
);
}
Widget ageCardInformation() {
2025-09-06 17:22:19 +03:30
return Padding(
padding: EdgeInsets.fromLTRB(30.w, 8, 30.w, 13),
child: ObxValue((data) {
return Row(
spacing: 8,
children: List.generate(
data.length,
(index) => Expanded(child: InformationCard(data: data[index])),
2025-09-06 17:22:19 +03:30
),
);
}, controller.ageCardData),
2025-09-06 17:22:19 +03:30
);
}
//region Widely Used Widget
2025-09-07 20:24:14 +03:30
Widget widelyWidget() {
2025-09-22 16:21:17 +03:30
return Container(
margin: EdgeInsetsGeometry.all(6),
decoration: BoxDecoration(
2025-09-25 17:25:55 +03:30
color: Colors.white,
2025-09-22 16:21:17 +03:30
borderRadius: BorderRadius.circular(8),
2025-09-25 17:25:55 +03:30
border: Border.all(width: 0.50, color: const Color(0xFFA9A9A9)),
2025-09-22 16:21:17 +03:30
),
child: Stack(
clipBehavior: Clip.none,
children: [
Padding(
padding: EdgeInsets.fromLTRB(12.w, 24.h, 12.w, 16.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
widelyUsed(
title: 'بازرسی',
iconPath: Assets.vec.cubeSearchSvg.path,
isOnEdit: false,
cardColor: AppColor.greenLightActive,
labelColor: AppColor.greenNormal,
textColor: AppColor.textColor,
onTap: () async {
controller.rootLogic.currentPage.value = 0;
2025-09-20 13:12:16 +03:30
Get.toNamed(
PoultryScienceRoutes.inspectionPoultryScience,
id: poultryFirstKey,
);
2025-09-22 16:21:17 +03:30
},
),
2025-09-07 20:24:14 +03:30
2025-09-22 16:21:17 +03:30
widelyUsed(
title: 'ثبت کشتار',
iconPath: Assets.vec.noteRemoveSvg.path,
isOnEdit: false,
cardColor: AppColor.blueLightActive,
labelColor: AppColor.blueNormalOld,
textColor: AppColor.textColor,
onTap: () async {
controller.rootLogic.currentPage.value = 0;
Get.toNamed(
PoultryScienceRoutes.genocidePoultryScience,
id: poultryFirstKey,
);
2025-09-22 16:21:17 +03:30
},
),
widelyUsed(
title: 'فارم ها',
iconPath: Assets.vec.cubeScanSvg.path,
cardColor: Color(0xFFFFCFA3),
labelColor: Color(0xFFF68D2B),
textColor: AppColor.textColor,
isOnEdit: false,
onTap: () async {
controller.rootLogic.currentPage.value = 0;
Get.toNamed(
PoultryScienceRoutes.farmPoultryScience,
id: poultryFirstKey,
);
2025-09-22 16:21:17 +03:30
},
),
2025-09-07 20:24:14 +03:30
2025-09-22 16:21:17 +03:30
widelyUsed(
2025-09-23 11:18:33 +03:30
title: 'جوجه‌ریزی فعال',
2025-09-22 16:21:17 +03:30
iconPath: Assets.vec.boxTickSvg.path,
isOnEdit: false,
cardColor: Color(0xFFD9BEFF),
labelColor: Color(0xFF9757FF),
textColor: AppColor.textColor,
onTap: () async {
controller.rootLogic.currentPage.value = 0;
Get.toNamed(
PoultryScienceRoutes.activeHatchingPoultryScience,
id: poultryFirstKey,
);
2025-09-22 16:21:17 +03:30
},
),
],
),
2025-09-07 20:24:14 +03:30
),
2025-09-22 16:21:17 +03:30
Positioned(
2025-09-25 17:25:55 +03:30
top: -17,
2025-09-22 16:21:17 +03:30
right: 11,
child: Container(
2025-09-25 17:25:55 +03:30
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 0.50, color: const Color(0xFFA9A9A9)),
),
child: Text(
'پر کاربردها',
textAlign: TextAlign.right,
style: AppFonts.yekan16,
),
2025-09-22 16:21:17 +03:30
),
),
],
),
2025-09-07 20:24:14 +03:30
);
}
Widget widelyUsed({
required String title,
required String iconPath,
required VoidCallback onTap,
required bool isOnEdit,
Color? cardColor,
Color? labelColor,
Color? textColor,
}) {
return GestureDetector(
onTap: !isOnEdit ? onTap : null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
spacing: 4,
children: [
Stack(
clipBehavior: Clip.none,
children: [
Container(
width: 48,
height: 48,
padding: EdgeInsets.all(4),
decoration: ShapeDecoration(
color: cardColor ?? Color(0xFFBECDFF),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
2025-09-07 20:24:14 +03:30
),
child: Container(
width: 40,
height: 40,
decoration: ShapeDecoration(
color: labelColor ?? AppColor.blueNormal,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
2025-09-07 20:24:14 +03:30
),
child: SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(
Colors.white,
BlendMode.srcIn,
),
2025-09-07 20:24:14 +03:30
fit: BoxFit.cover,
),
),
),
Visibility(
visible: isOnEdit,
child: Container(
width: 48,
height: 48,
padding: EdgeInsets.all(4),
decoration: ShapeDecoration(
color: Colors.white60,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
2025-09-07 20:24:14 +03:30
),
),
),
Visibility(
visible: isOnEdit,
child: Positioned(
top: -15,
left: -12,
child: SizedBox(
width: 32.w,
height: 32.h,
child: GestureDetector(
onTap: () {},
behavior: HitTestBehavior.translucent,
child: Center(
child: Container(
width: 16,
height: 16,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
2025-09-07 20:24:14 +03:30
alignment: Alignment.center,
child: Icon(
CupertinoIcons.minus,
color: AppColor.error,
size: 15,
),
2025-09-07 20:24:14 +03:30
),
),
),
),
),
),
],
),
2025-09-22 16:21:17 +03:30
Text(
title,
style: AppFonts.yekan10Bold.copyWith(
color: textColor ?? AppColor.blueNormal,
),
2025-09-22 16:21:17 +03:30
),
2025-09-07 20:24:14 +03:30
],
),
);
}
//endregion
2025-09-06 17:22:19 +03:30
}