fix : Active Hatching -> poultry science
This commit is contained in:
@@ -0,0 +1,68 @@
|
|||||||
|
import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart';
|
||||||
|
import 'package:rasadyar_chicken/presentation/pages/poultry_science/root/logic.dart';
|
||||||
|
import 'package:rasadyar_core/core.dart';
|
||||||
|
|
||||||
|
class ActiveHatchingLogic extends GetxController {
|
||||||
|
PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
|
||||||
|
|
||||||
|
Rx<Resource<PaginationModel<HatchingModel>>> activeHatchingList =
|
||||||
|
Resource<PaginationModel<HatchingModel>>.loading().obs;
|
||||||
|
|
||||||
|
final RxBool isLoadingMoreList = false.obs;
|
||||||
|
RxInt currentPage = 1.obs;
|
||||||
|
RxList<int> isExpandedList = <int>[].obs;
|
||||||
|
List<String> routesName = ['اقدام', 'جوجه ریزی فعال'];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onReady() {
|
||||||
|
super.onReady();
|
||||||
|
|
||||||
|
getHatchingList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
// TODO: implement onClose
|
||||||
|
super.onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ?? [])],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.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/pages/poultry_science/active_hatching/logic.dart';
|
||||||
|
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||||
|
import 'package:rasadyar_core/core.dart';
|
||||||
|
import 'package:rasadyar_core/presentation/widget/list_item/list_item2.dart';
|
||||||
|
import 'package:rasadyar_core/presentation/widget/list_view/r_paginated_list_view.dart';
|
||||||
|
|
||||||
|
class ActiveHatchingPage extends GetView<ActiveHatchingLogic> {
|
||||||
|
const ActiveHatchingPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BasePage(
|
||||||
|
hasSearch: false,
|
||||||
|
hasFilter: false,
|
||||||
|
routes: controller.routesName,
|
||||||
|
onBackPressed: () => Get.back(id: 0),
|
||||||
|
widgets: [
|
||||||
|
hatchingWidget()
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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.contains(index),
|
||||||
|
onTap: () => controller.isExpandedList.toggle(index),
|
||||||
|
index: index,
|
||||||
|
child: itemListWidget(item),
|
||||||
|
secondChild: itemListExpandedWidget(item),
|
||||||
|
labelColor: AppColor.blueLight,
|
||||||
|
labelIcon: Assets.vec.checkSquareSvg.path,
|
||||||
|
);
|
||||||
|
}, controller.isExpandedList);
|
||||||
|
},
|
||||||
|
itemCount: data.value.data?.results?.length ?? 0,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||||
|
onLoadMore: () async => controller.getHatchingList(true),
|
||||||
|
onRefresh: () async {
|
||||||
|
controller.currentPage.value = 1;
|
||||||
|
await controller.getHatchingList();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}, 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: [
|
||||||
|
Row(
|
||||||
|
spacing: 3,
|
||||||
|
children: [
|
||||||
|
Text('نژاد:', style: AppFonts.yekan14.copyWith(color: AppColor.textColor)),
|
||||||
|
Text(
|
||||||
|
item.breed?.first.breed ?? 'N/A',
|
||||||
|
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(width: 2),
|
||||||
|
|
||||||
|
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'),
|
||||||
|
buildRow(
|
||||||
|
title: 'حجم جوجه ریزی',
|
||||||
|
value: item.quantity.separatedByComma,
|
||||||
|
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||||
|
),
|
||||||
|
buildRow(title: 'مانده در سالن', value: item.leftOver.separatedByComma),
|
||||||
|
buildRow(title: 'تلفات', value: item.losses.separatedByComma),
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:rasadyar_chicken/presentation/pages/auth/logic.dart';
|
import 'package:rasadyar_chicken/presentation/pages/auth/logic.dart';
|
||||||
import 'package:rasadyar_chicken/presentation/pages/auth/view.dart';
|
import 'package:rasadyar_chicken/presentation/pages/auth/view.dart';
|
||||||
|
import 'package:rasadyar_chicken/presentation/pages/poultry_science/active_hatching/logic.dart';
|
||||||
|
import 'package:rasadyar_chicken/presentation/pages/poultry_science/active_hatching/view.dart';
|
||||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/farm/logic.dart';
|
import 'package:rasadyar_chicken/presentation/pages/poultry_science/farm/logic.dart';
|
||||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/farm/view.dart';
|
import 'package:rasadyar_chicken/presentation/pages/poultry_science/farm/view.dart';
|
||||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/home/logic.dart';
|
import 'package:rasadyar_chicken/presentation/pages/poultry_science/home/logic.dart';
|
||||||
@@ -190,6 +192,15 @@ sealed class ChickenPages {
|
|||||||
Get.lazyPut(() => PoultryScienceRootLogic());
|
Get.lazyPut(() => PoultryScienceRootLogic());
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
GetPage(
|
||||||
|
name: ChickenRoutes.activeHatchingPoultryScience,
|
||||||
|
page: () => ActiveHatchingPage(),
|
||||||
|
middlewares: [AuthMiddleware()],
|
||||||
|
binding: BindingsBuilder(() {
|
||||||
|
Get.lazyPut(() => ActiveHatchingLogic());
|
||||||
|
Get.lazyPut(() => PoultryScienceRootLogic());
|
||||||
|
}),
|
||||||
|
),
|
||||||
//endregion
|
//endregion
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user