chore: update app version to 1.3.35+32, change build mode to debug, and refactor poultry farm inspection routes and logic for improved structure
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
abstract class ChickenRemoteDataSource {
|
||||
Future<void> getChickens();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
abstract class PoultryFarmLocalDataSource {
|
||||
// TODO: Implement local data source methods
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
abstract class PoultryFarmRemoteDataSource {
|
||||
Future<void> getPoultryFarms();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
abstract class PoultryFarmRepository {
|
||||
// TODO: Implement repository interface
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export 'presentation/home/logic.dart';
|
||||
export 'presentation/home/view.dart';
|
||||
@@ -0,0 +1,151 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
|
||||
class PoultryFarmInspectionHomeLogic extends GetxController
|
||||
with GetTickerProviderStateMixin {
|
||||
RxInt selectedSegmentIndex = 0.obs;
|
||||
RxList<Resource<PaginationModel<String>>> inspectionList = RxList([
|
||||
Resource<PaginationModel<String>>.success(
|
||||
PaginationModel(results: ["s", "b", "c", "d"]),
|
||||
),
|
||||
]);
|
||||
RxList<Resource<PaginationModel<String>>> inactiveInspectionList = RxList([
|
||||
Resource<PaginationModel<String>>.success(
|
||||
PaginationModel(results: ["s", "b", "c", "d"]),
|
||||
),
|
||||
]);
|
||||
|
||||
RxInt expandedIndex = RxInt(-1);
|
||||
|
||||
late TabController tabController;
|
||||
|
||||
RxInt selectedTabIndex = 0.obs;
|
||||
|
||||
RxInt activeStepperIndex = 0.obs;
|
||||
|
||||
PageController pageController = PageController(initialPage: 0);
|
||||
|
||||
//step1
|
||||
|
||||
TextEditingController nameOfThePoultryFarmUnit = TextEditingController();
|
||||
|
||||
//step2
|
||||
RxInt sanitaryConditionOfTheHallIndex = (-1).obs;
|
||||
RxInt ventilationStatusIndex = (-1).obs;
|
||||
RxInt beddingStatusIndex = (-1).obs;
|
||||
RxInt waterQualityIndex = (-1).obs;
|
||||
RxInt fuelTypeIndex = (-1).obs;
|
||||
RxInt sampleTypeIndex = (-1).obs;
|
||||
|
||||
//step3
|
||||
RxInt grainQualityInputIndex = (-1).obs;
|
||||
RxInt generatorOperatingStatusIndex = (-1).obs;
|
||||
RxInt workerContractStatusIndex = (-1).obs;
|
||||
RxInt newBeneficiaryRequestIndex = (-1).obs;
|
||||
|
||||
//step4
|
||||
RxInt inspectorConclusionIndex = (-1).obs;
|
||||
TextEditingController inspectorConclusionDescriptionController =
|
||||
TextEditingController();
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
|
||||
activeStepperIndex.listen((value) {
|
||||
pageController.animateToPage(
|
||||
value,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.linear,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void toggleExpanded(int index) {
|
||||
expandedIndex.value = expandedIndex.value == index ? -1 : index;
|
||||
}
|
||||
|
||||
void changeSegmentIndex(int index) {
|
||||
if (index == selectedSegmentIndex.value) {
|
||||
return;
|
||||
}
|
||||
expandedIndex.value = -1;
|
||||
selectedSegmentIndex.value = index;
|
||||
}
|
||||
|
||||
void changeTab(int index) {
|
||||
if (index == selectedTabIndex.value) {
|
||||
return;
|
||||
}
|
||||
selectedTabIndex.value = index;
|
||||
}
|
||||
|
||||
void clearForm() {
|
||||
nameOfThePoultryFarmUnit.clear();
|
||||
activeStepperIndex.value = 0;
|
||||
selectedTabIndex.value = 0;
|
||||
}
|
||||
|
||||
void setSanitaryConditionOfTheHallIndex(int index) {
|
||||
sanitaryConditionOfTheHallIndex.value =
|
||||
index == sanitaryConditionOfTheHallIndex.value ? -1 : index;
|
||||
}
|
||||
|
||||
void setFuelTypeIndex(int index) {
|
||||
fuelTypeIndex.value = index == fuelTypeIndex.value ? -1 : index;
|
||||
}
|
||||
|
||||
void setVentilationStatusIndex(int index) {
|
||||
ventilationStatusIndex.value = index == ventilationStatusIndex.value
|
||||
? -1
|
||||
: index;
|
||||
}
|
||||
|
||||
void setBeddingStatusIndex(int index) {
|
||||
beddingStatusIndex.value = index == beddingStatusIndex.value ? -1 : index;
|
||||
}
|
||||
|
||||
void setWaterQualityIndex(int index) {
|
||||
waterQualityIndex.value = index == waterQualityIndex.value ? -1 : index;
|
||||
}
|
||||
|
||||
void setSampleTypeIndex(int index) {
|
||||
sampleTypeIndex.value = index == sampleTypeIndex.value ? -1 : index;
|
||||
}
|
||||
|
||||
void setGrainQualityInputIndex(int index) {
|
||||
grainQualityInputIndex.value = index == grainQualityInputIndex.value
|
||||
? -1
|
||||
: index;
|
||||
}
|
||||
|
||||
void setGeneratorOperatingStatusIndex(int index) {
|
||||
generatorOperatingStatusIndex.value =
|
||||
index == generatorOperatingStatusIndex.value ? -1 : index;
|
||||
}
|
||||
|
||||
void setWorkerContractStatusIndex(int index) {
|
||||
workerContractStatusIndex.value = index == workerContractStatusIndex.value
|
||||
? -1
|
||||
: index;
|
||||
}
|
||||
|
||||
void setNewBeneficiaryRequestIndex(int index) {
|
||||
newBeneficiaryRequestIndex.value = index == newBeneficiaryRequestIndex.value
|
||||
? -1
|
||||
: index;
|
||||
}
|
||||
|
||||
void setInspectorConclusionIndex(int index) {
|
||||
inspectorConclusionIndex.value = index == inspectorConclusionIndex.value
|
||||
? -1
|
||||
: index;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,934 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/info_card/info_card.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../widgets/cu_bottom_sheet.dart';
|
||||
import 'logic.dart';
|
||||
|
||||
class PoultryFarmInspectionHomePage extends GetView<PoultryFarmInspectionHomeLogic> {
|
||||
const PoultryFarmInspectionHomePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
onFilterTap: () {
|
||||
//TODO
|
||||
},
|
||||
|
||||
onSearchTap: () {
|
||||
//TODO
|
||||
},
|
||||
|
||||
onSearchChanged: (data) {
|
||||
//TODO
|
||||
},
|
||||
backId: poultryFirstKey,
|
||||
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
infoCards(),
|
||||
segmentWidget(),
|
||||
ObxValue((data) {
|
||||
return data.value == 0 ? activeInspectionWidget() : inactiveInspectionWidget();
|
||||
}, controller.selectedSegmentIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 90.h,
|
||||
child: RFab.add(
|
||||
onPressed: () {
|
||||
Get.bottomSheet(
|
||||
addOrEditBottomSheet(controller),
|
||||
isScrollControlled: true,
|
||||
ignoreSafeArea: false,
|
||||
).then((value) => controller.clearForm());
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Padding infoCards() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(9, 12, 9, 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
spacing: 8,
|
||||
children: [
|
||||
cardInfo(value: 2225256, description: 'بازرسی شده', color: const Color(0xFFB6DED8)),
|
||||
cardInfo(value: 2050, description: 'بازرسی نشده', color: const Color(0xFFE9CED7)),
|
||||
cardInfo(value: 2225256, description: 'عملکرد مناسب', color: const Color(0xFFCFE0FF)),
|
||||
cardInfo(value: 55225, description: 'عملکرد ضعیف', color: const Color(0xFFF3D6CB)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Padding segmentWidget() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: RSegment(
|
||||
children: ['بازرسی فعال', 'بایگانی'],
|
||||
selectedIndex: 0,
|
||||
borderColor: const Color(0xFFB4B4B4),
|
||||
selectedBorderColor: AppColor.blueNormal,
|
||||
selectedBackgroundColor: AppColor.blueLight,
|
||||
onSegmentSelected: (index) => controller.changeSegmentIndex(index),
|
||||
backgroundColor: AppColor.whiteGreyNormal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget activeInspectionWidget() {
|
||||
return Expanded(
|
||||
child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.first,
|
||||
hasMore: false,
|
||||
onLoadMore: () async {},
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: activeinspecitonItemListWidget(),
|
||||
secondChild: avtiveInspectionItemListExpandedWidget(),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.checkSquareSvg.path,
|
||||
labelIconColor: AppColor.mediumGreyDarkHover,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: 2,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
);
|
||||
}, controller.inspectionList),
|
||||
);
|
||||
}
|
||||
|
||||
Container avtiveInspectionItemListExpandedWidget() {
|
||||
const farmerName = 'آرمان صادقی';
|
||||
const showViolationLabel = true;
|
||||
const violationLabel = 'پیگیری';
|
||||
const breed = 'راس ۳۰۸';
|
||||
const ageInDays = '۴۲';
|
||||
const growPeriod = 'بهار ۱۴۰۴';
|
||||
const licenceNumber = '۱۲۳۴۵۶۷۸';
|
||||
const chickVolume = '۲۵,۰۰۰';
|
||||
const hallRemain = '۲۳,۴۵۰';
|
||||
const losses = '۱,۵۵۰';
|
||||
const vetInfo = 'دکتر نرگس مرادی(۰۹۳۵۴۵۶۶۷۷۹)';
|
||||
const showReportButton = true;
|
||||
const reportStatus = 'ارسال تصویر جوجه ریزی فارم';
|
||||
final reportColor = AppColor.redDark;
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
farmerName,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
Visibility(
|
||||
visible: showViolationLabel,
|
||||
child: Text(
|
||||
violationLabel,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan10.copyWith(color: AppColor.redDark),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('نژاد:$breed', style: AppFonts.yekan14.copyWith(color: AppColor.textColor)),
|
||||
Text(
|
||||
' سن $ageInDays (روزه)',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
' دوره جوجه ریزی:$growPeriod',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
buildRow(title: 'شماره مجوز جوجه ریزی', value: licenceNumber),
|
||||
buildUnitRow(title: 'حجم جوجه ریزی', value: chickVolume, unit: '(قطعه)'),
|
||||
buildUnitRow(title: 'مانده در سالن', value: hallRemain, unit: '(قطعه)'),
|
||||
buildUnitRow(title: 'تلفات', value: losses, unit: '(قطعه)'),
|
||||
buildRow(title: 'دامپزشک فارم', value: vetInfo),
|
||||
buildRow(
|
||||
title: 'شرح بازرسی',
|
||||
value: reportStatus,
|
||||
titleStyle: AppFonts.yekan14.copyWith(color: reportColor),
|
||||
valueStyle: AppFonts.yekan14.copyWith(color: reportColor),
|
||||
),
|
||||
Visibility(
|
||||
visible: showReportButton,
|
||||
child: RElevated(
|
||||
text: 'ثبت بازرسی',
|
||||
isFullWidth: true,
|
||||
width: 150.w,
|
||||
height: 40.h,
|
||||
onPressed: () {},
|
||||
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget activeinspecitonItemListWidget() {
|
||||
const farmerName = 'آرمان صادقی';
|
||||
const farmerMobile = '۰۹۱۲۱۲۳۴۵۶۷';
|
||||
const unitName = 'فارم نمونه آفتاب';
|
||||
const unitLicence = 'مجوز ۵۴۲۱-الف';
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(
|
||||
farmerName,
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
farmerMobile,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
spacing: 5,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
unitName,
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
unitLicence,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget inactiveInspectionWidget() {
|
||||
return Expanded(
|
||||
child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.first,
|
||||
hasMore: false,
|
||||
onLoadMore: () async {},
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: inActiveinspecitonItemListWidget(),
|
||||
secondChild: inAvtiveInspectionItemListExpandedWidget(),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.checkSquareSvg.path,
|
||||
labelIconColor: AppColor.mediumGreyDarkHover,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: 5,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
);
|
||||
}, controller.inspectionList),
|
||||
);
|
||||
}
|
||||
|
||||
Widget inActiveinspecitonItemListWidget() {
|
||||
const farmerName = 'زهرا موسوی';
|
||||
const farmerMobile = '۰۹۳۸۸۸۷۷۶۶۵';
|
||||
const unitName = 'کشت و پرورش افق سبز';
|
||||
const unitLicence = 'مجوز ۷۶۳۲-ج';
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(
|
||||
farmerName,
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
farmerMobile,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
spacing: 5,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
unitName,
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
unitLicence,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Container inAvtiveInspectionItemListExpandedWidget() {
|
||||
const farmerName = 'زهرا موسوی';
|
||||
const showViolationLabel = false;
|
||||
const violationLabel = 'عادی';
|
||||
const breed = 'کاب ۵۰۰';
|
||||
const ageInDays = '۳۵';
|
||||
const growPeriod = 'پاییز ۱۴۰۳';
|
||||
const licenceNumber = '۸۹۴۵۶۱۲۳';
|
||||
const chickVolume = '۱۸,۵۰۰';
|
||||
const hallRemain = '۱۷,۹۴۰';
|
||||
const losses = '۵۶۰';
|
||||
const vetInfo = 'دکتر حمید نادری(۰۹۱۳۴۴۵۵۶۶۷)';
|
||||
const reportStatus = 'بازدید تایید شده';
|
||||
final reportColor = AppColor.greenNormal;
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
farmerName,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
Visibility(
|
||||
visible: showViolationLabel,
|
||||
child: Text(
|
||||
violationLabel,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan10.copyWith(color: AppColor.redDark),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('نژاد:$breed', style: AppFonts.yekan14.copyWith(color: AppColor.textColor)),
|
||||
Text(
|
||||
' سن $ageInDays (روزه)',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
' دوره جوجه ریزی:$growPeriod',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
buildRow(title: 'شماره مجوز جوجه ریزی', value: licenceNumber),
|
||||
buildUnitRow(title: 'حجم جوجه ریزی', value: chickVolume, unit: '(قطعه)'),
|
||||
buildUnitRow(title: 'مانده در سالن', value: hallRemain, unit: '(قطعه)'),
|
||||
buildUnitRow(title: 'تلفات', value: losses, unit: '(قطعه)'),
|
||||
buildRow(title: 'دامپزشک فارم', value: vetInfo),
|
||||
buildRow(
|
||||
title: 'شرح بازرسی',
|
||||
value: reportStatus,
|
||||
titleStyle: AppFonts.yekan14.copyWith(color: reportColor),
|
||||
valueStyle: AppFonts.yekan14.copyWith(color: reportColor),
|
||||
),
|
||||
ROutlinedElevated(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Assets.vec.excelDownloadSvg.svg(
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.greenDark, BlendMode.srcIn),
|
||||
),
|
||||
|
||||
Text(
|
||||
'مشاهده جزییات ',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
borderColor: AppColor.greenDark,
|
||||
onPressed: () {
|
||||
Get.bottomSheet(detailsWidget(), isScrollControlled: true, isDismissible: true);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget detailsWidget() {
|
||||
return BaseBottomSheet(
|
||||
height: Get.height * 0.8,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 10),
|
||||
child: Text(
|
||||
'جزییات',
|
||||
style: AppFonts.yekan18Bold.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(color: AppColor.blackLightHover, height: 1, thickness: 1),
|
||||
ObxValue((data) {
|
||||
return tabBarWidget(
|
||||
['اطلاعات', 'پاییش سلامت', 'زیرساخت', 'مستندات'],
|
||||
controller.selectedTabIndex.value,
|
||||
(index) => controller.changeTab(index),
|
||||
);
|
||||
}, controller.selectedTabIndex),
|
||||
|
||||
ObxValue((data) {
|
||||
switch (data.value) {
|
||||
case 0:
|
||||
return infoTable();
|
||||
case 1:
|
||||
return healthTable();
|
||||
case 2:
|
||||
return infrastructureTable();
|
||||
case 3:
|
||||
return documentsTable();
|
||||
default:
|
||||
return infoTable();
|
||||
}
|
||||
}, controller.selectedTabIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Expanded در سطح بالاتر
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container infoTable() {
|
||||
return Container(
|
||||
height: Get.height,
|
||||
width: Get.width,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text('مشخصات کلی', style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
|
||||
Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
children: [
|
||||
rTableRow(title: 'نام واحد مرغداری', value: 'لذیذ'),
|
||||
rTableRow(title: 'کد یکتا / شناسه واحد', value: '2541415'),
|
||||
rTableRow(title: 'نام مالک / بهرهبردار', value: 'مرغداری احمدی'),
|
||||
rTableRow(title: 'موجودی سوخت اضطراری', value: '200 لیتر'),
|
||||
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(title: 'تاریخ ثبت جوجه ریزی', value: '1402/09/19 (10:12)'),
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(title: 'تاریخ ثبت جوجه ریزی', value: '1402/09/19 (10:12)'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Row rTableRow({String? title, String? value}) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 9, vertical: 11),
|
||||
alignment: Alignment.centerRight,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight2,
|
||||
border: Border(bottom: BorderSide(color: AppColor.blackLightHover, width: 1)),
|
||||
),
|
||||
child: Text(
|
||||
title ?? '',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 9, vertical: 11),
|
||||
alignment: Alignment.centerRight,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: AppColor.blackLightHover, width: 1)),
|
||||
),
|
||||
child: Text(
|
||||
value ?? '',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget tabBarWidget(List<String> tabs, int selectedIndex, Function(int) onTabSelected) {
|
||||
return SizedBox(
|
||||
height: 38.h,
|
||||
width: Get.width,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Row(
|
||||
children: [
|
||||
...tabs.map(
|
||||
(tab) => GestureDetector(
|
||||
onTap: () => onTabSelected(tabs.indexOf(tab)),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 11),
|
||||
decoration: BoxDecoration(
|
||||
border: tab == tabs[selectedIndex]
|
||||
? Border(bottom: BorderSide(color: AppColor.blueNormalOld, width: 3))
|
||||
: null,
|
||||
),
|
||||
child: Text(
|
||||
tab,
|
||||
style: AppFonts.yekan12Bold.copyWith(
|
||||
color: tab == tabs[selectedIndex]
|
||||
? AppColor.blueNormalOld
|
||||
: AppColor.mediumGrey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Divider(color: AppColor.blackLightHover, height: 1, thickness: 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget healthTable() {
|
||||
return Container(
|
||||
height: Get.height,
|
||||
width: Get.width,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text('پاییش سلامت', style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
|
||||
Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
children: [
|
||||
rTableRow(title: 'نام واحد مرغداری', value: 'لذیذ'),
|
||||
rTableRow(title: 'کد یکتا / شناسه واحد', value: '2541415'),
|
||||
rTableRow(title: 'نام مالک / بهرهبردار', value: 'مرغداری احمدی'),
|
||||
rTableRow(title: 'موجودی سوخت اضطراری', value: '200 لیتر'),
|
||||
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(title: 'تاریخ ثبت جوجه ریزی', value: '1402/09/19 (10:12)'),
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(title: 'تاریخ ثبت جوجه ریزی', value: '1402/09/19 (10:12)'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget infrastructureTable() {
|
||||
return Container(
|
||||
height: Get.height,
|
||||
width: Get.width,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text('زیرساخت', style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
|
||||
Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
children: [
|
||||
rTableRow(title: 'نام واحد مرغداری', value: 'لذیذ'),
|
||||
rTableRow(title: 'کد یکتا / شناسه واحد', value: '2541415'),
|
||||
rTableRow(title: 'نام مالک / بهرهبردار', value: 'مرغداری احمدی'),
|
||||
rTableRow(title: 'موجودی سوخت اضطراری', value: '200 لیتر'),
|
||||
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(title: 'تاریخ ثبت جوجه ریزی', value: '1402/09/19 (10:12)'),
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(title: 'تاریخ ثبت جوجه ریزی', value: '1402/09/19 (10:12)'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget documentsTable() {
|
||||
return Container(
|
||||
height: Get.height,
|
||||
width: Get.width,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text('مستندات', style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor)),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
Container(
|
||||
height: 135.h,
|
||||
width: Get.width,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 100.h,
|
||||
width: Get.width,
|
||||
child: ListView.separated(
|
||||
itemCount: 10,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: 80.w,
|
||||
height: 80.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0x33000000),
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage("https://picsum.photos/150/150?random=$index"),
|
||||
),
|
||||
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => SizedBox(width: 10),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'200 فارم در این سالن تخمین زده شده است.',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
Container(
|
||||
height: 135.h,
|
||||
width: Get.width,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 100.h,
|
||||
width: Get.width,
|
||||
child: ListView.separated(
|
||||
itemCount: 10,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: 80.w,
|
||||
height: 80.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0x33000000),
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(
|
||||
"https://picsum.photos/150/150?random=${index * 2 + 1}",
|
||||
),
|
||||
),
|
||||
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => SizedBox(width: 10),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'انبار نهاده ها',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
Container(
|
||||
height: 135.h,
|
||||
width: Get.width,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 100.h,
|
||||
width: Get.width,
|
||||
child: ListView.separated(
|
||||
itemCount: 10,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: 80.w,
|
||||
height: 80.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0x33000000),
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(
|
||||
"https://picsum.photos/150/150?random=${index * 3 + 1}",
|
||||
),
|
||||
),
|
||||
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => SizedBox(width: 10),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'تلفات',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_farm_inspection/presentation/home/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
Widget farmInfoWidget({
|
||||
required PoultryFarmInspectionHomeLogic controller,
|
||||
required String title,
|
||||
required Widget child,
|
||||
EdgeInsets? padding,
|
||||
}) {
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(width: 0.50, color: AppColor.mediumGrey),
|
||||
),
|
||||
|
||||
padding:
|
||||
padding ?? EdgeInsets.symmetric(horizontal: 12.w, vertical: 11.h),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: -17,
|
||||
right: 7,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 5.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(width: 0.50, color: AppColor.mediumGrey),
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget cardInfo({required Widget child, EdgeInsets? padding}) {
|
||||
return Container(
|
||||
width: Get.width,
|
||||
padding: padding ?? EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.h),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight,
|
||||
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(width: 1, color: AppColor.blackLight),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import '../home/logic.dart';
|
||||
import 'step1_page.dart';
|
||||
import 'step2_page.dart';
|
||||
import 'step3_page.dart';
|
||||
import 'step4_page.dart';
|
||||
import 'step5_page.dart';
|
||||
|
||||
Widget addOrEditBottomSheet(PoultryFarmInspectionHomeLogic controller) {
|
||||
List<Widget> pages = [
|
||||
step1Page(controller),
|
||||
step2Page(controller),
|
||||
step3Page(controller),
|
||||
step4Page(controller),
|
||||
step5Page(controller),
|
||||
];
|
||||
|
||||
return BaseBottomSheet(
|
||||
height: Get.height,
|
||||
rootChild: Column(
|
||||
children: [
|
||||
ObxValue((data) {
|
||||
return stepper(activeStep: data.value);
|
||||
}, controller.activeStepperIndex),
|
||||
Expanded(
|
||||
child: PageView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
reverse: true,
|
||||
controller: controller.pageController,
|
||||
itemBuilder: (context, index) => pages[index],
|
||||
),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
spacing: 16,
|
||||
children: [
|
||||
Expanded(
|
||||
child: RElevated(
|
||||
height: 40.h,
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
children: [
|
||||
Icon(Icons.arrow_back_ios, color: Colors.white),
|
||||
|
||||
Text('ادامه'),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
if (controller.activeStepperIndex.value <4) {
|
||||
controller.activeStepperIndex.value++;
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ROutlinedElevated(
|
||||
borderColor: AppColor.error,
|
||||
height: 40.h,
|
||||
child: Text('برگشت'),
|
||||
enabled: controller.activeStepperIndex.value > 0,
|
||||
onPressed: () {
|
||||
if (controller.activeStepperIndex.value > 0) {
|
||||
controller.activeStepperIndex.value--;
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.activeStepperIndex),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class stepper extends StatelessWidget {
|
||||
const stepper({super.key, required this.activeStep});
|
||||
final int activeStep;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: SizedBox(
|
||||
height: 24,
|
||||
width: Get.width,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: activeStep >= 0
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
child: Text(
|
||||
'1',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(
|
||||
color: activeStep >= 0 ? Colors.white : AppColor.iconColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(
|
||||
color: activeStep >= 1
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
thickness: 8,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: activeStep >= 1
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
child: Text(
|
||||
'2',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(
|
||||
color: activeStep >= 1 ? Colors.white : AppColor.iconColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(
|
||||
color: activeStep >= 2
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
thickness: 8,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: activeStep >= 2
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
child: Text(
|
||||
'3',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(
|
||||
color: activeStep >= 2 ? Colors.white : AppColor.iconColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(
|
||||
color: activeStep >= 3
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
thickness: 8,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: activeStep >= 3
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
child: Text(
|
||||
'4',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(
|
||||
color: activeStep >= 3 ? Colors.white : AppColor.iconColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(
|
||||
color: activeStep >= 4
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
thickness: 8,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: activeStep >= 4
|
||||
? AppColor.greenNormalHover
|
||||
: AppColor.whiteNormalActive,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
child: Text(
|
||||
'5',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(
|
||||
color: activeStep >= 3 ? Colors.white : AppColor.iconColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_farm_inspection/presentation/widgets/card_info.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../home/logic.dart';
|
||||
|
||||
Widget step1Page(PoultryFarmInspectionHomeLogic controller) {
|
||||
return SingleChildScrollView(
|
||||
physics: BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 25.h),
|
||||
|
||||
Container(
|
||||
height: 610.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'اطلاعات پایه واحد',
|
||||
child: basicUnitInformation(controller),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 30.h),
|
||||
|
||||
Container(
|
||||
height: 400.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'اطلاعات جوجه ریزی',
|
||||
child: hatchingInformation(controller),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.h),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Column basicUnitInformation(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'نام واحد مرغداری',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'کد یکتا / شناسه واحد',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'نام مالک / بهرهبردار',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['مالک', 'بهرهبردار', 'مشاور', 'دیگر']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'نوع مالکیت'),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'کد ملی بهرهبردار',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'شماره تماس بهرهبردار',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'ظرفیت اسمی سالنها',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'نوع سیستم پرورش',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RElevated(
|
||||
isFullWidth: true,
|
||||
height: 40.h,
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
onPressed: () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Icon(Icons.my_location_rounded, color: Colors.white, size: 24),
|
||||
Text('دریافت موقعیت جغرافیایی', style: AppFonts.yekan14.copyWith(color: Colors.white)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column hatchingInformation(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تاریخ جوجه ریزی',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد جوجهریزی اولیه',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'منبع تهیه جوجه',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['سرابی', 'پژدر', 'روتوایلر', 'دیگر']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'نوع نژاد'),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'گرید جوجه',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'میانگین وزن جوجه در ورود',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,499 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_farm_inspection/presentation/widgets/card_info.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../home/logic.dart';
|
||||
|
||||
Widget step2Page(PoultryFarmInspectionHomeLogic controller) {
|
||||
return SingleChildScrollView(
|
||||
physics: BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 35.h),
|
||||
|
||||
Container(
|
||||
height: 760.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'وضعیت عمومی سالن',
|
||||
child: generalConditionOfTheHall(controller),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 30.h),
|
||||
|
||||
Container(
|
||||
height: 430.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'تلفات',
|
||||
child: casualtiesInformation(controller),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24.h),
|
||||
|
||||
Container(
|
||||
height: 450.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'بیماریها و وضعیت سلامت',
|
||||
child: diseasesAndHealthInformation(controller),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Column generalConditionOfTheHall(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 12),
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(0, 12, 12, 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 80.w,
|
||||
padding: EdgeInsets.all(22),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE9E9E9),
|
||||
border: Border.all(width: 1, color: AppColor.blackLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Assets.vec.galleryAddSvg.svg(width: 36, height: 36),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Text(
|
||||
'تعداد موجود فعلی',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'وضعیت بهداشتی سالن',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'عالی',
|
||||
onTap: (index) => controller.setSanitaryConditionOfTheHallIndex(index),
|
||||
),
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'خوب',
|
||||
onTap: (index) => controller.setSanitaryConditionOfTheHallIndex(index),
|
||||
),
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'متوسط',
|
||||
onTap: (index) => controller.setSanitaryConditionOfTheHallIndex(index),
|
||||
),
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 3,
|
||||
label: 'ضعیف',
|
||||
onTap: (index) => controller.setSanitaryConditionOfTheHallIndex(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.sanitaryConditionOfTheHallIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text('وضعیت تهویه', style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2)),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setVentilationStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'خشک',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setVentilationStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'نیمهمرطوب',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setVentilationStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'مرطوب',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.ventilationStatusIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text('وضعیت بستر', style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2)),
|
||||
|
||||
ObxValue((data) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setBeddingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'خشک',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setBeddingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'نیمهمرطوب',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setBeddingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'مرطوب',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setBeddingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'نیازمند اصلاح',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.beddingStatusIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'دمای سالن',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
maxLines: 1,
|
||||
minLines: 1,
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'کیفیت آب مصرفی',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setWaterQualityIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'چاه',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setWaterQualityIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'شهری',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setWaterQualityIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'تصفیهشده',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.waterQualityIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'کیفیت آب مصرفی',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setFuelTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'گازوییل',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setFuelTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'بنزین',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setFuelTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'گاز',
|
||||
),
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 3,
|
||||
label: 'نفت',
|
||||
onTap: (index) => controller.setFuelTypeIndex(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.fuelTypeIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
ChoiceChip formChips({
|
||||
required int selectedIndex,
|
||||
required int index,
|
||||
required String label,
|
||||
required Function(int) onTap,
|
||||
}) {
|
||||
return ChoiceChip(
|
||||
selectedColor: AppColor.green1Normal,
|
||||
labelStyle: index == selectedIndex
|
||||
? AppFonts.yekan14Bold.copyWith(color: Colors.white)
|
||||
: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
surfaceTintColor: Colors.white,
|
||||
checkmarkColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: index == selectedIndex
|
||||
? BorderSide.none
|
||||
: BorderSide(width: 1, color: AppColor.blackLightHover),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
label: Text(label),
|
||||
selected: index == selectedIndex,
|
||||
onSelected: (value) => onTap(index),
|
||||
);
|
||||
}
|
||||
|
||||
Column casualtiesInformation(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد تلفات عادی دوره',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تلفات غیرعادی',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'منبع تهیه جوجه',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['بیماری', 'قطعی برق', 'استرس گرمایی', 'مشکلات دانه']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'علت احتمالی تلفات غیرعادی'),
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['انجام نشد', 'انجام شد']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'نمونهبرداری انجامشده'),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text('نوع نمونه', style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2)),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setSampleTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'رنده',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setSampleTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'لاشه',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setSampleTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'ترکیبی',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.sampleTypeIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column diseasesAndHealthInformation(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['بیماری', 'قطعی برق', 'استرس گرمایی', 'مشکلات دانه']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'وجود علائم بیماری در گله'),
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['انجام نشد', 'انجام شد']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'نوع بیماری تشخیص دادهشده / مشکوک'),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تاریخ واکسیناسیونهای انجامشده',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success([
|
||||
'واکسن 1',
|
||||
'واکسن 2',
|
||||
'واکسن 3',
|
||||
'واکسن 4',
|
||||
'واکسن 5',
|
||||
'واکسن 6',
|
||||
'واکسن 7',
|
||||
'واکسن 8',
|
||||
'واکسن 9',
|
||||
'واکسن 10',
|
||||
]),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'نوع واکسن'),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'شرکت تولیدکننده',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'نام مسئول فنی بهداشتی',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'نام مسئول فنی نظام مهندسی',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,719 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_farm_inspection/presentation/widgets/card_info.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../home/logic.dart';
|
||||
|
||||
Widget step3Page(PoultryFarmInspectionHomeLogic controller) {
|
||||
return SingleChildScrollView(
|
||||
physics: BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 35.h),
|
||||
|
||||
Container(
|
||||
height: 410.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'نهاده و خوراک',
|
||||
child: agriculturalInput(controller),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 30.h),
|
||||
|
||||
Container(
|
||||
height: 650.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'زیرساخت و انرژی',
|
||||
child: infrastructureAndEnergy(controller),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24.h),
|
||||
|
||||
Container(
|
||||
height: 405.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'نیروی انسانی',
|
||||
child: humanResources(controller),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24.h),
|
||||
|
||||
Container(
|
||||
height: 440.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'تسهیلات و حمایتها',
|
||||
child: facilitiesAndSupport(controller),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Column agriculturalInput2(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(0, 12, 12, 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 80.w,
|
||||
padding: EdgeInsets.all(22),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE9E9E9),
|
||||
border: Border.all(width: 1, color: AppColor.blackLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Assets.vec.galleryAddSvg.svg(width: 36, height: 36),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Text(
|
||||
'تعداد موجود فعلی',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'وضعیت بهداشتی سالن',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'عالی',
|
||||
onTap: (index) => controller.setSanitaryConditionOfTheHallIndex(index),
|
||||
),
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'خوب',
|
||||
onTap: (index) => controller.setSanitaryConditionOfTheHallIndex(index),
|
||||
),
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'متوسط',
|
||||
onTap: (index) => controller.setSanitaryConditionOfTheHallIndex(index),
|
||||
),
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 3,
|
||||
label: 'ضعیف',
|
||||
onTap: (index) => controller.setSanitaryConditionOfTheHallIndex(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.sanitaryConditionOfTheHallIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text('وضعیت تهویه', style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2)),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setVentilationStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'خشک',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setVentilationStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'نیمهمرطوب',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setVentilationStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'مرطوب',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.ventilationStatusIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text('وضعیت بستر', style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2)),
|
||||
|
||||
ObxValue((data) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setBeddingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'خشک',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setBeddingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'نیمهمرطوب',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setBeddingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'مرطوب',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setBeddingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'نیازمند اصلاح',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.beddingStatusIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'دمای سالن',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
maxLines: 1,
|
||||
minLines: 1,
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'کیفیت آب مصرفی',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setWaterQualityIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'چاه',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setWaterQualityIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'شهری',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setWaterQualityIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'تصفیهشده',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.waterQualityIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'کیفیت آب مصرفی',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setFuelTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'گازوییل',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setFuelTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'بنزین',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setFuelTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'گاز',
|
||||
),
|
||||
formChips(
|
||||
selectedIndex: data.value,
|
||||
index: 3,
|
||||
label: 'نفت',
|
||||
onTap: (index) => controller.setFuelTypeIndex(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.fuelTypeIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
ChoiceChip formChips({
|
||||
required int selectedIndex,
|
||||
required int index,
|
||||
required String label,
|
||||
required Function(int) onTap,
|
||||
}) {
|
||||
return ChoiceChip(
|
||||
selectedColor: AppColor.green1Normal,
|
||||
labelStyle: index == selectedIndex
|
||||
? AppFonts.yekan14Bold.copyWith(color: Colors.white)
|
||||
: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
surfaceTintColor: Colors.white,
|
||||
checkmarkColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: index == selectedIndex
|
||||
? BorderSide.none
|
||||
: BorderSide(width: 1, color: AppColor.blackLightHover),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
label: Text(label),
|
||||
selected: index == selectedIndex,
|
||||
onSelected: (value) => onTap(index),
|
||||
);
|
||||
}
|
||||
|
||||
Column infrastructureAndEnergy(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'نوع ژنراتور',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'ظرفیت (KVA)',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'وضعیت عملکرد ژنراتور',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setGeneratorOperatingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'سالم',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setGeneratorOperatingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'نیمهسالم',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setGeneratorOperatingStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'معیوب',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.generatorOperatingStatusIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'میزان موجودی سوخت اضطراری (لیتر)',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['بیماری', 'قطعی برق', 'استرس گرمایی', 'مشکلات دانه']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'علت احتمالی تلفات غیرعادی'),
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['ندارد', 'دارد']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'سابقه قطعی برق دوره جاری'),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد تلفات',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'مدت قطعی',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'توضیحات تکمیلی',
|
||||
filled: true,
|
||||
maxLines: 3,
|
||||
minLines: 3,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column agriculturalInput(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'میزان نهاده مصرفی تا روز بازدید (کیلوگرم)',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'میزان نهاده موجود در انبار',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'میزان نهاده خریداریشده و حملنشده از بازارگاه',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text('کیفیت دانه', style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2)),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setSampleTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'خوب',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setSampleTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'متوسط',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setGrainQualityInputIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'ضعیف',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.grainQualityInputIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'فرمول دانه (در صورت ارائه)',
|
||||
filled: true,
|
||||
minLines: 3,
|
||||
maxLines: 3,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column humanResources(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد افراد شاغل',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد افراد بومی',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد افراد غیر بومی',
|
||||
filled: true,
|
||||
maxLines: 3,
|
||||
minLines: 3,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'وضعیت قرارداد کارگران',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setWorkerContractStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'دائم',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setWorkerContractStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'موقت',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setWorkerContractStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'روزمزدی',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.workerContractStatusIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['آموزش ندیده است', 'آموزش دیده است']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'آموزشدیده در حوزه بهداشت و امنیت زیستی'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column facilitiesAndSupport(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تسهیلات دریافتی فعال',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'نوع تسهیلات',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'مبلغ',
|
||||
filled: true,
|
||||
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'سال دریافت',
|
||||
filled: true,
|
||||
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['دریافت نشده', 'دریافت شده']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'وضعیت بازپرداخت'),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'درخواست جدید بهرهبردار',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setNewBeneficiaryRequestIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'نهاده',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setNewBeneficiaryRequestIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'تسهیلات',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setNewBeneficiaryRequestIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'واکسن',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setNewBeneficiaryRequestIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 3,
|
||||
label: 'تجهیزات',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.newBeneficiaryRequestIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,487 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_farm_inspection/presentation/widgets/card_info.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../home/logic.dart';
|
||||
|
||||
Widget step4Page(PoultryFarmInspectionHomeLogic controller) {
|
||||
return SingleChildScrollView(
|
||||
physics: BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 35.h),
|
||||
|
||||
Container(
|
||||
height: 455.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'مستندات',
|
||||
child: documents(controller),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 30.h),
|
||||
|
||||
Container(
|
||||
height: 220.h,
|
||||
clipBehavior: Clip.none,
|
||||
width: Get.width,
|
||||
child: farmInfoWidget(
|
||||
controller: controller,
|
||||
title: 'جمعبندی بازرس',
|
||||
child: inspectorConclusion(controller),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24.h),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Column documents(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(0, 12, 12, 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
SizedBox(height: 10.h),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 80.w,
|
||||
padding: EdgeInsets.all(22),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE9E9E9),
|
||||
border: Border.all(width: 1, color: AppColor.blackLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Assets.vec.galleryAddSvg.svg(width: 36, height: 36),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Text(
|
||||
'ثبت عکس سالن (حداقل ۳ زاویه) *',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(0, 12, 12, 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 80.w,
|
||||
padding: EdgeInsets.all(22),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE9E9E9),
|
||||
border: Border.all(width: 1, color: AppColor.blackLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Assets.vec.galleryAddSvg.svg(width: 36, height: 36),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Text(
|
||||
'ثبت عکس انبار نهادهها',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(0, 12, 12, 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 80.w,
|
||||
padding: EdgeInsets.all(22),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE9E9E9),
|
||||
border: Border.all(width: 1, color: AppColor.blackLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Assets.vec.galleryAddSvg.svg(width: 36, height: 36),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Text('ثبت عکس تلفات', style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
ChoiceChip formChips({
|
||||
required int selectedIndex,
|
||||
required int index,
|
||||
required String label,
|
||||
required Function(int) onTap,
|
||||
}) {
|
||||
return ChoiceChip(
|
||||
selectedColor: AppColor.green1Normal,
|
||||
labelStyle: index == selectedIndex
|
||||
? AppFonts.yekan14Bold.copyWith(color: Colors.white)
|
||||
: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
surfaceTintColor: Colors.white,
|
||||
checkmarkColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: index == selectedIndex
|
||||
? BorderSide.none
|
||||
: BorderSide(width: 1, color: AppColor.blackLightHover),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
label: Text(label),
|
||||
selected: index == selectedIndex,
|
||||
onSelected: (value) => onTap(index),
|
||||
);
|
||||
}
|
||||
|
||||
Column inspectorConclusion(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'وضعیت کلی واحد',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setInspectorConclusionIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'تایید شده',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setInspectorConclusionIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'نیازمند اصلاح',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setInspectorConclusionIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'پرریسک',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.inspectorConclusionIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.inspectorConclusionDescriptionController,
|
||||
hintText: 'توصیهها / اخطارها / اقدامات اصلاحی ...',
|
||||
hintStyle: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
|
||||
maxLines: 3,
|
||||
minLines: 3,
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column agriculturalInput(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'میزان نهاده مصرفی تا روز بازدید (کیلوگرم)',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'میزان نهاده موجود در انبار',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'میزان نهاده خریداریشده و حملنشده از بازارگاه',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text('کیفیت دانه', style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2)),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setSampleTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'خوب',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setSampleTypeIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'متوسط',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setGrainQualityInputIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'ضعیف',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.grainQualityInputIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'فرمول دانه (در صورت ارائه)',
|
||||
filled: true,
|
||||
minLines: 3,
|
||||
maxLines: 3,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column humanResources(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد افراد شاغل',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد افراد بومی',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تعداد افراد غیر بومی',
|
||||
filled: true,
|
||||
maxLines: 3,
|
||||
minLines: 3,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'وضعیت قرارداد کارگران',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setWorkerContractStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'دائم',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setWorkerContractStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'موقت',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setWorkerContractStatusIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'روزمزدی',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.workerContractStatusIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['آموزش ندیده است', 'آموزش دیده است']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'آموزشدیده در حوزه بهداشت و امنیت زیستی'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column facilitiesAndSupport(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(height: 1.h),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'تسهیلات دریافتی فعال',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'نوع تسهیلات',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'مبلغ',
|
||||
filled: true,
|
||||
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
RTextField(
|
||||
controller: controller.nameOfThePoultryFarmUnit,
|
||||
label: 'سال دریافت',
|
||||
filled: true,
|
||||
|
||||
filledColor: AppColor.bgLight,
|
||||
),
|
||||
|
||||
ResourceOverlayDropdown(
|
||||
items: Resource.success(['دریافت نشده', 'دریافت شده']),
|
||||
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'وضعیت بازپرداخت'),
|
||||
),
|
||||
|
||||
cardInfo(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Text(
|
||||
'درخواست جدید بهرهبردار',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
formChips(
|
||||
onTap: (index) => controller.setNewBeneficiaryRequestIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 0,
|
||||
label: 'نهاده',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setNewBeneficiaryRequestIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 1,
|
||||
label: 'تسهیلات',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setNewBeneficiaryRequestIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 2,
|
||||
label: 'واکسن',
|
||||
),
|
||||
formChips(
|
||||
onTap: (index) => controller.setNewBeneficiaryRequestIndex(index),
|
||||
selectedIndex: data.value,
|
||||
index: 3,
|
||||
label: 'تجهیزات',
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.newBeneficiaryRequestIndex),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,598 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../home/logic.dart';
|
||||
|
||||
Widget step5Page(PoultryFarmInspectionHomeLogic controller) {
|
||||
return SingleChildScrollView(
|
||||
physics: BouncingScrollPhysics(),
|
||||
child: detailsWidget(controller),
|
||||
);
|
||||
}
|
||||
|
||||
Widget detailsWidget(PoultryFarmInspectionHomeLogic controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 10,
|
||||
),
|
||||
child: Text(
|
||||
'جزییات',
|
||||
style: AppFonts.yekan18Bold.copyWith(
|
||||
color: AppColor.iconColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(color: AppColor.blackLightHover, height: 1, thickness: 1),
|
||||
ObxValue((data) {
|
||||
return tabBarWidget(
|
||||
['اطلاعات', 'پاییش سلامت', 'زیرساخت', 'مستندات'],
|
||||
controller.selectedTabIndex.value,
|
||||
(index) => controller.changeTab(index),
|
||||
);
|
||||
}, controller.selectedTabIndex),
|
||||
|
||||
ObxValue((data) {
|
||||
switch (data.value) {
|
||||
case 0:
|
||||
return infoTable();
|
||||
case 1:
|
||||
return healthTable();
|
||||
case 2:
|
||||
return infrastructureTable();
|
||||
case 3:
|
||||
return documentsTable();
|
||||
default:
|
||||
return infoTable();
|
||||
}
|
||||
}, controller.selectedTabIndex),
|
||||
],
|
||||
),
|
||||
|
||||
// Expanded در سطح بالاتر
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column infoTable() {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'مشخصات کلی',
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
|
||||
Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
rTableRow(title: 'نام واحد مرغداری', value: 'لذیذ'),
|
||||
rTableRow(title: 'کد یکتا / شناسه واحد', value: '2541415'),
|
||||
rTableRow(title: 'نام مالک / بهرهبردار', value: 'مرغداری احمدی'),
|
||||
rTableRow(title: 'موجودی سوخت اضطراری', value: '200 لیتر'),
|
||||
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(
|
||||
title: 'تاریخ ثبت جوجه ریزی',
|
||||
value: '1402/09/19 (10:12)',
|
||||
),
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(
|
||||
title: 'تاریخ ثبت جوجه ریزی',
|
||||
value: '1402/09/19 (10:12)',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Row rTableRow({String? title, String? value}) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 9, vertical: 11),
|
||||
alignment: Alignment.centerRight,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight2,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: AppColor.blackLightHover, width: 1),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
title ?? '',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 9, vertical: 11),
|
||||
alignment: Alignment.centerRight,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: AppColor.blackLightHover, width: 1),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
value ?? '',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget tabBarWidget(
|
||||
List<String> tabs,
|
||||
int selectedIndex,
|
||||
Function(int) onTabSelected,
|
||||
) {
|
||||
return SizedBox(
|
||||
height: 38.h,
|
||||
width: Get.width,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Row(
|
||||
children: [
|
||||
...tabs.map(
|
||||
(tab) => GestureDetector(
|
||||
onTap: () => onTabSelected(tabs.indexOf(tab)),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 11),
|
||||
decoration: BoxDecoration(
|
||||
border: tab == tabs[selectedIndex]
|
||||
? Border(
|
||||
bottom: BorderSide(
|
||||
color: AppColor.blueNormalOld,
|
||||
width: 3,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: Text(
|
||||
tab,
|
||||
style: AppFonts.yekan12Bold.copyWith(
|
||||
color: tab == tabs[selectedIndex]
|
||||
? AppColor.blueNormalOld
|
||||
: AppColor.mediumGrey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Divider(
|
||||
color: AppColor.blackLightHover,
|
||||
height: 1,
|
||||
thickness: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget healthTable() {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'پاییش سلامت',
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
|
||||
Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
rTableRow(title: 'نام واحد مرغداری', value: 'لذیذ'),
|
||||
rTableRow(title: 'کد یکتا / شناسه واحد', value: '2541415'),
|
||||
rTableRow(title: 'نام مالک / بهرهبردار', value: 'مرغداری احمدی'),
|
||||
rTableRow(title: 'موجودی سوخت اضطراری', value: '200 لیتر'),
|
||||
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(
|
||||
title: 'تاریخ ثبت جوجه ریزی',
|
||||
value: '1402/09/19 (10:12)',
|
||||
),
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(
|
||||
title: 'تاریخ ثبت جوجه ریزی',
|
||||
value: '1402/09/19 (10:12)',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget infrastructureTable() {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'زیرساخت',
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
|
||||
Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
rTableRow(title: 'نام واحد مرغداری', value: 'لذیذ'),
|
||||
rTableRow(title: 'کد یکتا / شناسه واحد', value: '2541415'),
|
||||
rTableRow(title: 'نام مالک / بهرهبردار', value: 'مرغداری احمدی'),
|
||||
rTableRow(title: 'موجودی سوخت اضطراری', value: '200 لیتر'),
|
||||
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(
|
||||
title: 'تاریخ ثبت جوجه ریزی',
|
||||
value: '1402/09/19 (10:12)',
|
||||
),
|
||||
rTableRow(title: 'شهر/تعاونی', value: 'خرم آباد/تعاونی خرم آباد'),
|
||||
|
||||
rTableRow(title: 'شماره تلفن واحد', value: '021-12345678'),
|
||||
rTableRow(title: 'دامپزشک فارم', value: 'dd dd (05218569685)'),
|
||||
|
||||
rTableRow(title: 'سالن', value: '2'),
|
||||
rTableRow(
|
||||
title: 'تاریخ ثبت جوجه ریزی',
|
||||
value: '1402/09/19 (10:12)',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget documentsTable() {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'مستندات',
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
Container(
|
||||
height: 135.h,
|
||||
width: Get.width,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 100.h,
|
||||
width: Get.width,
|
||||
child: ListView.separated(
|
||||
itemCount: 10,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: 80.w,
|
||||
height: 80.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0x33000000),
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(
|
||||
"https://picsum.photos/150/150?random=$index",
|
||||
),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned(
|
||||
top: 6,
|
||||
left: 6,
|
||||
child: Container(
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
padding: EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.80),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Assets.vec.trashSvg.svg(
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
colorFilter: ColorFilter.mode(
|
||||
AppColor.redNormal,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => SizedBox(width: 10),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'200 فارم در این سالن تخمین زده شده است.',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14Bold.copyWith(
|
||||
color: AppColor.textColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
Container(
|
||||
height: 135.h,
|
||||
width: Get.width,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 100.h,
|
||||
width: Get.width,
|
||||
child: ListView.separated(
|
||||
itemCount: 10,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: 80.w,
|
||||
height: 80.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0x33000000),
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(
|
||||
"https://picsum.photos/150/150?random=${index * 2 + 1}",
|
||||
),
|
||||
),
|
||||
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned(
|
||||
top: 6,
|
||||
left: 6,
|
||||
child: Container(
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
padding: EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.80),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Assets.vec.trashSvg.svg(
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
colorFilter: ColorFilter.mode(
|
||||
AppColor.redNormal,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => SizedBox(width: 10),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'انبار نهاده ها',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14Bold.copyWith(
|
||||
color: AppColor.textColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
Container(
|
||||
height: 135.h,
|
||||
width: Get.width,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 100.h,
|
||||
width: Get.width,
|
||||
child: ListView.separated(
|
||||
itemCount: 10,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: 80.w,
|
||||
height: 80.h,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0x33000000),
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(
|
||||
"https://picsum.photos/150/150?random=${index * 3 + 1}",
|
||||
),
|
||||
),
|
||||
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned(
|
||||
top: 6,
|
||||
left: 6,
|
||||
child: Container(
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
padding: EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.80),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Assets.vec.trashSvg.svg(
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
colorFilter: ColorFilter.mode(
|
||||
AppColor.redNormal,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) => SizedBox(width: 10),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'تلفات',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14Bold.copyWith(
|
||||
color: AppColor.textColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
abstract class PoultryScienceRemoteDataSource {
|
||||
Future<void> getPoultryScience();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export 'presentation/routes/routes.dart';
|
||||
export 'presentation/routes/pages.dart';
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class ActiveHatchingLogic extends GetxController {
|
||||
PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||
BaseLogic baseLogic = Get.find<BaseLogic>();
|
||||
Rx<Resource<PaginationModel<HatchingModel>>> activeHatchingList =
|
||||
Resource<PaginationModel<HatchingModel>>.loading().obs;
|
||||
|
||||
final RxBool isLoadingMoreList = false.obs;
|
||||
RxInt currentPage = 1.obs;
|
||||
RxInt expandedIndex = RxInt(-1);
|
||||
List<String> routesName = ['اقدام', 'جوجه ریزی فعال'];
|
||||
|
||||
Rx<Jalali> fromDateFilter = Jalali.now().obs;
|
||||
Rx<Jalali> toDateFilter = Jalali.now().obs;
|
||||
RxnString searchedValue = RxnString();
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
getHatchingList();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
baseLogic.clearSearch();
|
||||
}
|
||||
|
||||
Future<void> getHatchingList([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreList.value = true;
|
||||
} else {
|
||||
activeHatchingList.value =
|
||||
Resource<PaginationModel<HatchingModel>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
searchedValue.value!.trim().isNotEmpty &&
|
||||
currentPage.value > 1) {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getHatchingPoultry(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {'type': 'hatching'},
|
||||
role: 'PoultryScience',
|
||||
pageSize: 50,
|
||||
page: currentPage.value,
|
||||
),
|
||||
),
|
||||
onSuccess: (res) {
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
activeHatchingList.value =
|
||||
Resource<PaginationModel<HatchingModel>>.empty();
|
||||
} else {
|
||||
activeHatchingList.value =
|
||||
Resource<PaginationModel<HatchingModel>>.success(
|
||||
PaginationModel<HatchingModel>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [
|
||||
...(activeHatchingList.value.data?.results ?? []),
|
||||
...(res?.results ?? []),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void toggleExpanded(int index) {
|
||||
expandedIndex.value = expandedIndex.value == index ? -1 : index;
|
||||
}
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
currentPage.value = 1;
|
||||
await getHatchingList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/active_hatching/logic.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 ActiveHatchingPage extends GetView<ActiveHatchingLogic> {
|
||||
const ActiveHatchingPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
hasSearch: true,
|
||||
hasFilter: false,
|
||||
backId: poultryFirstKey,
|
||||
routes: controller.routesName,
|
||||
onSearchChanged: (data) {
|
||||
controller.searchedValue.value = data;
|
||||
controller.getHatchingList();
|
||||
},
|
||||
child: hatchingWidget(),
|
||||
/*widgets: [
|
||||
hatchingWidget()
|
||||
],*/
|
||||
);
|
||||
}
|
||||
|
||||
Widget hatchingWidget() {
|
||||
return ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
hasMore: data.value.data?.next != null,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.activeFramSvg.path,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async => controller.getHatchingList(true),
|
||||
|
||||
);
|
||||
}, controller.activeHatchingList);
|
||||
}
|
||||
|
||||
Container itemListExpandedWidget(HatchingModel item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.poultry?.user?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
|
||||
Visibility(
|
||||
child: Text(
|
||||
item.violation == true ? 'پیگیری' : 'عادی',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan10.copyWith(color: AppColor.redDark),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'نژاد:${item.breed?.first.breed ?? 'N/A'}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
Text(
|
||||
' سن${item.age} (روز)',
|
||||
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
' دوره جوجه ریزی:${item.period}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
buildRow(title: 'شماره مجوز جوجه ریزی', value: item.licenceNumber ?? 'N/A'),
|
||||
buildUnitRow(
|
||||
title: 'حجم جوجه ریزی',
|
||||
value: item.quantity.separatedByCommaFa,
|
||||
unit: '(قطعه)',
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'مانده در سالن',
|
||||
value: item.leftOver.separatedByCommaFa,
|
||||
unit: '(قطعه)',
|
||||
),
|
||||
buildUnitRow(title: 'تلفات', value: item.losses.separatedByCommaFa, unit: '(قطعه)'),
|
||||
buildRow(
|
||||
title: 'دامپزشک فارم',
|
||||
value: '${item.vetFarm?.vetFarmFullName}(${item.vetFarm?.vetFarmMobile})',
|
||||
),
|
||||
buildRow(
|
||||
title: 'شرح بازرسی',
|
||||
value: item.reportInfo?.image == false ? 'ارسال تصویر جوجه ریزی فارم ' : 'تکمیل شده',
|
||||
titleStyle: AppFonts.yekan14.copyWith(
|
||||
color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark,
|
||||
),
|
||||
valueStyle: AppFonts.yekan14.copyWith(
|
||||
color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemListWidget(HatchingModel item) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text(
|
||||
item.poultry?.user?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.poultry?.user?.mobile ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
spacing: 3,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
item.poultry?.unitName ?? 'N/Aaq',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
Text(
|
||||
item.poultry?.licenceNumber ?? 'N/A',
|
||||
textAlign: TextAlign.left,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_farm/poultry_farm.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/home/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class FarmLogic extends GetxController {
|
||||
List<String> routes = ['اقدام', 'فارم ها'];
|
||||
PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||
BasePageLogic baseLogic = Get.find<BasePageLogic>();
|
||||
final PoultryScienceHomeLogic _homeLogic =
|
||||
Get.find<PoultryScienceHomeLogic>();
|
||||
RxList<InformationTagData> tagInfo = <InformationTagData>[
|
||||
InformationTagData(
|
||||
labelTitle: 'کل فارم ها',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.cubeScanSvg.path,
|
||||
iconColor: AppColor.blueNormalOld,
|
||||
valueBgColor: Colors.white,
|
||||
labelGradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [AppColor.blueLight, Colors.white],
|
||||
),
|
||||
),
|
||||
InformationTagData(
|
||||
labelTitle: 'حجم جوجه ریزی',
|
||||
unit: 'قطعه',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.cubeCardSvg.path,
|
||||
blendMode: BlendMode.dst,
|
||||
valueBgColor: Colors.white,
|
||||
labelGradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [AppColor.greenLightHover, Colors.white],
|
||||
),
|
||||
),
|
||||
].obs;
|
||||
Rx<Resource<PaginationModel<PoultryFarm>>> farmList =
|
||||
Resource<PaginationModel<PoultryFarm>>.loading().obs;
|
||||
|
||||
RxInt currentPage = 1.obs;
|
||||
final RxBool isLoadingMoreList = false.obs;
|
||||
RxInt expandedIndex = RxInt(-1);
|
||||
|
||||
Rx<Jalali> fromDateFilter = Jalali.now().obs;
|
||||
Rx<Jalali> toDateFilter = Jalali.now().obs;
|
||||
RxnString searchedValue = RxnString();
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
tagInfo[0] = tagInfo[0].copyWith(
|
||||
isLoading: false,
|
||||
value: _homeLogic.tagInfo['first']!.first.value,
|
||||
);
|
||||
tagInfo[1] = tagInfo[1].copyWith(
|
||||
isLoading: false,
|
||||
value: _homeLogic.tagInfo['second']!.first.value,
|
||||
);
|
||||
|
||||
getFarmList();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
baseLogic.clearSearch();
|
||||
}
|
||||
|
||||
Future<void> getFarmList([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreList.value = true;
|
||||
} else {
|
||||
farmList.value = Resource<PaginationModel<PoultryFarm>>.loading();
|
||||
}
|
||||
await safeCall(
|
||||
call: () async =>
|
||||
await rootLogic.poultryRepository.getPoultryScienceFarmList(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {'type': 'farm'},
|
||||
role: 'PoultryScience',
|
||||
pageSize: 50,
|
||||
search: 'filter',
|
||||
value: '',
|
||||
page: currentPage.value,
|
||||
),
|
||||
),
|
||||
onSuccess: (res) {
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
farmList.value = Resource<PaginationModel<PoultryFarm>>.empty();
|
||||
} else {
|
||||
farmList.value = Resource<PaginationModel<PoultryFarm>>.success(
|
||||
PaginationModel<PoultryFarm>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [
|
||||
...(farmList.value.data?.results ?? []),
|
||||
...?res?.results,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
void toggleExpanded(int index) {
|
||||
expandedIndex.value = expandedIndex.value == index ? -1 : index;
|
||||
}
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
currentPage.value = 1;
|
||||
farmList.value = Resource<PaginationModel<PoultryFarm>>.loading();
|
||||
await getFarmList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_farm/poultry_farm.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class FarmPage extends GetView<FarmLogic> {
|
||||
const FarmPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
hasFilter: false,
|
||||
hasSearch: true,
|
||||
onRefresh: controller.onRefresh,
|
||||
onFilterTap: () {
|
||||
Get.bottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
filterBottomSheet(),
|
||||
);
|
||||
},
|
||||
onSearchChanged: (data) {
|
||||
controller.searchedValue.value = data;
|
||||
controller.getFarmList();
|
||||
},
|
||||
routes: controller.routes,
|
||||
backId: poultryFirstKey,
|
||||
child: Column(children: [firstTagInformation(), farmListWidget()]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget firstTagInformation() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
|
||||
child: ObxValue((data) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.w),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: List.generate(
|
||||
data.length,
|
||||
(index) => Expanded(child: InformationTag(data: data[index])),
|
||||
),
|
||||
),
|
||||
);
|
||||
}, controller.tagInfo),
|
||||
);
|
||||
}
|
||||
|
||||
Widget farmListWidget() {
|
||||
return Expanded(
|
||||
child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
hasMore: data.value.data?.next != null,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.cubeScanSvg.path,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async => controller.getFarmList(true),
|
||||
|
||||
);
|
||||
}, controller.farmList),
|
||||
);
|
||||
}
|
||||
|
||||
Container itemListExpandedWidget(PoultryFarm item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.unitName ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
|
||||
Visibility(
|
||||
child: Text(
|
||||
'${item.address?.province?.name} / ${item.address?.city?.name}',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'تعاونی : ${item.cityOperator ?? 'ندارد'}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
|
||||
Text(
|
||||
' تعداد سالن : ${item.numberOfHalls}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
buildRow(title: 'مالک/ تلفن', value: '${item.user?.fullname} (${item.user?.mobile})'),
|
||||
buildRow(title: 'شناسه یکتا', value: item.breedingUniqueId ?? 'N/A'),
|
||||
buildRow(title: 'کد اپیدمیولوژیک', value: item.epidemiologicalCode ?? 'N/A'),
|
||||
buildRow(title: 'کد بهداشتی', value: item.healthCertificateNumber ?? 'N/A'),
|
||||
buildRow(
|
||||
title: 'دامپزشک فارم',
|
||||
value: '${item.vetFarm?.fullName} (${item.vetFarm?.mobile ?? '-'})',
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'ظرفیت فارم',
|
||||
value: item.totalCapacity.separatedByCommaFa,
|
||||
unit: '(قطعه)',
|
||||
),
|
||||
buildRow(
|
||||
title: 'جوجه ریزی فعال (تعداد دوره) ',
|
||||
value:
|
||||
'${(item.hatchingInfo?.activeHatching ?? false) ? 'دارد' : 'ندارد'} (${item.hatchingInfo?.period ?? 0})',
|
||||
),
|
||||
|
||||
/* buildRow(
|
||||
title: 'شرح بازرسی',
|
||||
value: item.reportInfo?.image == false ? 'ارسال تصویر جوجه ریزی فارم ' : 'تکمیل شده',
|
||||
titleStyle: AppFonts.yekan14.copyWith(
|
||||
color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark,
|
||||
),
|
||||
valueStyle: AppFonts.yekan14.copyWith(
|
||||
color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark,
|
||||
),
|
||||
),*/
|
||||
/* Visibility(
|
||||
visible: (item.reportInfo?.image == false),
|
||||
child: RElevated(
|
||||
text: 'ثبت بازرسی',
|
||||
isFullWidth: true,
|
||||
width: 150.w,
|
||||
height: 40.h,
|
||||
onPressed: () {
|
||||
cameraBottomSheet(item.id!);
|
||||
},
|
||||
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemListWidget(PoultryFarm item) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text(
|
||||
item.unitName ?? 'N/A',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.user?.mobile ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
spacing: 3,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'شناسه یکتا: ${item.breedingUniqueId}',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
'${item.address?.province?.name}/${item.address?.city?.name}',
|
||||
textAlign: TextAlign.left,
|
||||
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget filterBottomSheet() => filterBottomSheetWidget(
|
||||
fromDate: controller.fromDateFilter,
|
||||
onChangedFromDate: (jalali) => controller.fromDateFilter.value = jalali,
|
||||
toDate: controller.toDateFilter,
|
||||
onChangedToDate: (jalali) => controller.toDateFilter.value = jalali,
|
||||
onSubmit: () => controller.getFarmList(),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_order/poultry_order.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/killing_registration/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class GenocideLogic extends GetxController {
|
||||
List<String> routesName = ['اقدام', 'درخواست کشتارها'];
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
BaseLogic baseLogic = Get.find<BaseLogic>();
|
||||
var gService = Get.find<GService>();
|
||||
var rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||
var killRegistration = Get.find<KillingRegistrationLogic>();
|
||||
|
||||
Rx<Resource<PaginationModel<PoultryOrder>>> poultryOrderList =
|
||||
Resource<PaginationModel<PoultryOrder>>.loading().obs;
|
||||
|
||||
RxInt expandedIndex = RxInt(-1);
|
||||
final RxInt currentPage = 1.obs;
|
||||
|
||||
final RxBool isLoadingMore = false.obs;
|
||||
|
||||
final RxBool isLoadingDelete = false.obs;
|
||||
|
||||
Rx<Jalali> fromDateFilter = Jalali.now().obs;
|
||||
Rx<Jalali> toDateFilter = Jalali.now().obs;
|
||||
RxnString searchedValue = RxnString();
|
||||
|
||||
/* final RxBool isLoadingMoreAllocationsMade = false.obs;
|
||||
final RxBool isOnLoadingSubmitOrEdit = false.obs;*/
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
getPoultryOrderList();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
baseLogic.clearSearch();
|
||||
}
|
||||
|
||||
Future<void> getPoultryOrderList([bool loadingMore = false]) async {
|
||||
if (loadingMore) {
|
||||
isLoadingMore.value = true;
|
||||
} else {
|
||||
poultryOrderList.value =
|
||||
Resource<PaginationModel<PoultryOrder>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
searchedValue.value!.trim().isNotEmpty &&
|
||||
currentPage.value > 1) {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getPoultryOderList(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
pageSize: 20,
|
||||
page: currentPage.value,
|
||||
search: 'filter',
|
||||
role: gService.getRole(Module.chicken),
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
queryParams: {'today': null},
|
||||
),
|
||||
),
|
||||
onSuccess: (res) async {
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
poultryOrderList.value =
|
||||
Resource<PaginationModel<PoultryOrder>>.empty();
|
||||
} else {
|
||||
if (loadingMore) {
|
||||
poultryOrderList.value =
|
||||
Resource<PaginationModel<PoultryOrder>>.success(
|
||||
PaginationModel<PoultryOrder>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [
|
||||
...(poultryOrderList.value.data?.results ?? []),
|
||||
...(res?.results ?? []),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
poultryOrderList.value =
|
||||
Resource<PaginationModel<PoultryOrder>>.success(res!);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deletePoultryOrder(int id) async {
|
||||
toggleExpanded(-1);
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.deletePoultryOder(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
orderId: id.toString(),
|
||||
),
|
||||
onSuccess: (_) {
|
||||
defaultShowSuccessMessage('درخواست با موفقیت حذف شد');
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void toggleExpanded(int index) {
|
||||
expandedIndex.value = expandedIndex.value == index ? -1 : index;
|
||||
}
|
||||
|
||||
String getRequestType(PoultryOrder item) {
|
||||
if (item.market ?? false) {
|
||||
return 'پنل معاملات';
|
||||
} else if (item.union ?? false) {
|
||||
return 'اتحادیه';
|
||||
} else {
|
||||
return 'خرید مستقیم';
|
||||
}
|
||||
}
|
||||
|
||||
String getKillType(PoultryOrder item) {
|
||||
if (item.export ?? false) {
|
||||
return 'صادرات';
|
||||
} else if (item.freezing ?? false) {
|
||||
return 'انجماد';
|
||||
} else {
|
||||
return 'عادی';
|
||||
}
|
||||
}
|
||||
|
||||
String getState(PoultryOrder item) {
|
||||
if (item.stateProcess == 'pending') {
|
||||
return 'در انتظار تایید';
|
||||
} else {
|
||||
return 'تایید شده';
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
currentPage.value = 1;
|
||||
await getPoultryOrderList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_order/poultry_order.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/killing_registration/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_chicken/presentation/widget/filter_bottom_sheet.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class GenocidePage extends GetView<GenocideLogic> {
|
||||
const GenocidePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
routes: controller.routesName,
|
||||
hasSearch: true,
|
||||
hasFilter: true,
|
||||
onRefresh: controller.onRefresh,
|
||||
onSearchChanged: (data) {
|
||||
controller.searchedValue.value = data;
|
||||
controller.getPoultryOrderList();
|
||||
},
|
||||
backId: poultryFirstKey,
|
||||
onFilterTap: () {
|
||||
Get.bottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
filterBottomSheet(),
|
||||
);
|
||||
},
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned.fill(child: poultryOrderListWidget()),
|
||||
Positioned(
|
||||
bottom: 130,
|
||||
right: 16,
|
||||
child: RFab.add(
|
||||
onPressed: () {
|
||||
Get.bottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
killRegistrationBottomSheet(),
|
||||
).whenComplete(() {
|
||||
controller.killRegistration.clearAllFields();
|
||||
controller.killRegistration.onReady();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//region List and Items
|
||||
Widget poultryOrderListWidget() {
|
||||
return ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
hasMore: data.value.data?.next != null,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.timerSvg.path,
|
||||
labelIconColor: AppColor.yellowNormal2,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async => controller.getPoultryOrderList(true),
|
||||
);
|
||||
}, controller.poultryOrderList);
|
||||
}
|
||||
|
||||
Container itemListExpandedWidget(PoultryOrder item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.poultry?.unitName ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
|
||||
Visibility(
|
||||
child: Text(
|
||||
'${item.poultry?.address?.province?.name} / ${item.poultry?.address?.city?.name}',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'سن مرغ:${item.hatching?.age ?? '-'} (روز)',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
|
||||
Text(
|
||||
item.sendDate?.formattedJalaliDate ?? '-',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
|
||||
Text(
|
||||
'تعداد:${item.quantity.separatedByComma} (قطعه)',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
buildRow(title: 'کد سفارش', value: '${item.orderCode} '),
|
||||
buildRow(
|
||||
title: 'نوع فروش',
|
||||
value: (item.freeSaleInProvince ?? false) ? 'آزاد' : 'دولتی ',
|
||||
),
|
||||
buildRow(title: 'نوع کشتار ', value: controller.getKillType(item)),
|
||||
buildRow(title: 'درخواست', value: controller.getRequestType(item)),
|
||||
|
||||
buildRow(
|
||||
title: 'میانگین وزنی',
|
||||
value: '${(item.indexWeight)} (کیلوگرم)',
|
||||
),
|
||||
buildRow(
|
||||
title: 'قیمت مرغدار',
|
||||
value: '${item.amount.separatedByComma} (ریال)',
|
||||
),
|
||||
buildRow(
|
||||
title: 'مانده در سالن ',
|
||||
value: '${item.hatching?.leftOver.separatedByComma ?? 0} (قطعه)',
|
||||
),
|
||||
buildRow(title: ' وضعیت', value: controller.getState(item)),
|
||||
|
||||
Visibility(
|
||||
visible: item.stateProcess == 'pending',
|
||||
child: ObxValue((data) {
|
||||
return ROutlinedElevatedIcon(
|
||||
height: 40.h,
|
||||
width: Get.width,
|
||||
text: 'حذف',
|
||||
icon: Assets.vec.trashSvg.svg(
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
colorFilter: ColorFilter.mode(
|
||||
AppColor.error,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
textStyle: AppFonts.yekan16Bold.copyWith(color: AppColor.error),
|
||||
borderColor: AppColor.error,
|
||||
foregroundColor: AppColor.error,
|
||||
pressedBackgroundColor: AppColor.error,
|
||||
onPressed: data.value
|
||||
? null
|
||||
: () => _buildDeleteDialog(
|
||||
onConfirm: () async {
|
||||
Get.back();
|
||||
await controller.deletePoultryOrder(item.id!);
|
||||
controller.getPoultryOrderList();
|
||||
},
|
||||
),
|
||||
);
|
||||
}, controller.isLoadingDelete),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemListWidget(PoultryOrder item) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text(
|
||||
item.poultry?.unitName ?? 'N/A',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.sendDate?.formattedJalaliDate ?? '-',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
spacing: 3,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'کد سفارش : ${item.orderCode ?? '-'}',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
|
||||
Text(
|
||||
'تعداد:${item.quantity.separatedByComma} (قطعه)',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region other widgets
|
||||
void _buildDeleteDialog({required VoidCallback onConfirm}) {
|
||||
Get.defaultDialog(
|
||||
title: 'حذف درخواست کشتار',
|
||||
middleText: 'آیا از حذف این درخواست کشتار مطمئن هستید؟',
|
||||
confirm: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.error,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: onConfirm,
|
||||
child: Text('بله'),
|
||||
),
|
||||
cancel: ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
child: Text('خیر'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget filterBottomSheet() => filterBottomSheetWidget(
|
||||
fromDate: controller.fromDateFilter,
|
||||
onChangedFromDate: (jalali) => controller.fromDateFilter.value = jalali,
|
||||
toDate: controller.toDateFilter,
|
||||
onChangedToDate: (jalali) => controller.toDateFilter.value = jalali,
|
||||
onSubmit: () => controller.getPoultryOrderList(),
|
||||
);
|
||||
|
||||
//endregion
|
||||
|
||||
//region kill registration bottom sheet
|
||||
Widget killRegistrationBottomSheet() {
|
||||
return BaseBottomSheet(
|
||||
height: Get.height * 0.9,
|
||||
bgColor: Color(0x66E4E4E4),
|
||||
child: KillingRegistrationPage(),
|
||||
);
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/presentation/widget/custom/information_card_widget.dart';
|
||||
|
||||
class PoultryScienceHomeLogic extends GetxController {
|
||||
PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||
Rxn<HomePoultryScienceModel> homeInformation = Rxn();
|
||||
RxBool isExpanded = false.obs;
|
||||
RxMap<String, List<InformationTagData>> tagInfo = RxMap({
|
||||
'first': [
|
||||
InformationTagData(
|
||||
labelTitle: 'کل فارم ها',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.cubeScanSvg.path,
|
||||
iconColor: AppColor.blueFlashing,
|
||||
blendMode: BlendMode.srcOut,
|
||||
valueBgColor: Colors.white,
|
||||
labelGradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [AppColor.blueLight, Colors.white],
|
||||
),
|
||||
),
|
||||
InformationTagData(
|
||||
labelTitle: 'تعداد جوجه ریزی',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.cubeCardSvg.path,
|
||||
blendMode: BlendMode.dst,
|
||||
valueBgColor: Colors.white,
|
||||
labelGradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [AppColor.greenLightHover, Colors.white],
|
||||
),
|
||||
),
|
||||
],
|
||||
'second': [
|
||||
InformationTagData(
|
||||
labelTitle: 'حجم جوجه ریزی',
|
||||
unit: 'قطعه',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.hashtagSvg.path,
|
||||
iconColor: const Color(0xFF6C5D60),
|
||||
labelBgColor: const Color(0xFFDDC0C7),
|
||||
valueBgColor: const Color(0xFFEDDCE0),
|
||||
),
|
||||
InformationTagData(
|
||||
labelTitle: 'مانده در سالن',
|
||||
unit: 'قطعه',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.homeHashtagSvg.path,
|
||||
labelBgColor: const Color(0xFFAFCBFF),
|
||||
valueBgColor: const Color(0xFFCEDFFF),
|
||||
),
|
||||
],
|
||||
'third': [
|
||||
InformationTagData(
|
||||
labelTitle: 'تلفات',
|
||||
unit: 'قطعه',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.boxRemoveSvg.path,
|
||||
|
||||
iconColor: const Color(0xFF426060),
|
||||
labelBgColor: const Color(0xFFA5D1D2),
|
||||
valueBgColor: const Color(0xFFC7DFE0),
|
||||
),
|
||||
InformationTagData(
|
||||
labelTitle: 'حجم کشتار شده',
|
||||
unit: 'قطعه',
|
||||
isLoading: true,
|
||||
labelVecIcon: Assets.vec.closeSquareFilledSvg.path,
|
||||
blendMode: BlendMode.dst,
|
||||
labelBgColor: Color(0xFFC8B8D1),
|
||||
valueBgColor: Color(0xFFDAD4DD),
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
RxList<InformationCardData> ageCardData = [
|
||||
InformationCardData(
|
||||
labelTitle: 'بیشترین سن جوجه ریزی',
|
||||
isLoading: true,
|
||||
unit: 'روز',
|
||||
labelVecIcon: Assets.vec.homeTrendUpSvg.path,
|
||||
iconColor: const Color.fromRGBO(85, 97, 93, 1),
|
||||
cardBgColor: const Color(0xFFE6FAF5),
|
||||
labelBgColor: const Color(0xFFB0EFDF),
|
||||
),
|
||||
InformationCardData(
|
||||
labelTitle: 'کمترین سن جوجه ریزی',
|
||||
isLoading: true,
|
||||
unit: 'روز',
|
||||
labelVecIcon: Assets.vec.homeTrendDownSvg.path,
|
||||
iconColor: const Color(0xFF6F6164),
|
||||
cardBgColor: const Color(0xFFEDDCE0),
|
||||
labelBgColor: const Color(0xFFE0BCC5),
|
||||
),
|
||||
].obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
getHomePoultryHatching();
|
||||
}
|
||||
|
||||
Future<void> getHomePoultryHatching() async {
|
||||
await safeCall<HomePoultryScienceModel?>(
|
||||
call: () async => await rootLogic.poultryRepository.getHomePoultry(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
type: 'home',
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
homeInformation.value = result;
|
||||
tagInfo['first'] = tagInfo['first']!.map((tag) {
|
||||
if (tag.labelTitle == 'کل فارم ها') {
|
||||
return tag.copyWith(
|
||||
value: result.farmCount?.separatedByCommaFa ?? '0',
|
||||
isLoading: false,
|
||||
);
|
||||
}
|
||||
if (tag.labelTitle == 'تعداد جوجه ریزی') {
|
||||
return tag.copyWith(
|
||||
value: result.hatchingCount?.separatedByCommaFa ?? '0',
|
||||
isLoading: false,
|
||||
);
|
||||
}
|
||||
return tag;
|
||||
}).toList();
|
||||
|
||||
// second
|
||||
tagInfo['second'] = tagInfo['second']!.map((tag) {
|
||||
switch (tag.labelTitle) {
|
||||
case 'حجم جوجه ریزی':
|
||||
return tag.copyWith(
|
||||
value: result.hatchingQuantity?.separatedByCommaFa ?? '0',
|
||||
isLoading: false,
|
||||
);
|
||||
case 'مانده در سالن':
|
||||
return tag.copyWith(
|
||||
value: result.hatchingLeftOver?.separatedByCommaFa ?? '0',
|
||||
isLoading: false,
|
||||
);
|
||||
default:
|
||||
return tag;
|
||||
}
|
||||
}).toList();
|
||||
|
||||
// third
|
||||
tagInfo['third'] = tagInfo['third']!.map((tag) {
|
||||
switch (tag.labelTitle) {
|
||||
case 'تلفات':
|
||||
return tag.copyWith(
|
||||
value: result.hatchingLosses?.separatedByCommaFa ?? '0',
|
||||
isLoading: false,
|
||||
);
|
||||
case 'حجم کشتار شده':
|
||||
return tag.copyWith(
|
||||
value:
|
||||
result.hatchingKilledQuantity?.separatedByCommaFa ?? '0',
|
||||
isLoading: false,
|
||||
);
|
||||
default:
|
||||
return tag;
|
||||
}
|
||||
}).toList();
|
||||
|
||||
ageCardData.value = ageCardData.map((element) {
|
||||
switch (element.labelTitle) {
|
||||
case 'کمترین سن جوجه ریزی':
|
||||
return element.copyWith(
|
||||
value: result.hatchingMinAge?.separatedByCommaFa ?? '0',
|
||||
isLoading: false,
|
||||
);
|
||||
case 'بیشترین سن جوجه ریزی':
|
||||
return element.copyWith(
|
||||
value: result.hatchingMaxAge?.separatedByCommaFa ?? '0',
|
||||
isLoading: false,
|
||||
);
|
||||
default:
|
||||
return element;
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching_report/hatching_report.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class InspectionPoultryScienceLogic extends GetxController {
|
||||
BaseLogic baseLogic = Get.find<BaseLogic>();
|
||||
Rx<Resource<PaginationModel<HatchingModel>>> hatchingList =
|
||||
Resource<PaginationModel<HatchingModel>>.loading().obs;
|
||||
|
||||
Rx<Resource<PaginationModel<HatchingReport>>> hatchingReportList =
|
||||
Resource<PaginationModel<HatchingReport>>.loading().obs;
|
||||
|
||||
PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||
|
||||
Rx<LatLng> currentLocation = LatLng(
|
||||
34.798315281272544,
|
||||
48.51479142983491,
|
||||
).obs;
|
||||
|
||||
final RxBool isLoadingMoreAllocationsMade = false.obs;
|
||||
RxInt currentPage = 1.obs;
|
||||
RxInt expandedIndex = RxInt(-1);
|
||||
RxList<XFile> pickedImages = <XFile>[].obs;
|
||||
final List<MultipartFile> _multiPartPickedImages = <MultipartFile>[];
|
||||
|
||||
RxBool isOnUpload = false.obs;
|
||||
|
||||
RxDouble presentUpload = 0.0.obs;
|
||||
RxList<String> routesName = RxList();
|
||||
RxInt selectedSegmentIndex = 0.obs;
|
||||
|
||||
RxnString searchedValue = RxnString();
|
||||
Rx<Jalali> fromDateFilter = Jalali.now().obs;
|
||||
Rx<Jalali> toDateFilter = Jalali.now().obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
routesName.value = ['اقدام'].toList();
|
||||
|
||||
ever(selectedSegmentIndex, (callback) {
|
||||
routesName.removeLast();
|
||||
routesName.add(callback == 0 ? 'بازرسی' : 'بایگانی');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
getHatchingList();
|
||||
getHatchingReport();
|
||||
|
||||
checkLocationPermission(request: true);
|
||||
|
||||
ever(pickedImages, (callback) {
|
||||
_multiPartPickedImages.clear();
|
||||
for (var element in pickedImages) {
|
||||
_multiPartPickedImages.add(
|
||||
MultipartFile.fromFileSync(element.path, filename: element.name),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
baseLogic.clearSearch();
|
||||
}
|
||||
|
||||
Future<void> getHatchingList([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
hatchingList.value = Resource<PaginationModel<HatchingModel>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
searchedValue.value!.trim().isNotEmpty &&
|
||||
currentPage.value > 1) {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getHatchingPoultry(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {'type': 'hatching', 'report': true},
|
||||
role: 'PoultryScience',
|
||||
search: 'filter',
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
pageSize: 50,
|
||||
page: currentPage.value,
|
||||
),
|
||||
),
|
||||
onSuccess: (res) {
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
hatchingList.value = Resource<PaginationModel<HatchingModel>>.empty();
|
||||
} else {
|
||||
hatchingList.value = Resource<PaginationModel<HatchingModel>>.success(
|
||||
PaginationModel<HatchingModel>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [
|
||||
...(hatchingList.value.data?.results ?? []),
|
||||
...(res?.results ?? []),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getHatchingReport([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
hatchingReportList.value =
|
||||
Resource<PaginationModel<HatchingReport>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
searchedValue.value!.trim().isNotEmpty &&
|
||||
currentPage.value > 1) {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
safeCall(
|
||||
call: () async =>
|
||||
await rootLogic.poultryRepository.getHatchingPoultryReport(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
role: 'PoultryScience',
|
||||
pageSize: 50,
|
||||
search: 'filter',
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
page: currentPage.value,
|
||||
),
|
||||
),
|
||||
onSuccess: (res) {
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
hatchingReportList.value =
|
||||
Resource<PaginationModel<HatchingReport>>.empty();
|
||||
} else {
|
||||
hatchingReportList.value =
|
||||
Resource<PaginationModel<HatchingReport>>.success(
|
||||
PaginationModel<HatchingReport>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [
|
||||
...(hatchingReportList.value.data?.results ?? []),
|
||||
...(res?.results ?? []),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> pickImages() async {
|
||||
determineCurrentPosition();
|
||||
var tmp = await pickCameraImage();
|
||||
if (tmp?.path != null && pickedImages.length < 7) {
|
||||
pickedImages.add(tmp!);
|
||||
}
|
||||
}
|
||||
|
||||
void removeImage(int index) {
|
||||
pickedImages.removeAt(index);
|
||||
}
|
||||
|
||||
void clearImages() {
|
||||
pickedImages.clear();
|
||||
}
|
||||
|
||||
Future<void> submitInspectionReport({required int id}) async {
|
||||
isOnUpload.value = true;
|
||||
|
||||
final tmpFiles = await Future.wait(
|
||||
pickedImages.map(
|
||||
(element) =>
|
||||
MultipartFile.fromFile(element.path, filename: element.name),
|
||||
),
|
||||
);
|
||||
|
||||
var data = FormData.fromMap({
|
||||
'file': tmpFiles,
|
||||
'hatching_id': id.toString(),
|
||||
'lat': currentLocation.value.latitude.toString(),
|
||||
'log': currentLocation.value.longitude.toString(),
|
||||
});
|
||||
|
||||
safeCall(
|
||||
call: () async =>
|
||||
await rootLogic.poultryRepository.submitPoultryScienceReport(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
data: data,
|
||||
onSendProgress: (sent, total) {
|
||||
presentUpload.value = calculateUploadProgress(
|
||||
sent: sent,
|
||||
total: total,
|
||||
);
|
||||
},
|
||||
),
|
||||
onSuccess: (res) {
|
||||
closeBottomSheet();
|
||||
clearImages();
|
||||
getHatchingList();
|
||||
getHatchingReport();
|
||||
isOnUpload.value = false;
|
||||
},
|
||||
onError: (error, stackTrace) async {
|
||||
clearImages();
|
||||
isOnUpload.value = false;
|
||||
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 4),
|
||||
).then((value) => closeBottomSheet());
|
||||
},
|
||||
showError: true,
|
||||
);
|
||||
}
|
||||
|
||||
void closeBottomSheet() {
|
||||
Get.back();
|
||||
}
|
||||
|
||||
double calculateUploadProgress({required int sent, required int total}) {
|
||||
if (total != 0) {
|
||||
double progress = (sent * 100 / total) / 100;
|
||||
return progress;
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
void toggleExpanded(int index) {
|
||||
expandedIndex.value = expandedIndex.value == index ? -1 : index;
|
||||
}
|
||||
|
||||
String getStatus(HatchingReport item) {
|
||||
if (item.state == 'accepted') {
|
||||
return 'تکمیل شده';
|
||||
} else if (item.state == 'rejected') {
|
||||
return 'رد شده';
|
||||
} else {
|
||||
return 'در حال بررسی';
|
||||
}
|
||||
}
|
||||
|
||||
Color getStatusColor(HatchingReport item) {
|
||||
if (item.state == 'accepted') {
|
||||
return AppColor.greenNormal;
|
||||
} else if (item.state == 'rejected') {
|
||||
return AppColor.redNormal;
|
||||
} else {
|
||||
return AppColor.yellowNormal;
|
||||
}
|
||||
}
|
||||
|
||||
void setSearchValue(String? data) {
|
||||
dLog('Search Value: $data');
|
||||
searchedValue.value = data?.trim();
|
||||
final isReporter = selectedSegmentIndex.value == 1;
|
||||
if (isReporter) {
|
||||
getHatchingReport();
|
||||
} else {
|
||||
getHatchingList();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
currentPage.value = 1;
|
||||
|
||||
await Future.wait([getHatchingList(), getHatchingReport()]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,699 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/hatching_report/hatching_report.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 'logic.dart';
|
||||
|
||||
class InspectionPoultrySciencePage extends GetView<InspectionPoultryScienceLogic> {
|
||||
const InspectionPoultrySciencePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
hasBack: true,
|
||||
hasFilter: true,
|
||||
hasSearch: true,
|
||||
onFilterTap: () {
|
||||
Get.bottomSheet(filterBottomSheet());
|
||||
},
|
||||
onRefresh: controller.onRefresh,
|
||||
onSearchChanged: (data) => controller.setSearchValue(data),
|
||||
backId: poultryFirstKey,
|
||||
routesWidget: ContainerBreadcrumb(rxRoutes: controller.routesName),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 50, child: segmentWidget()),
|
||||
ObxValue((data) {
|
||||
return data.value == 0 ? hatchingWidget() : reportWidget();
|
||||
}, controller.selectedSegmentIndex),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget hatchingWidget() {
|
||||
return Expanded(
|
||||
child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
hasMore: data.value.data?.next != null,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: item.reportInfo?.image == false
|
||||
? Assets.vec.timerSvg.path
|
||||
: Assets.vec.checkSquareSvg.path,
|
||||
labelIconColor: item.reportInfo?.image == false
|
||||
? AppColor.yellowNormal2
|
||||
: AppColor.mediumGreyDarkHover,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async => controller.getHatchingList(true),
|
||||
);
|
||||
}, controller.hatchingList),
|
||||
);
|
||||
}
|
||||
|
||||
Container itemListExpandedWidget(HatchingModel item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.poultry?.user?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
|
||||
Visibility(
|
||||
child: Text(
|
||||
item.violation == true ? 'پیگیری' : 'عادی',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan10.copyWith(color: AppColor.redDark),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'نژاد:${item.breed?.first.breed ?? 'N/A'}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
Text(
|
||||
' سن ${item.age} (روزه)',
|
||||
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
' دوره جوجه ریزی:${item.period}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
buildRow(title: 'شماره مجوز جوجه ریزی', value: item.licenceNumber ?? 'N/A'),
|
||||
buildUnitRow(
|
||||
title: 'حجم جوجه ریزی',
|
||||
value: item.quantity.separatedByCommaFa,
|
||||
|
||||
unit: '(قطعه)',
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'مانده در سالن',
|
||||
value: item.leftOver.separatedByCommaFa,
|
||||
unit: '(قطعه)',
|
||||
),
|
||||
buildUnitRow(title: 'تلفات', value: item.losses.separatedByCommaFa, unit: '(قطعه)'),
|
||||
buildRow(
|
||||
title: 'دامپزشک فارم',
|
||||
value: '${item.vetFarm?.vetFarmFullName}(${item.vetFarm?.vetFarmMobile})',
|
||||
),
|
||||
buildRow(
|
||||
title: 'شرح بازرسی',
|
||||
value: item.reportInfo?.image == false ? 'ارسال تصویر جوجه ریزی فارم ' : 'تکمیل شده',
|
||||
titleStyle: AppFonts.yekan14.copyWith(
|
||||
color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark,
|
||||
),
|
||||
valueStyle: AppFonts.yekan14.copyWith(
|
||||
color: (item.reportInfo?.image ?? false) ? AppColor.greenNormal : AppColor.redDark,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: (item.reportInfo?.image == false),
|
||||
child: RElevated(
|
||||
text: 'ثبت بازرسی',
|
||||
isFullWidth: true,
|
||||
width: 150.w,
|
||||
height: 40.h,
|
||||
onPressed: () {
|
||||
cameraBottomSheet(item.id!);
|
||||
},
|
||||
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void cameraBottomSheet(int id) {
|
||||
Get.bottomSheet(
|
||||
isDismissible: false,
|
||||
isScrollControlled: false,
|
||||
BaseBottomSheet(
|
||||
height: 350.h,
|
||||
child: Column(
|
||||
children: [
|
||||
ObxValue((data) {
|
||||
return GridView.builder(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
childAspectRatio: 1,
|
||||
),
|
||||
shrinkWrap: true,
|
||||
itemCount: controller.pickedImages.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index + 1 < 7 && index == data.length) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
await controller.pickImages();
|
||||
},
|
||||
child: Container(
|
||||
width: 80.h,
|
||||
height: 80.h,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.lightGreyNormal,
|
||||
borderRadius: BorderRadius.circular(8.r),
|
||||
),
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.add_a_photo,
|
||||
color: AppColor.lightGreyDarker,
|
||||
size: 32.h,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container(
|
||||
width: 80.h,
|
||||
height: 80.h,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.lightGreyNormal,
|
||||
borderRadius: BorderRadius.circular(8.r),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.file(File(data[index].path), fit: BoxFit.cover),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: 4,
|
||||
left: 4,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
controller.removeImage(index);
|
||||
},
|
||||
child: Container(
|
||||
width: 24.w,
|
||||
height: 24.h,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
padding: EdgeInsets.all(4),
|
||||
decoration: ShapeDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.80),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
child: Assets.vec.trashSvg.svg(
|
||||
width: 8.w,
|
||||
height: 8.h,
|
||||
colorFilter: ColorFilter.mode(
|
||||
AppColor.redNormal,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}, controller.pickedImages),
|
||||
|
||||
SizedBox(height: 35.h),
|
||||
Text(
|
||||
'حداقل ۲ تصویر برای ثبت بازرسی لازم است',
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
SizedBox(height: 8.h),
|
||||
Row(
|
||||
spacing: 16,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Obx(() {
|
||||
return RElevated(
|
||||
height: 40.h,
|
||||
text: 'ارسال',
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
progress: controller.presentUpload.value,
|
||||
isLoading: controller.isOnUpload.value,
|
||||
enabled: controller.pickedImages.length >= 2,
|
||||
onPressed: () async {
|
||||
controller.submitInspectionReport(id: id);
|
||||
},
|
||||
);
|
||||
}),
|
||||
ObxValue((data) {
|
||||
return RElevated(
|
||||
height: 40.h,
|
||||
text: 'انصراف',
|
||||
backgroundColor: AppColor.redNormal,
|
||||
enabled: !data.value,
|
||||
onPressed: () {
|
||||
if (!data.value) {
|
||||
controller.clearImages();
|
||||
Get.back();
|
||||
}
|
||||
},
|
||||
);
|
||||
}, controller.isOnUpload),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
).whenComplete(() {
|
||||
controller.pickedImages.clear();
|
||||
});
|
||||
}
|
||||
|
||||
Padding segmentWidget() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: RSegment(
|
||||
children: ['بازرسی', 'بایگانی'],
|
||||
selectedIndex: 0,
|
||||
borderColor: const Color(0xFFB4B4B4),
|
||||
selectedBorderColor: AppColor.blueNormal,
|
||||
selectedBackgroundColor: AppColor.blueLight,
|
||||
onSegmentSelected: (index) => controller.selectedSegmentIndex.value = index,
|
||||
backgroundColor: AppColor.whiteGreyNormal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget reportWidget() {
|
||||
return Expanded(
|
||||
child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
hasMore: data.value.data?.next != null,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: itemListWidgetReport(item),
|
||||
secondChild: itemListExpandedWidgetReport(item),
|
||||
labelColor: item.state == 'rejected' ? AppColor.redLight : AppColor.greenLight,
|
||||
labelIcon: Assets.vec.cubeSearchSvg.path,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async => controller.getHatchingReport(true),
|
||||
);
|
||||
}, controller.hatchingReportList),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemListExpandedWidgetReport(HatchingReport item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.hatching?.poultry?.user?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
|
||||
Visibility(
|
||||
child: Text(
|
||||
item.hatching?.violation == true ? 'پیگیری' : 'عادی',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan10.copyWith(color: AppColor.redDark),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text('نژاد:', style: AppFonts.yekan14.copyWith(color: AppColor.textColor)),
|
||||
Text(
|
||||
item.hatching?.chickenBreed ?? 'N/A',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
' سن ${item.hatching?.chickenAge} (روزه)',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
' دوره جوجه ریزی:${item.hatching?.period}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
buildRow(title: 'شماره مجوز جوجه ریزی', value: item.hatching?.licenceNumber ?? 'N/A'),
|
||||
buildUnitRow(
|
||||
title: 'حجم جوجه ریزی',
|
||||
value: item.hatching?.quantity.separatedByCommaFa ?? 'N/A',
|
||||
|
||||
unit: '(قطعه)',
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'مانده در سالن',
|
||||
value: item.hatching?.leftOver.separatedByCommaFa ?? 'N/A',
|
||||
unit: '(قطعه)',
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'تلفات',
|
||||
value: item.hatching?.losses.separatedByCommaFa ?? 'N/A',
|
||||
unit: '(قطعه)',
|
||||
),
|
||||
buildRow(
|
||||
title: 'دامپزشک فارم',
|
||||
value:
|
||||
'${item.hatching?.vetFarm?.vetFarmFullName}(${item.hatching?.vetFarm?.vetFarmMobile})',
|
||||
),
|
||||
buildRow(
|
||||
title: 'شرح بازرسی',
|
||||
value: controller.getStatus(item),
|
||||
titleStyle: AppFonts.yekan14.copyWith(color: controller.getStatusColor(item)),
|
||||
valueStyle: AppFonts.yekan14.copyWith(color: controller.getStatusColor(item)),
|
||||
),
|
||||
|
||||
if (item.state == 'accepted') ...{
|
||||
Visibility(
|
||||
visible: item.realQuantityAi != null,
|
||||
child: buildRow(
|
||||
title: 'تعداد تاییده هوش مصنوعی',
|
||||
value: item.realQuantityAi.separatedByComma,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: item.realQuantity != null,
|
||||
child: buildRow(
|
||||
title: 'تعداد تاییده',
|
||||
value: item.realQuantity.separatedByComma,
|
||||
),
|
||||
),
|
||||
},
|
||||
|
||||
if (item.state == 'rejected') ...{
|
||||
Visibility(
|
||||
visible: item.messageAi != null,
|
||||
child: buildRow(title: 'پیام هوش مصنوعی', value: item.messageAi ?? '-'),
|
||||
),
|
||||
Visibility(
|
||||
visible: item.message != null,
|
||||
child: buildRow(title: 'پیام', value: item.message ?? '-'),
|
||||
),
|
||||
Visibility(
|
||||
visible: item.messageRegistererFullname != null,
|
||||
child: buildRow(
|
||||
title: 'ثبت کننده گزارش',
|
||||
value: item.messageRegistererFullname ?? '-',
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: item.messageRegistererMobile != null,
|
||||
child: buildRow(
|
||||
title: 'موبایل کننده گزارش',
|
||||
value: item.messageRegistererMobile ?? '-',
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: item.messageRegistererRole != null,
|
||||
child: buildRow(title: 'نقش کننده گزارش', value: item.messageRegistererRole ?? '-'),
|
||||
),
|
||||
},
|
||||
|
||||
SizedBox(
|
||||
height: 140.h,
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: item.image?.length ?? 0,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
),
|
||||
itemBuilder: (context, index) => Container(
|
||||
height: 100.h,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Image.network(
|
||||
item.image?[index] ?? '',
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Padding(
|
||||
padding: EdgeInsetsGeometry.all(80),
|
||||
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColor.blueDark,
|
||||
value: loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded /
|
||||
(loadingProgress.expectedTotalBytes ?? 1)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8.r)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemListWidget(HatchingModel item) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(
|
||||
item.poultry?.user?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.poultry?.user?.mobile ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
spacing: 5,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
item.poultry?.unitName ?? 'N/Aaq',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.poultry?.licenceNumber ?? 'N/A',
|
||||
textAlign: TextAlign.left,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Row itemListWidgetReport(HatchingReport item) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(
|
||||
item.hatching?.poultry?.user?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.hatching?.poultry?.user?.mobile ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
spacing: 5,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
item.hatching?.poultry?.unitName ?? 'N/Aaq',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.hatching?.licenceNumber ?? 'N/A',
|
||||
textAlign: TextAlign.left,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget filterBottomSheet() {
|
||||
return BaseBottomSheet(
|
||||
height: 200,
|
||||
child: Column(
|
||||
spacing: 16,
|
||||
children: [
|
||||
Text('فیلترها', style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal)),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: dateFilterWidget(
|
||||
date: controller.fromDateFilter,
|
||||
onChanged: (jalali) => controller.fromDateFilter.value = jalali,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: dateFilterWidget(
|
||||
isFrom: false,
|
||||
date: controller.toDateFilter,
|
||||
onChanged: (jalali) => controller.toDateFilter.value = jalali,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
RElevated(
|
||||
text: 'اعمال فیلتر',
|
||||
isFullWidth: true,
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
onPressed: () {
|
||||
final isReporter = controller.selectedSegmentIndex.value == 0;
|
||||
if (isReporter) {
|
||||
controller.getHatchingReport();
|
||||
} else {
|
||||
controller.getHatchingList();
|
||||
}
|
||||
Get.back();
|
||||
},
|
||||
height: 40,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/poultry_export/poultry_export.dart';
|
||||
import 'package:rasadyar_chicken/data/models/request/kill_registration/kill_registration.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/all_poultry/all_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/approved_price/approved_price.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_house_poultry/kill_house_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_request_poultry/kill_request_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_hatching/poultry_hatching.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/sell_for_freezing/sell_for_freezing.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/genocide/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class KillingRegistrationLogic extends GetxController {
|
||||
List<String> routes = ['اقدام', 'درخواست کشتارها', 'ثبت کشتار'];
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
var gService = Get.find<GService>();
|
||||
var rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
|
||||
Rxn<ApprovedPrice> approvedPrice = Rxn<ApprovedPrice>();
|
||||
Rx<Jalali> killsDate = Jalali.now().obs;
|
||||
|
||||
Rxn<SellForFreezing> sellForFreezing = Rxn<SellForFreezing>();
|
||||
Rxn<PoultryExport> poultryExport = Rxn<PoultryExport>();
|
||||
|
||||
TextEditingController quantityKillsController = TextEditingController();
|
||||
RxBool quantityKillsIsCompleted = false.obs;
|
||||
TextEditingController quantityLoseController = TextEditingController(
|
||||
text: 0.toString(),
|
||||
);
|
||||
TextEditingController averageWeightKillsController = TextEditingController();
|
||||
RxBool averageWeightKillsIsCompleted = false.obs;
|
||||
TextEditingController priceFreeSaleController = TextEditingController();
|
||||
|
||||
RxInt generatedApprovedPrice = 0.obs;
|
||||
RxBool isOnSubmitLoading = false.obs;
|
||||
|
||||
RxBool isExportSelected = false.obs;
|
||||
RxBool isFreezedSelected = false.obs;
|
||||
RxBool isMarketSelected = false.obs;
|
||||
RxBool isFreeSale = false.obs;
|
||||
|
||||
//step 1
|
||||
Rx<Resource<List<AllPoultry>>> allPoultryList =
|
||||
Resource<List<AllPoultry>>.loading().obs;
|
||||
Rxn<AllPoultry> selectedPoultry = Rxn();
|
||||
|
||||
//step 2
|
||||
Rx<Resource<List<KillRequestPoultry>>> poultryList =
|
||||
Resource<List<KillRequestPoultry>>.success([]).obs;
|
||||
Rxn<KillRequestPoultry> selectedKillRequestPoultry = Rxn();
|
||||
|
||||
//step 3
|
||||
Rx<Resource<List<PoultryHatching>>> poultryHatchingList =
|
||||
Resource<List<PoultryHatching>>.success([]).obs;
|
||||
Rxn<PoultryHatching> selectedPoultryHatching = Rxn();
|
||||
|
||||
//step 5
|
||||
Rx<Resource<List<KillHousePoultry>>> killHouseList =
|
||||
Resource<List<KillHousePoultry>>.success([]).obs;
|
||||
Rxn<KillHousePoultry> selectedKillHouse = Rxn();
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
|
||||
getApprovedPrice();
|
||||
|
||||
getAllPoultryList();
|
||||
|
||||
getSellForFreezing();
|
||||
|
||||
getPoultryExport();
|
||||
|
||||
priceListener();
|
||||
|
||||
ever(selectedKillRequestPoultry, (callback) {
|
||||
if (callback?.provinceAllowChooseKillHouse?.allowState ?? false) {
|
||||
getKillHouseList();
|
||||
}
|
||||
});
|
||||
|
||||
everAll(
|
||||
[
|
||||
selectedPoultry,
|
||||
selectedKillRequestPoultry,
|
||||
selectedPoultryHatching,
|
||||
selectedKillHouse,
|
||||
],
|
||||
(callback) {
|
||||
checkSubmitButton();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
quantityKillsController.dispose();
|
||||
quantityLoseController.dispose();
|
||||
averageWeightKillsController.dispose();
|
||||
priceFreeSaleController.dispose();
|
||||
clearSelectedStep1();
|
||||
clearSelectedStep2();
|
||||
selectedKillHouse.value = null;
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.success([]);
|
||||
}
|
||||
|
||||
void priceListener() {
|
||||
quantityKillsController.addListener(() {
|
||||
quantityKillsIsCompleted.value = quantityKillsController.text
|
||||
.trim()
|
||||
.isNotEmpty;
|
||||
|
||||
if (averageWeightKillsController.text.isNotEmpty &&
|
||||
quantityKillsController.text.trim().isNotEmpty) {
|
||||
generatedApprovedPrice.value = calculateApprovedPrice().toInt();
|
||||
priceFreeSaleController.text =
|
||||
generatedApprovedPrice.value.separatedByComma;
|
||||
|
||||
checkSubmitButton();
|
||||
} else {
|
||||
generatedApprovedPrice.value = 0;
|
||||
priceFreeSaleController.text = '0';
|
||||
checkSubmitButton();
|
||||
}
|
||||
});
|
||||
|
||||
averageWeightKillsController.addListener(() {
|
||||
averageWeightKillsIsCompleted.value = averageWeightKillsController.text
|
||||
.trim()
|
||||
.isNotEmpty;
|
||||
|
||||
if (averageWeightKillsController.text.trim().isNotEmpty &&
|
||||
quantityKillsController.text.trim().isNotEmpty) {
|
||||
generatedApprovedPrice.value = calculateApprovedPrice().toInt();
|
||||
priceFreeSaleController.text =
|
||||
generatedApprovedPrice.value.separatedByComma;
|
||||
checkSubmitButton();
|
||||
} else {
|
||||
generatedApprovedPrice.value = 0;
|
||||
priceFreeSaleController.text = '0';
|
||||
checkSubmitButton();
|
||||
}
|
||||
});
|
||||
|
||||
priceFreeSaleController.addListener(() {
|
||||
final text = priceFreeSaleController.text;
|
||||
if (text.isNotEmpty) {
|
||||
generatedApprovedPrice.value = int.parse(text.replaceAll(',', ''));
|
||||
} else {
|
||||
generatedApprovedPrice.value = 0;
|
||||
}
|
||||
checkSubmitButton();
|
||||
});
|
||||
}
|
||||
|
||||
void clearSelectedStep1() {
|
||||
selectedPoultry.value = null;
|
||||
selectedKillRequestPoultry.value = null;
|
||||
selectedPoultryHatching.value = null;
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.success([]);
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.success([]);
|
||||
}
|
||||
|
||||
void clearSelectedStep2() {
|
||||
selectedKillRequestPoultry.value = null;
|
||||
selectedPoultryHatching.value = null;
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.success([]);
|
||||
}
|
||||
|
||||
Future<void> getApprovedPrice() async {
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getApprovedPrice(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
approvedPrice.value = result;
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getAllPoultryList() async {
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getAllPoultry(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
queryParameters: buildRawQueryParams(
|
||||
role: gService.getRole(Module.chicken),
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
allPoultryList.value = Resource<List<AllPoultry>>.success(result);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
allPoultryList.value = Resource<List<AllPoultry>>.error(
|
||||
'$error -- $stackTrace',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getSellForFreezing() async {
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getSellForFreezing(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
sellForFreezing.value = result;
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getPoultryExport() async {
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getPoultryExport(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
poultryExport.value = result;
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getUserPoultryList() async {
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.loading();
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getUserPoultry(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
queryParameters: buildQueryParams(
|
||||
value: selectedPoultry.value?.user?.mobile,
|
||||
queryParams: {'type': 'filter'},
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.success(
|
||||
result,
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.error(
|
||||
'$error -- $stackTrace',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getPoultryHatchingList() async {
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.loading();
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getPoultryHatching(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
queryParameters: buildRawQueryParams(
|
||||
queryParams: {'key': selectedKillRequestPoultry.value?.key},
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.success(
|
||||
result,
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.error(
|
||||
'$error -- $stackTrace',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getKillHouseList() async {
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.loading();
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getKillHouseList(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
queryParameters: buildRawQueryParams(
|
||||
queryParams: {
|
||||
'show_poultry': '',
|
||||
'date': DateTime.now().formattedDashedGregorian,
|
||||
},
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.success(
|
||||
result,
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.error(
|
||||
'$error -- $stackTrace',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
double calculateApprovedPrice() {
|
||||
final inputWeight = double.parse(averageWeightKillsController.text) * 1000;
|
||||
final lowestWeight = approvedPrice.value?.lowestWeight ?? 0;
|
||||
final highestWeight = approvedPrice.value?.highestWeight ?? 0;
|
||||
final lowestPrice = approvedPrice.value?.lowestPrice ?? 0;
|
||||
final highestPrice = approvedPrice.value?.highestPrice ?? 0;
|
||||
|
||||
if (inputWeight <= lowestWeight) {
|
||||
return lowestPrice;
|
||||
} else if (inputWeight >= highestWeight) {
|
||||
return highestPrice;
|
||||
} else {
|
||||
final diffWeight = highestWeight - lowestWeight;
|
||||
final diffPrice = highestPrice - lowestPrice;
|
||||
final fraction = diffPrice / diffWeight;
|
||||
final diffFromMinWeight = inputWeight - lowestWeight;
|
||||
return diffFromMinWeight * fraction + lowestPrice;
|
||||
}
|
||||
}
|
||||
|
||||
void changeSaleType() {
|
||||
isFreeSale.value = !isFreeSale.value;
|
||||
generatedApprovedPrice.value = calculateApprovedPrice().toInt();
|
||||
}
|
||||
|
||||
void checkSubmitButton() {
|
||||
isOnSubmitLoading.value =
|
||||
selectedPoultry.value != null &&
|
||||
selectedKillRequestPoultry.value != null &&
|
||||
selectedPoultryHatching.value != null &&
|
||||
quantityKillsController.text.isNotEmpty &&
|
||||
averageWeightKillsController.text.isNotEmpty &&
|
||||
((selectedKillRequestPoultry
|
||||
.value
|
||||
?.provinceAllowChooseKillHouse
|
||||
?.mandatory ??
|
||||
false)
|
||||
? selectedKillHouse.value != null
|
||||
: true);
|
||||
}
|
||||
|
||||
Future<void> submitKillRegistration() async {
|
||||
isOnSubmitLoading.value = false;
|
||||
if (!formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
dLog(double.parse(averageWeightKillsController.text));
|
||||
KillRegistrationRequest registrationRequest = KillRegistrationRequest(
|
||||
indexWeight: double.parse(averageWeightKillsController.text),
|
||||
amount: generatedApprovedPrice.value,
|
||||
approvedPrice: approvedPrice.value?.approved ?? false,
|
||||
auctionList: [],
|
||||
cash: true,
|
||||
chickenBreed: selectedPoultryHatching.value?.chickenBreed,
|
||||
confirmPoultryMobile: selectedPoultry.value?.user?.mobile,
|
||||
credit: false,
|
||||
export: isExportSelected.value,
|
||||
financialOperation: "outside-system",
|
||||
freeSaleInProvince: isMarketSelected.value,
|
||||
freezing: isFreezedSelected.value,
|
||||
killHouseList: [
|
||||
if (selectedKillHouse.value != null)
|
||||
'${selectedKillHouse.value?.name}(${selectedKillHouse.value?.fullname})',
|
||||
],
|
||||
killReqKey: selectedKillHouse.value?.killReqKey,
|
||||
losses: quantityLoseController.text,
|
||||
market: isMarketSelected.value,
|
||||
operatorKey: "",
|
||||
poultryHatchingKey: selectedPoultryHatching.value?.key,
|
||||
poultryKey: selectedPoultry.value?.key,
|
||||
quantity: int.parse(quantityKillsController.text.clearComma),
|
||||
role: gService.getRole(Module.chicken),
|
||||
sendDate: killsDate.value.toDateTime().formattedDashedGregorian,
|
||||
);
|
||||
|
||||
await safeCall(
|
||||
call: () async =>
|
||||
await rootLogic.poultryRepository.submitKillRegistration(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
request: registrationRequest,
|
||||
),
|
||||
onSuccess: (result) async {
|
||||
defaultShowSuccessMessage(
|
||||
'ثبت با موفقیت انجام شد',
|
||||
durationInSeconds: 2,
|
||||
onDismissed: () async {
|
||||
Get.find<GenocideLogic>().getPoultryOrderList();
|
||||
Future.delayed(Duration(milliseconds: 300), () {
|
||||
Get.back();
|
||||
});
|
||||
Get.find<GenocideLogic>().getPoultryOrderList();
|
||||
},
|
||||
);
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
void clearAllFields() {
|
||||
// ریست فرم
|
||||
formKey.currentState?.reset();
|
||||
|
||||
// ریست Rxn ها
|
||||
approvedPrice.value = null;
|
||||
sellForFreezing.value = null;
|
||||
poultryExport.value = null;
|
||||
selectedPoultry.value = null;
|
||||
selectedKillRequestPoultry.value = null;
|
||||
selectedPoultryHatching.value = null;
|
||||
selectedKillHouse.value = null;
|
||||
|
||||
// ریست Rx ها
|
||||
killsDate.value = Jalali.now();
|
||||
generatedApprovedPrice.value = 0;
|
||||
isOnSubmitLoading.value = false;
|
||||
isExportSelected.value = false;
|
||||
isFreezedSelected.value = false;
|
||||
isMarketSelected.value = false;
|
||||
isFreeSale.value = false;
|
||||
|
||||
// ریست TextEditingController ها
|
||||
quantityKillsController.clear();
|
||||
quantityLoseController.text = '0';
|
||||
averageWeightKillsController.clear();
|
||||
priceFreeSaleController.clear();
|
||||
|
||||
// ریست RxBool ها
|
||||
quantityKillsIsCompleted.value = false;
|
||||
averageWeightKillsIsCompleted.value = false;
|
||||
|
||||
// ریست Resource لیستها
|
||||
allPoultryList.value = Resource<List<AllPoultry>>.loading();
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.success([]);
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.success([]);
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.success([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,587 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/all_poultry/all_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_house_poultry/kill_house_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_request_poultry/kill_request_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_hatching/poultry_hatching.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class KillingRegistrationPage extends GetView<KillingRegistrationLogic> {
|
||||
const KillingRegistrationPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Form(
|
||||
key: controller.formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
poultryFarmWidget(),
|
||||
poultryUserListWidget(),
|
||||
poultryHatchingWidget(),
|
||||
ObxValue((data) {
|
||||
return Visibility(
|
||||
visible: controller.selectedPoultryHatching.value != null,
|
||||
child: Column(
|
||||
children: [
|
||||
informationWidget(),
|
||||
killDateWidget(
|
||||
date: controller.killsDate,
|
||||
onChanged: (Jalali jalali) {
|
||||
controller.killsDate.value = jalali;
|
||||
},
|
||||
),
|
||||
quantityKillsWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.selectedPoultryHatching),
|
||||
ObxValue((data) {
|
||||
return Visibility(
|
||||
visible: data.value,
|
||||
child: Column(children: [averageWeightKillsWidget()]),
|
||||
);
|
||||
}, controller.quantityKillsIsCompleted),
|
||||
|
||||
ObxValue((data) {
|
||||
return Visibility(
|
||||
visible: data.value,
|
||||
child: Column(
|
||||
children: [
|
||||
saleTypeWidget(),
|
||||
priceWidget(),
|
||||
buyerListWidget(),
|
||||
slaughterhouseSelectedWidget(),
|
||||
submitButtonWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.averageWeightKillsIsCompleted),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget poultryFarmWidget() {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 10.h),
|
||||
child: ObxValue((data) {
|
||||
return ResourceOverlayDropdown<AllPoultry>(
|
||||
items: data.value,
|
||||
background: Colors.white,
|
||||
onChanged: (value) {
|
||||
controller.clearSelectedStep1();
|
||||
controller.selectedPoultry.value = value;
|
||||
controller.getUserPoultryList();
|
||||
},
|
||||
selectedItem: controller.selectedPoultry.value,
|
||||
itemBuilder: (item) => labelPoultryWidget(item),
|
||||
labelBuilder: (item) => labelPoultryWidget(item),
|
||||
);
|
||||
}, controller.allPoultryList),
|
||||
);
|
||||
}
|
||||
|
||||
Widget labelPoultryWidget(AllPoultry? item) {
|
||||
if (item == null) {
|
||||
return Row(
|
||||
children: [
|
||||
Assets.vec.farmSvg.svg(
|
||||
width: 28.w,
|
||||
height: 28.h,
|
||||
colorFilter: const ColorFilter.mode(AppColor.darkGreyDark, BlendMode.srcIn),
|
||||
),
|
||||
SizedBox(width: 4.w),
|
||||
Text('انتخاب مرغداری', style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark)),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Text('${item.unitName} (${item.address?.city?.name})', maxLines: 2);
|
||||
}
|
||||
}
|
||||
|
||||
Widget poultryUserListWidget() {
|
||||
return ObxValue((data) {
|
||||
if (data.value == null) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w),
|
||||
child: ObxValue((data) {
|
||||
return ResourceOverlayDropdown<KillRequestPoultry>(
|
||||
items: data.value,
|
||||
background: Colors.white,
|
||||
onChanged: (value) {
|
||||
controller.clearSelectedStep2();
|
||||
controller.selectedKillRequestPoultry.value = value;
|
||||
controller.getPoultryHatchingList();
|
||||
},
|
||||
selectedItem: controller.selectedKillRequestPoultry.value,
|
||||
itemBuilder: (item) => labelPoultryUser(item),
|
||||
labelBuilder: (item) => labelPoultryUser(item),
|
||||
);
|
||||
}, controller.poultryList),
|
||||
);
|
||||
}, controller.selectedPoultry);
|
||||
}
|
||||
|
||||
Widget labelPoultryUser(KillRequestPoultry? item) {
|
||||
if (item == null) {
|
||||
return Row(
|
||||
children: [
|
||||
Assets.vec.chickenHouseSvg.svg(
|
||||
width: 28.w,
|
||||
height: 28.h,
|
||||
colorFilter: const ColorFilter.mode(AppColor.darkGreyDark, BlendMode.srcIn),
|
||||
),
|
||||
SizedBox(width: 6.w),
|
||||
Text('محل پرورش', style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark)),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Text(item.unitName ?? '-');
|
||||
}
|
||||
}
|
||||
|
||||
Widget poultryHatchingWidget() {
|
||||
return ObxValue((data) {
|
||||
if (data.value == null) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 10.h),
|
||||
child: ObxValue((data) {
|
||||
return ResourceOverlayDropdown<PoultryHatching>(
|
||||
items: data.value,
|
||||
background: Colors.white,
|
||||
onChanged: (value) {
|
||||
controller.selectedPoultryHatching.value = value;
|
||||
},
|
||||
selectedItem: controller.selectedPoultryHatching.value,
|
||||
itemBuilder: (item) => labelPoultryHatching(item),
|
||||
labelBuilder: (item) => labelPoultryHatching(item),
|
||||
);
|
||||
}, controller.poultryHatchingList),
|
||||
);
|
||||
}, controller.selectedKillRequestPoultry);
|
||||
}
|
||||
|
||||
Widget labelPoultryHatching(PoultryHatching? item) {
|
||||
if (item == null) {
|
||||
return Row(
|
||||
children: [
|
||||
Assets.vec.calendarSvg.svg(
|
||||
width: 28.w,
|
||||
height: 28.h,
|
||||
colorFilter: const ColorFilter.mode(AppColor.darkGreyDark, BlendMode.srcIn),
|
||||
),
|
||||
SizedBox(width: 6.w),
|
||||
Text('دوره جوجه ریزی', style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark)),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
' دوره ${item.period} سالن ${item.hall} نژاد ${item.chickenBreed} باقیمانده ${item.leftOver} قطعه ',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget informationWidget() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
margin: EdgeInsets.fromLTRB(8.w, 0, 8.w, 10.h),
|
||||
padding: EdgeInsets.all(7),
|
||||
child: ObxValue(
|
||||
(data) => Column(
|
||||
spacing: 8,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text(
|
||||
'اطلاعات مرغداری',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
decoration: ShapeDecoration(
|
||||
color: const Color(0xFFEAEFFF),
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: const Color(0xFFE0E7FF)),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(4),
|
||||
child: buildUnitRow(
|
||||
title: 'تعداد جوجه ریزی',
|
||||
value: data.value?.quantity.separatedByCommaFa,
|
||||
unit: 'قطعه',
|
||||
),
|
||||
),
|
||||
|
||||
buildUnitRow(
|
||||
title: 'تلفات',
|
||||
value: data.value?.losses.separatedByCommaFa,
|
||||
unit: 'قطعه',
|
||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 4),
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'باقیمانده',
|
||||
value: data.value?.leftOver.separatedByCommaFa,
|
||||
unit: 'قطعه',
|
||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 4),
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'سن جوجه',
|
||||
value: data.value?.chickenAge.separatedByCommaFa,
|
||||
unit: 'روز',
|
||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 4),
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'مجوز فروش آزاد',
|
||||
value:
|
||||
data.value?.freeGovernmentalInfo?.totalFreeCommitmentQuantity.separatedByCommaFa,
|
||||
unit: 'قطعه',
|
||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 4),
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'مانده فروش آزاد',
|
||||
value: data
|
||||
.value
|
||||
?.freeGovernmentalInfo
|
||||
?.leftTotalFreeCommitmentQuantity
|
||||
.separatedByCommaFa,
|
||||
unit: 'قطعه',
|
||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 4),
|
||||
),
|
||||
buildUnitRow(
|
||||
title: 'تلفن مرغدار',
|
||||
value: data.value?.poultry?.userprofile?.mobile,
|
||||
unit: '',
|
||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
controller.selectedPoultryHatching,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget killDateWidget({required Rx<Jalali> date, required Function(Jalali jalali) onChanged}) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Get.bottomSheet(modalDatePicker(onDateSelected: (value) => onChanged(value)));
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
margin: EdgeInsets.symmetric(horizontal: 8.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(width: 1, color: AppColor.darkGreyLight),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 11, vertical: 4),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Assets.vec.calendarSvg.svg(
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: const ColorFilter.mode(AppColor.bgDark, BlendMode.srcIn),
|
||||
),
|
||||
Text('تاریخ کشتار', style: AppFonts.yekan14.copyWith(color: AppColor.bgDark)),
|
||||
Spacer(),
|
||||
ObxValue((data) {
|
||||
return Text(
|
||||
date.value.formatCompactDate(),
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark),
|
||||
);
|
||||
}, date),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget quantityKillsWidget() {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 10.h),
|
||||
child: RTextField(
|
||||
label: 'تعداد کشتار (قطعه)',
|
||||
filled: true,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'تعداد کشتار را وارد کنید';
|
||||
}
|
||||
final count = double.tryParse(value.replaceAll(',', ''));
|
||||
if (controller.isFreeSale.value) {
|
||||
if (count! >
|
||||
(controller
|
||||
.selectedPoultryHatching
|
||||
.value
|
||||
?.freeGovernmentalInfo
|
||||
?.leftTotalFreeCommitmentQuantity ??
|
||||
0)) {
|
||||
return 'مجوز فروش آزاد شما کافی نیست';
|
||||
}
|
||||
} else {
|
||||
if (count! > (controller.selectedPoultryHatching.value?.leftOver ?? 0)) {
|
||||
return 'تعداد کشتار نباید بیشتر از باقیمانده جوجه ریزی باشد';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
textInputAction: TextInputAction.next,
|
||||
filledColor: Colors.white,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
|
||||
controller: controller.quantityKillsController,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget averageWeightKillsWidget() {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w),
|
||||
child: RTextField(
|
||||
label: 'میانگین وزن (کیلوگرم)',
|
||||
filled: true,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'میانگین وزن را وارد کنید';
|
||||
}
|
||||
final weight = double.tryParse(value.replaceAll(',', ''));
|
||||
if (weight == null || weight <= 0) {
|
||||
return 'میانگین وزن باید عددی بزرگتر از صفر باشد';
|
||||
} else if (weight >
|
||||
(controller.selectedPoultryHatching.value?.managementHatchingAgeRange?.toWeight ??
|
||||
10000) ||
|
||||
weight <
|
||||
(controller
|
||||
.selectedPoultryHatching
|
||||
.value
|
||||
?.managementHatchingAgeRange
|
||||
?.fromWeight ??
|
||||
-10000)) {
|
||||
return 'میانگین وزن باید بین ${controller.selectedPoultryHatching.value?.managementHatchingAgeRange?.fromWeight} تا ${controller.selectedPoultryHatching.value?.managementHatchingAgeRange?.toWeight} کیلوگرم باشد';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
filledColor: Colors.white,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FirstDigitDecimalFormatter()],
|
||||
controller: controller.averageWeightKillsController,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget saleTypeWidget() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
margin: EdgeInsets.symmetric(horizontal: 8.w, vertical: 10.h),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 4.h),
|
||||
child: ObxValue((data) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
'نوع فروش',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
RadioGroup(
|
||||
groupValue: data.value ? 1 : 0,
|
||||
onChanged: (value) {
|
||||
controller.changeSaleType();
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Radio(value: 0, activeColor: AppColor.blueNormal),
|
||||
Text('دولتی', style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark)),
|
||||
Spacer(),
|
||||
Radio(value: 1, activeColor: AppColor.blueNormal),
|
||||
Text('آزاد', style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.isFreeSale),
|
||||
);
|
||||
}
|
||||
|
||||
Widget priceWidget() {
|
||||
return ObxValue((data) {
|
||||
if (!data.value) {
|
||||
return Container(
|
||||
height: 40.h,
|
||||
margin: EdgeInsets.symmetric(horizontal: 8.w),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.greenLight,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(width: 1.w, color: AppColor.whiteNormalHover),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 11.w, vertical: 4.h),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Text('قیمت مصوب', style: AppFonts.yekan14.copyWith(color: AppColor.textColor)),
|
||||
Spacer(),
|
||||
|
||||
ObxValue((data) {
|
||||
return Text(
|
||||
' ${data.value.separatedByCommaFa} ریال',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
);
|
||||
}, controller.generatedApprovedPrice),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: EdgeInsets.fromLTRB(8.w, 0, 8.w, 0),
|
||||
child: RTextField(
|
||||
label: 'قیمت پیشنهادی (ریال)',
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'قیمت پیشنهادی را وارد کنید';
|
||||
}
|
||||
final price = double.tryParse(value.replaceAll(',', ''));
|
||||
|
||||
if (price == null || price <= 0) {
|
||||
return 'قیمت پیشنهادی باید عددی بزرگتر از صفر باشد';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
filled: true,
|
||||
borderColor: AppColor.whiteNormalHover,
|
||||
filledColor: AppColor.accent1,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
|
||||
controller: controller.priceFreeSaleController,
|
||||
),
|
||||
);
|
||||
}
|
||||
}, controller.isFreeSale);
|
||||
}
|
||||
|
||||
Widget buyerListWidget() {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 8.w),
|
||||
child: ObxValue((data) {
|
||||
return Visibility(
|
||||
visible: data.value?.provinceAllowChooseKillHouse?.allowState ?? false,
|
||||
child: ObxValue((data) {
|
||||
return ResourceOverlayDropdown<KillHousePoultry>(
|
||||
items: data.value,
|
||||
background: Colors.white,
|
||||
onChanged: (value) {
|
||||
controller.selectedKillHouse.value = value;
|
||||
},
|
||||
selectedItem: controller.selectedKillHouse.value,
|
||||
itemBuilder: (item) => Text(buildKillHouseLabel(item)),
|
||||
labelBuilder: (item) => Text(buildKillHouseLabel(item)),
|
||||
);
|
||||
}, controller.killHouseList),
|
||||
);
|
||||
}, controller.selectedKillRequestPoultry),
|
||||
);
|
||||
}
|
||||
|
||||
String buildKillHouseLabel(KillHousePoultry? item) {
|
||||
if (item == null) {
|
||||
return 'خریدار/ظرفیت باقیمانده';
|
||||
} else {
|
||||
return '${item.name} / ${item.quantitySum} قطعه ';
|
||||
}
|
||||
}
|
||||
|
||||
Widget slaughterhouseSelectedWidget() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
margin: EdgeInsets.symmetric(horizontal: 8.w),
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 8.h),
|
||||
Text('عملیات کشتار', style: AppFonts.yekan14Bold.copyWith(color: AppColor.blueNormal)),
|
||||
SizedBox(height: 8.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ObxValue((data) {
|
||||
return Visibility(
|
||||
visible: data.value?.permission ?? false,
|
||||
child: ObxValue(
|
||||
(data) => TitleCheckBox(
|
||||
title: ' انجماد',
|
||||
onChanged: (_) {
|
||||
controller.isFreezedSelected.value = !controller.isFreezedSelected.value;
|
||||
},
|
||||
isSelected: data.value,
|
||||
),
|
||||
controller.isFreezedSelected,
|
||||
),
|
||||
);
|
||||
}, controller.sellForFreezing),
|
||||
|
||||
ObxValue((data) {
|
||||
return TitleCheckBox(
|
||||
title: 'پنل معاملات',
|
||||
onChanged: (_) {
|
||||
controller.isMarketSelected.value = !controller.isMarketSelected.value;
|
||||
},
|
||||
isSelected: data.value,
|
||||
);
|
||||
}, controller.isMarketSelected),
|
||||
|
||||
ObxValue((data) {
|
||||
return Visibility(
|
||||
visible: data.value?.allow ?? false,
|
||||
child: ObxValue((data) {
|
||||
return TitleCheckBox(
|
||||
title: 'صادرات',
|
||||
isSelected: data.value,
|
||||
onChanged: (_) {
|
||||
controller.isExportSelected.value = !controller.isExportSelected.value;
|
||||
},
|
||||
);
|
||||
}, controller.isExportSelected),
|
||||
);
|
||||
}, controller.poultryExport),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.h),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget submitButtonWidget() {
|
||||
return ObxValue((data) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 12.h),
|
||||
child: RElevated(
|
||||
enabled: data.value,
|
||||
height: 45.h,
|
||||
isFullWidth: true,
|
||||
disabledBackgroundColor: AppColor.greenDarkHover,
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
textStyle: AppFonts.yekan16Bold.copyWith(color: Colors.white),
|
||||
onPressed: () {
|
||||
controller.submitKillRegistration();
|
||||
},
|
||||
text: 'ثبت کشتار',
|
||||
),
|
||||
);
|
||||
}, controller.isOnSubmitLoading);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class PoultryActionItem {
|
||||
final String title;
|
||||
final String route;
|
||||
final String icon;
|
||||
|
||||
PoultryActionItem({
|
||||
required this.title,
|
||||
required this.route,
|
||||
required this.icon,
|
||||
});
|
||||
}
|
||||
|
||||
class PoultryActionLogic extends GetxController {
|
||||
RxList<PoultryActionItem> items = [
|
||||
PoultryActionItem(
|
||||
title: "بازرسی",
|
||||
route: PoultryScienceRoutes.inspectionPoultryScience,
|
||||
icon: Assets.vec.chickenInspectionSvg.path,
|
||||
),
|
||||
PoultryActionItem(
|
||||
title: "ثبت کشتار",
|
||||
route: PoultryScienceRoutes.genocidePoultryScience,
|
||||
icon: Assets.vec.registerKillSvg.path,
|
||||
),
|
||||
PoultryActionItem(
|
||||
title: "فارم ها",
|
||||
route: PoultryScienceRoutes.farmPoultryScience,
|
||||
icon: Assets.vec.farmsSvg.path,
|
||||
),
|
||||
PoultryActionItem(
|
||||
title: "جوجه ریزی فعال",
|
||||
route: PoultryScienceRoutes.activeHatchingPoultryScience,
|
||||
icon: Assets.vec.activeFramSvg.path,
|
||||
),
|
||||
|
||||
PoultryActionItem(
|
||||
title: "بازرسی مزارع طیور",
|
||||
route: ChickenRoutes.poultryFarmInspectionHome,
|
||||
icon: Assets.vec.activeFramSvg.path,
|
||||
),
|
||||
].obs;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.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 'logic.dart';
|
||||
|
||||
class PoultryActionPage extends GetView<PoultryActionLogic> {
|
||||
PoultryActionPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(isBase: true, hasNews: true, hasNotification: true, child: gridWidget());
|
||||
}
|
||||
|
||||
Widget gridWidget() {
|
||||
return ObxValue((data) {
|
||||
return GridView.builder(
|
||||
physics: BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.symmetric(vertical: 18.h, horizontal: 32.w),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 24.h,
|
||||
crossAxisSpacing: 24.w,
|
||||
),
|
||||
itemCount: data.length,
|
||||
hitTestBehavior: HitTestBehavior.opaque,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var item = data[index];
|
||||
return GlassMorphismCardIcon(
|
||||
title: item.title,
|
||||
vecIcon: item.icon,
|
||||
onTap: () async {
|
||||
Get.toNamed(item.route, id: poultryFirstKey);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}, controller.items);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||
import 'package:rasadyar_chicken/data/repositories/poultry_science/poultry_science_repository.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/home/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/common/profile/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/routes/routes.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 PoultryScienceRootLogic extends GetxController {
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
|
||||
late PoultryScienceRepository poultryRepository;
|
||||
|
||||
RxList<ErrorLocationType> errorLocationType = RxList();
|
||||
RxMap<int, dynamic> homeExpandedList = RxMap();
|
||||
DateTime? _lastBackPressed;
|
||||
|
||||
RxInt currentPage = 1.obs;
|
||||
|
||||
final pages = [
|
||||
Navigator(
|
||||
key: Get.nestedKey(poultryFirstKey),
|
||||
onGenerateRoute: (settings) {
|
||||
final page = ChickenPages.pages.firstWhere(
|
||||
(e) => e.name == settings.name,
|
||||
orElse: () => ChickenPages.pages.firstWhere(
|
||||
(e) => e.name == PoultryScienceRoutes.actionPoultryScience,
|
||||
),
|
||||
);
|
||||
|
||||
return buildRouteFromGetPage(page);
|
||||
},
|
||||
),
|
||||
PoultryScienceHomePage(),
|
||||
ProfilePage(),
|
||||
];
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
poultryRepository = diChicken.get<PoultryScienceRepository>();
|
||||
}
|
||||
|
||||
void toggleExpanded(int index) {
|
||||
if (homeExpandedList.keys.contains(index)) {
|
||||
homeExpandedList.remove(index);
|
||||
} else {
|
||||
homeExpandedList[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void rootErrorHandler(DioException error) {
|
||||
handleGeneric(error, () {
|
||||
tokenService.deleteModuleTokens(Module.chicken);
|
||||
});
|
||||
}
|
||||
|
||||
void changePage(int index) {
|
||||
currentPage.value = index;
|
||||
}
|
||||
|
||||
int getNestedKey() {
|
||||
switch (currentPage.value) {
|
||||
case 0:
|
||||
return poultryFirstKey;
|
||||
case 1:
|
||||
return poultrySecondKey;
|
||||
case 2:
|
||||
return poultryThirdKey;
|
||||
default:
|
||||
return poultryFirstKey;
|
||||
}
|
||||
}
|
||||
|
||||
void popBackTaped() async {
|
||||
final nestedKeyId = getNestedKey();
|
||||
GlobalKey<NavigatorState>? currentNestedKey = Get.nestedKey(nestedKeyId);
|
||||
|
||||
if (currentNestedKey?.currentState?.canPop() == true) {
|
||||
Get.back(id: nestedKeyId);
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import 'package:flutter/material.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 'logic.dart';
|
||||
|
||||
class PoultryScienceRootPage extends GetView<PoultryScienceRootLogic> {
|
||||
const PoultryScienceRootPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
isFullScreen: true,
|
||||
onPopScopTaped: controller.popBackTaped,
|
||||
child: ObxValue((data) {
|
||||
return Stack(
|
||||
children: [
|
||||
IndexedStack(children: controller.pages, index: data.value),
|
||||
Positioned(
|
||||
right: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
child: RBottomNavigation(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
items: [
|
||||
RBottomNavigationItem(
|
||||
label: 'عملیات',
|
||||
icon: Assets.vec.settingSvg.path,
|
||||
isSelected: controller.currentPage.value == 0,
|
||||
onTap: () {
|
||||
Get.nestedKey(
|
||||
poultrySecondKey,
|
||||
)?.currentState?.popUntil((route) => route.isFirst);
|
||||
Get.nestedKey(
|
||||
poultryFirstKey,
|
||||
)?.currentState?.popUntil((route) => route.isFirst);
|
||||
controller.changePage(0);
|
||||
},
|
||||
),
|
||||
RBottomNavigationItem(
|
||||
label: 'خانه',
|
||||
icon: Assets.vec.homeSvg.path,
|
||||
isSelected: controller.currentPage.value == 1,
|
||||
onTap: () {
|
||||
Get.nestedKey(
|
||||
poultryFirstKey,
|
||||
)?.currentState?.popUntil((route) => route.isFirst);
|
||||
Get.nestedKey(
|
||||
poultryThirdKey,
|
||||
)?.currentState?.popUntil((route) => route.isFirst);
|
||||
controller.changePage(1);
|
||||
},
|
||||
),
|
||||
RBottomNavigationItem(
|
||||
label: 'پروفایل',
|
||||
icon: Assets.vec.profileCircleSvg.path,
|
||||
isSelected: controller.currentPage.value == 2,
|
||||
onTap: () {
|
||||
Get.nestedKey(
|
||||
poultryFirstKey,
|
||||
)?.currentState?.popUntil((route) => route.isFirst);
|
||||
Get.nestedKey(
|
||||
poultrySecondKey,
|
||||
)?.currentState?.popUntil((route) => route.isFirst);
|
||||
controller.changePage(2);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.currentPage),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/active_hatching/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/active_hatching/view.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/farm/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/farm/view.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/genocide/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/genocide/view.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/home/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/inspection/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/inspection/view.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/killing_registration/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/killing_registration/view.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/poultry_action/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/poultry_action/view.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/view.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/global_binding.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class PoultrySciencePages {
|
||||
PoultrySciencePages._();
|
||||
|
||||
static List<GetPage> get pages => [
|
||||
GetPage(
|
||||
name: PoultryScienceRoutes.initPoultryScience,
|
||||
page: () => PoultryScienceRootPage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
bindings: [
|
||||
GlobalBinding(),
|
||||
BindingsBuilder(() {
|
||||
Get.lazyPut(() => PoultryScienceRootLogic());
|
||||
Get.lazyPut(() => PoultryScienceHomeLogic());
|
||||
Get.lazyPut(() => PoultryActionLogic());
|
||||
}),
|
||||
],
|
||||
),
|
||||
GetPage(
|
||||
name: PoultryScienceRoutes.inspectionPoultryScience,
|
||||
page: () => InspectionPoultrySciencePage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => InspectionPoultryScienceLogic());
|
||||
}),
|
||||
),
|
||||
GetPage(
|
||||
name: PoultryScienceRoutes.actionPoultryScience,
|
||||
page: () => PoultryActionPage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => PoultryActionLogic());
|
||||
}),
|
||||
),
|
||||
GetPage(
|
||||
name: PoultryScienceRoutes.farmPoultryScience,
|
||||
page: () => FarmPage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => FarmLogic());
|
||||
Get.lazyPut(() => PoultryScienceHomeLogic());
|
||||
Get.lazyPut(() => PoultryScienceRootLogic());
|
||||
}),
|
||||
),
|
||||
GetPage(
|
||||
name: PoultryScienceRoutes.activeHatchingPoultryScience,
|
||||
page: () => ActiveHatchingPage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => ActiveHatchingLogic());
|
||||
Get.lazyPut(() => PoultryScienceRootLogic());
|
||||
}),
|
||||
),
|
||||
GetPage(
|
||||
name: PoultryScienceRoutes.genocidePoultryScience,
|
||||
page: () => GenocidePage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => GenocideLogic());
|
||||
Get.lazyPut(() => PoultryScienceRootLogic());
|
||||
Get.lazyPut(() => KillingRegistrationLogic(), fenix: true);
|
||||
}),
|
||||
),
|
||||
GetPage(
|
||||
name: PoultryScienceRoutes.killingRegistrationPoultryScience,
|
||||
page: () => KillingRegistrationPage(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => KillingRegistrationLogic());
|
||||
Get.lazyPut(() => GenocideLogic());
|
||||
Get.lazyPut(() => PoultryScienceRootLogic());
|
||||
}),
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
sealed class PoultryScienceRoutes {
|
||||
PoultryScienceRoutes._();
|
||||
|
||||
static const _base = '/chicken/poultryScience';
|
||||
static const initPoultryScience = '$_base/';
|
||||
static const actionPoultryScience = '$_base/action';
|
||||
static const inspectionPoultryScience = '$_base/inspection';
|
||||
static const farmPoultryScience = '$_base/farm';
|
||||
static const activeHatchingPoultryScience = '$_base/activeHatching';
|
||||
static const genocidePoultryScience = '$_base/genocidePoultryScience';
|
||||
static const killingRegistrationPoultryScience =
|
||||
'$genocidePoultryScience/KillingRegistration';
|
||||
}
|
||||
Reference in New Issue
Block a user