feat : inspection

This commit is contained in:
2025-09-07 17:20:01 +03:30
parent 5281bcbea6
commit d914bf7f36
22 changed files with 10607 additions and 44 deletions

View File

@@ -15,7 +15,7 @@ class PoultryScienceHomeLogic extends GetxController {
Future<void> getHomePoultryHatching() async {
await safeCall<HomePoultryScienceModel?>(
call: () async => await rootLogic.poultryRepository.getHomePoultryScience(
call: () async => await rootLogic.poultryRepository.getHomePoultry(
token: rootLogic.tokenService.accessToken.value!,
type: 'home',
),

View File

@@ -141,7 +141,7 @@ class PoultryScienceHomePage extends GetView<PoultryScienceHomeLogic> {
),
),
WidelyUsedWidget(),
// WidelyUsedWidget(),
SizedBox(height: 20),
],
),

View File

@@ -0,0 +1,258 @@
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/root/logic.dart';
import 'package:rasadyar_core/core.dart';
class InspectionPoultryScienceLogic extends GetxController {
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;
RxList<int> isExpandedList = <int>[].obs;
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;
@override
void onInit() {
super.onInit();
routesName.value = ['اقدام'].toList();
routesName.add(selectedSegmentIndex.value == 0 ? 'بازرسی' : 'بایگانی');
ever(selectedSegmentIndex, (callback) {
routesName.removeLast();
routesName.add(callback == 0 ? 'بازرسی' : 'بایگانی');
});
}
@override
void onReady() {
super.onReady();
getHatchingList();
getHatchingReport();
checkPermission(request: true);
ever(pickedImages, (callback) {
_multiPartPickedImages.clear();
for (var element in pickedImages) {
_multiPartPickedImages.add(
MultipartFile.fromFileSync(element.path, filename: element.name),
);
}
});
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
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},
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: '',
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 ImagePicker().pickImage(
source: ImageSource.camera,
imageQuality: 50,
preferredCameraDevice: CameraDevice.front,
maxHeight: 720,
maxWidth: 1080,
);
getFileSizeInKB(tmp?.path ?? '', tag: 'Picked');
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;
DioFormData formData = DioFormData();
for (var element in _multiPartPickedImages) {
var ls = await element.finalize().toList();
formData.addFile('file', ls[0], element.filename ?? 'image.jpg');
}
formData.addField("lat", currentLocation.value.latitude.toString());
formData.addField("log", currentLocation.value.longitude.toString());
formData.addField("hatching_id", id.toString());
safeCall(
call: () async => await rootLogic.poultryRepository.submitPoultryScienceReport(
token: rootLogic.tokenService.accessToken.value!,
data: formData,
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,
);
}
Future<void> determineCurrentPosition() async {
final position = await Geolocator.getCurrentPosition(
locationSettings: AndroidSettings(accuracy: LocationAccuracy.best),
);
final latLng = LatLng(position.latitude, position.longitude);
currentLocation.value = latLng;
}
Future<bool> checkPermission({bool request = false}) async {
try {
final LocationPermission permission = await Geolocator.checkPermission();
switch (permission) {
case LocationPermission.denied:
final LocationPermission requestResult = await Geolocator.requestPermission();
return requestResult != LocationPermission.denied &&
requestResult != LocationPermission.deniedForever;
case LocationPermission.deniedForever:
return request ? await Geolocator.openAppSettings() : false;
case LocationPermission.always:
case LocationPermission.whileInUse:
return true;
default:
return false;
}
} catch (e) {
eLog(e);
return await Geolocator.openLocationSettings();
}
}
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;
}
}
}

View File

