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

394 lines
13 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/cupertino.dart' hide LinearGradient;
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.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';
import 'package:rasadyar_core/presentation/widget/custom/information_card_widget.dart';
import 'logic.dart';
class PoultryScienceHomePage extends GetView<PoultryScienceHomeLogic> {
const PoultryScienceHomePage({super.key});
@override
Widget build(BuildContext context) {
return ChickenBasePage(
isBase: true,
hasNotification: true,
hasNews: true,
scrollable: true,
child: Column(
children: [
SizedBox(height: 18.h),
InkWell(
onTap: () {
controller.isExpanded.value = !controller.isExpanded.value;
},
child: Stack(
clipBehavior: Clip.none,
children: [
Container(
margin: EdgeInsetsGeometry.all(6),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 0.50, color: const Color(0xFFA9A9A9)),
),
child: ObxValue((data) {
return AnimatedSize(
duration: Duration(milliseconds: 300),
child: data.value ? mainItemWidget() : mainItemWidgetExpanded(),
);
}, 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)),
),
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),
),
Text(
'اطلاعات فارم‌ها',
textAlign: TextAlign.right,
style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor),
),
],
),
),
),
],
),
),
SizedBox(height: 10),
widelyWidget(),
SizedBox(height: 20),
],
),
);
}
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: [
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),
),
),
child: Assets.images.liveChicken.image(
width: 40.w,
height: 40.h,
fit: BoxFit.cover,
),
),
Text(
'فارم ها',
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),
),
],
),*/
SizedBox(height: 8),
firstTagInformation(),
Row(
children: [
Text('اطلاعات جوجه‌ریزی', textAlign: TextAlign.right, style: AppFonts.yekan16),
],
),
secondTagInformation(),
thirdTagInformation(),
ageCardInformation(),
],
),
);
}
Widget firstTagInformation() {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
child: ObxValue((data) {
List<InformationTagData>? items = data['first']!;
return Row(
spacing: 8,
children: List.generate(
items.length,
(index) => Expanded(child: InformationTag(data: items[index])),
),
);
}, controller.tagInfo),
);
}
Widget secondTagInformation() {
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])),
),
);
}, controller.tagInfo),
);
}
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])),
),
);
}, controller.tagInfo),
);
}
Widget ageCardInformation() {
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])),
),
);
}, controller.ageCardData),
);
}
//region Widely Used Widget
Widget widelyWidget() {
return Container(
margin: EdgeInsetsGeometry.all(6),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 0.50, color: const Color(0xFFA9A9A9)),
),
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;
Get.toNamed(ChickenRoutes.inspectionPoultryScience, id: poultryFirstKey);
},
),
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(ChickenRoutes.genocidePoultryScience, id: poultryFirstKey);
},
),
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(ChickenRoutes.farmPoultryScience, id: poultryFirstKey);
},
),
widelyUsed(
title: 'جوجه‌ریزی فعال',
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(ChickenRoutes.activeHatchingPoultryScience, id: poultryFirstKey);
},
),
],
),
),
Positioned(
top: -17,
right: 11,
child: Container(
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),
),
),
],
),
);
}
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)),
),
child: Container(
width: 40,
height: 40,
decoration: ShapeDecoration(
color: labelColor ?? 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,
),
),
),
Visibility(
visible: isOnEdit,
child: Container(
width: 48,
height: 48,
padding: EdgeInsets.all(4),
decoration: ShapeDecoration(
color: Colors.white60,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
),
),
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),
alignment: Alignment.center,
child: Icon(CupertinoIcons.minus, color: AppColor.error, size: 15),
),
),
),
),
),
),
],
),
Text(
title,
style: AppFonts.yekan10Bold.copyWith(color: textColor ?? AppColor.blueNormal),
),
],
),
);
}
//endregion
}