diff --git a/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/create_inspection_bottom_sheet_logic.dart b/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/create_inspection_bottom_sheet_logic.dart index c81cd05..341551d 100644 --- a/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/create_inspection_bottom_sheet_logic.dart +++ b/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/create_inspection_bottom_sheet_logic.dart @@ -190,21 +190,22 @@ class CreateInspectionBottomSheetLogic extends GetxController TextEditingController(); RxList hallImagesUrls = RxList(); + RImagePickerController hallImagesController = RImagePickerController(); RxList hallImages = RxList(); RxList inputWarehouseImagesUrls = RxList(); + RImagePickerController inputWarehouseImagesController = + RImagePickerController(); RxList inputWarehouseImages = RxList(); RxList lossesImagesUrls = RxList(); + RImagePickerController lossesImagesController = RImagePickerController(); RxList lossesImages = RxList(); //location Rxn currentLocation = Rxn(); RxBool isLoadingLocation = false.obs; - //images - ImagePicker imagePicker = ImagePicker(); - @override void onReady() { super.onReady(); @@ -220,7 +221,9 @@ class CreateInspectionBottomSheetLogic extends GetxController ); }); setUpPultryImagesListener(); - + setUpHallImagesListener(); + setUpInputWarehouseImagesListener(); + setUpLossesImagesListener(); initData(); setUpNextButtonListeners(); } @@ -570,32 +573,6 @@ class CreateInspectionBottomSheetLogic extends GetxController } } - Future pickImageFromCamera(RxList images) async { - try { - final XFile? image = await imagePicker.pickImage( - source: ImageSource.camera, - preferredCameraDevice: CameraDevice.rear, - imageQuality: 50, - maxWidth: 1080, - maxHeight: 720, - ); - - if (image != null) { - images.add(image); - - //await uploadImage(image); - } - } catch (e) { - Get.snackbar( - 'خطا', - 'خطا در باز کردن دوربین', - snackPosition: SnackPosition.TOP, - backgroundColor: Colors.red, - colorText: Colors.white, - ); - } - } - Future?> uploadImageBatch(List images) async { if (images.isEmpty) return []; @@ -964,7 +941,38 @@ class CreateInspectionBottomSheetLogic extends GetxController WidgetsBinding.instance.addPostFrameCallback((_) { pultryImages.assignAll(pultryImagesController.capturedImages); }); - + } + }); + } + + void setUpHallImagesListener() { + hallImagesController.addListener(() { + if (hallImagesController.capturedImages.isNotEmpty) { + WidgetsBinding.instance.addPostFrameCallback((_) { + hallImages.assignAll(hallImagesController.capturedImages); + }); + } + }); + } + + void setUpInputWarehouseImagesListener() { + inputWarehouseImagesController.addListener(() { + if (inputWarehouseImagesController.capturedImages.isNotEmpty) { + WidgetsBinding.instance.addPostFrameCallback((_) { + inputWarehouseImages.assignAll( + inputWarehouseImagesController.capturedImages, + ); + }); + } + }); + } + + void setUpLossesImagesListener() { + lossesImagesController.addListener(() { + if (lossesImagesController.capturedImages.isNotEmpty) { + WidgetsBinding.instance.addPostFrameCallback((_) { + lossesImages.assignAll(lossesImagesController.capturedImages); + }); } }); } diff --git a/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/step2_page.dart b/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/step2_page.dart index b7cea3f..d4b1e73 100644 --- a/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/step2_page.dart +++ b/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/step2_page.dart @@ -144,6 +144,7 @@ Widget generalConditionOfTheHall(CreateInspectionBottomSheetLogic controller) { child: Container( height: 80.h, width: 80.w, + margin: EdgeInsets.only(left: 8.h), padding: EdgeInsets.all(22), decoration: BoxDecoration( color: Color(0xFFE9E9E9), diff --git a/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/step4_page.dart b/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/step4_page.dart index d845c77..c038e59 100644 --- a/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/step4_page.dart +++ b/packages/chicken/lib/features/poultry_science/presentation/widgets/submit_inspection_bottom_sheet/step4_page.dart @@ -114,8 +114,15 @@ Column documents(CreateInspectionBottomSheetLogic controller) { ), // Add image button GestureDetector( - onTap: () => - controller.pickImageFromCamera(controller.hallImages), + onTap: () => Get.to( + () => RImagePicker( + controller: controller.hallImagesController, + ), + fullscreenDialog: true, + transition: Transition.fade, + duration: Duration(milliseconds: 300), + ), + child: Container( height: 80.h, width: 80.w, @@ -222,8 +229,13 @@ Column documents(CreateInspectionBottomSheetLogic controller) { ), // Add image button GestureDetector( - onTap: () => controller.pickImageFromCamera( - controller.inputWarehouseImages, + onTap: () => Get.to( + () => RImagePicker( + controller: controller.inputWarehouseImagesController, + ), + fullscreenDialog: true, + transition: Transition.fade, + duration: Duration(milliseconds: 300), ), child: Container( height: 80.h, @@ -319,8 +331,13 @@ Column documents(CreateInspectionBottomSheetLogic controller) { ), // Add image button GestureDetector( - onTap: () => controller.pickImageFromCamera( - controller.lossesImages, + onTap: () => Get.to( + () => RImagePicker( + controller: controller.lossesImagesController, + ), + fullscreenDialog: true, + transition: Transition.fade, + duration: Duration(milliseconds: 300), ), child: Container( height: 80.h,