@@ -0,0 +1,586 @@
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/widget/base_page/view.dart';
import 'package:rasadyar_chicken/presentation/widget/page_route.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 BasePage(
isBase: true,
routesWidget: ObxValue((route) => buildPageRoute(route), controller.routesName),
onBackPressed: () => Get.back(id: 0),
widgets: [
segmentWidget(),
ObxValue((data) {
return data.value == 0 ? hatchingWidget() : reportWidget();
}, controller.selectedSegmentIndex),
],
);
}
ObxValue<Rx<Resource<PaginationModel<HatchingModel>>>> 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.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.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: [
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 ?? 'N/A',
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
buildRow(title: 'مانده در سالن', value: item.leftOver.separatedByComma ?? 'N/A'),
buildRow(title: 'تلفات', value: item.losses.separatedByComma ?? 'N/A'),
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 ?? 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(
child: Column(
children: [
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
childAspectRatio: 1,
),
shrinkWrap: true,
itemCount: 7,
itemBuilder: (context, index) {
return ObxValue((data) {
if (index + 1 > 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.camera_alt,
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: 20),
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),
],
),
],
),
),
);
}
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 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: itemListWidgetReport(item),
secondChild: itemListExpandedWidgetReport(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.getHatchingReport(true),
onRefresh: () async {
controller.currentPage.value = 1;
await controller.getHatchingReport();
},
);
}, 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?.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),
),
SizedBox(width: 2),
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'),
buildRow(
title: 'حجم جوجه ریزی',
value: item.hatching?.quantity.separatedByComma ?? 'N/A',
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
buildRow(title: 'مانده در سالن', value: item.hatching?.leftOver.separatedByComma ?? 'N/A'),
buildRow(title: 'تلفات', value: item.hatching?.losses.separatedByComma ?? 'N/A'),
buildRow(
title: 'دامپزشک فارم',
value: '${item.hatching?.vetFarm?.vetFarmFullname}(${item.hatching?.vetFarm?.vetFarmMobile})',
),
buildRow(
title: 'شرح بازرسی',
value: 'تکمیل شده',
titleStyle: AppFonts.yekan14.copyWith(
color: AppColor.greenNormal
),
valueStyle: AppFonts.yekan14.copyWith(
color: AppColor.greenNormal
),
),
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: 138.h,
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.r),
image: DecorationImage(
image: NetworkImage(item.image?[index] ?? ''),
fit: BoxFit.cover,
),
),
),
),
),
],
),
);
}
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),
),
),
],
);
}
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: 3,
children: [
Text(
item.hatching?.poultry?.fullname ?? 'N/A',
textAlign: TextAlign.start,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
Text(
item.hatching?.poultry?.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.hatching?.poultry?.unitName ?? 'N/Aaq',
textAlign: TextAlign.start,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
),
Text(
item.hatching?.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),
),
),
],
);
}
}

View File

@@ -1,5 +1,18 @@
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_core/core.dart';
class PoultryActionLogic extends GetxController {
RxList<String> actions = ['a'].obs;
class PoultryActionItem {
final String title;
final String route;
PoultryActionItem({required this.title, required this.route});
}
class PoultryActionLogic extends GetxController {
RxList<PoultryActionItem> items = [
PoultryActionItem(title: "بازرسی", route: ChickenRoutes.inspectionPoultryScience),
PoultryActionItem(title: "ثبت کشتار", route: ChickenRoutes.killingRegistrationPoultryScience),
PoultryActionItem(title: "فارم ها", route: ChickenRoutes.farmPoultryScience),
PoultryActionItem(title: "جوجه ریزی فعال", route: ChickenRoutes.activeHatchingPoultryScience),
].obs;
}

View File

@@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rasadyar_chicken/presentation/pages/role/view.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/common/assets.gen.dart';
import '../../../widget/app_bar.dart';
import 'logic.dart';
@@ -13,42 +11,33 @@ class PoultryActionPage extends GetView<PoultryActionLogic> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: chickenAppBar(
hasBack: false,
hasFilter: false,
hasSearch: false,
isBase: false,
),
appBar: chickenAppBar(hasBack: false, hasFilter: false, hasSearch: false, isBase: false),
body: Column(
children: [
Assets.images.poultryAction.image(
height: 212.h,
width: Get.width.w,
fit: BoxFit.cover,
),
Assets.images.poultryAction.image(height: 212.h, width: Get.width.w, fit: BoxFit.cover),
ObxValue((data) {
return Expanded(
child: GridView.builder(
physics: BouncingScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisCount: 2,
mainAxisSpacing: 12.h,
crossAxisSpacing: 12.w,
childAspectRatio: 2,
),
itemCount: 4,
itemCount: data.length,
hitTestBehavior: HitTestBehavior.opaque,
itemBuilder: (BuildContext context, int index) {
var item = data[index];
return roleCard(
title: data[index],
title: item.title,
onTap: () async {
Get.toNamed(item.route, id: 0);
},
);
},
),
);
}, controller.actions),
}, controller.items),
],
),
);

View File

@@ -3,7 +3,7 @@ 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/presentation/pages/poultry_science/home/view.dart';
import 'package:rasadyar_chicken/presentation/pages/poultry_science/poultry_action/view.dart';
import 'package:rasadyar_chicken/presentation/pages/steward/profile/view.dart';
import 'package:rasadyar_chicken/presentation/pages/poultry_science/profile/view.dart';
import 'package:rasadyar_chicken/presentation/utils/utils.dart';
import 'package:rasadyar_core/core.dart';
@@ -11,11 +11,7 @@ enum ErrorLocationType { serviceDisabled, permissionDenied, none }
class PoultryScienceRootLogic extends GetxController {
RxInt currentPage = 1.obs;
List<Widget> pages = [
PoultryActionPage(),
PoultryScienceHomePage(),
ProfilePage(),
];
List<Widget> pages = [PoultryActionPage(), PoultryScienceHomePage(), PoultryScienceProfilePage()];
late DioRemote dioRemote;
var tokenService = Get.find<TokenStorageService>();
late PoultryScienceRepository poultryRepository;

View File

@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rasadyar_chicken/presentation/routes/pages.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -67,18 +69,24 @@ class PoultryScienceRootPage extends GetView<PoultryScienceRootLogic> {
),*/
Navigator(
key: Get.nestedKey(0),
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[0]),
onGenerateRoute: (settings) {
final page = ChickenPages.pages.firstWhere(
(e) => e.name == settings.name,
orElse: () => ChickenPages.pages.firstWhere(
(e) => e.name == ChickenRoutes.actionPoultryScience,
),
);
return buildRouteFromGetPage(page);
},
),
Navigator(
key: Get.nestedKey(1),
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[1]),
onGenerateRoute: (settings) => GetPageRoute(page: () => controller.pages[1]),
),
Navigator(
key: Get.nestedKey(2),
onGenerateRoute: (settings) =>
GetPageRoute(page: () => controller.pages[1]),
onGenerateRoute: (settings) => GetPageRoute(page: () => controller.pages[2]),
),
],
index: data.value,
@@ -92,7 +100,7 @@ class PoultryScienceRootPage extends GetView<PoultryScienceRootLogic> {
icon: Assets.vec.settingSvg.path,
isSelected: controller.currentPage.value == 0,
onTap: () {
//Get.nestedKey(1)?.currentState?.popUntil((route) => route.isFirst);
Get.nestedKey(1)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(0);
},
@@ -102,8 +110,8 @@ class PoultryScienceRootPage extends GetView<PoultryScienceRootLogic> {
icon: Assets.vec.homeSvg.path,
isSelected: controller.currentPage.value == 1,
onTap: () {
/* Get.nestedKey(1)?.currentState?.popUntil((route) => route.isFirst);
Get.nestedKey(0)?.currentState?.popUntil((route) => route.isFirst);*/
Get.nestedKey(0)?.currentState?.popUntil((route) => route.isFirst);
Get.nestedKey(2)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(1);
},
),