feat: integrate camera package and update related dependencies in pubspec.lock for enhanced image handling capabilities
This commit is contained in:
@@ -424,3 +424,5 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ class CreateInspectionBottomSheetLogic extends GetxController
|
||||
TextEditingController otherTypeOfDiseaseController = TextEditingController();
|
||||
|
||||
RxList<String> pultryImagesUrls = RxList<String>();
|
||||
RImagePickerController pultryImagesController = RImagePickerController();
|
||||
RxList<XFile> pultryImages = RxList<XFile>();
|
||||
|
||||
TextEditingController hatchingTemperatureController = TextEditingController();
|
||||
@@ -214,6 +215,7 @@ class CreateInspectionBottomSheetLogic extends GetxController
|
||||
curve: Curves.linear,
|
||||
);
|
||||
});
|
||||
setUpPultryImagesListener();
|
||||
|
||||
initData();
|
||||
setUpNextButtonListeners();
|
||||
@@ -340,7 +342,7 @@ class CreateInspectionBottomSheetLogic extends GetxController
|
||||
inspectorConclusionDescriptionController.clear();
|
||||
|
||||
// Clear all images
|
||||
pultryImages.clear();
|
||||
pultryImagesController.disposeCameraController();
|
||||
pultryImagesUrls.clear();
|
||||
hallImages.clear();
|
||||
hallImagesUrls.clear();
|
||||
@@ -590,27 +592,6 @@ class CreateInspectionBottomSheetLogic extends GetxController
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> uploadImage(XFile imageFile) async {
|
||||
await safeCall(
|
||||
call: () async {
|
||||
final urls = await repository.uploadImages(
|
||||
token: tokenStorageService.accessToken.value ?? '',
|
||||
images: [imageFile],
|
||||
);
|
||||
return urls;
|
||||
},
|
||||
onSuccess: (urls) {
|
||||
if (urls != null) {
|
||||
pultryImagesUrls.addAll(urls);
|
||||
}
|
||||
pultryImages.add(imageFile);
|
||||
},
|
||||
onError: (error, e) {
|
||||
pultryImages.remove(imageFile);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<String>?> uploadImageBatch(List<XFile> images) async {
|
||||
if (images.isEmpty) return [];
|
||||
|
||||
@@ -649,7 +630,7 @@ class CreateInspectionBottomSheetLogic extends GetxController
|
||||
hallImages.length +
|
||||
inputWarehouseImages.length +
|
||||
lossesImages.length +
|
||||
pultryImages.length;
|
||||
pultryImagesController.capturedImages.length;
|
||||
|
||||
if (totalImages == 0) {
|
||||
isUploadingImages.value = false;
|
||||
@@ -702,9 +683,10 @@ class CreateInspectionBottomSheetLogic extends GetxController
|
||||
}
|
||||
|
||||
// آپلود عکسهای مرغداری
|
||||
if (pultryImages.isNotEmpty) {
|
||||
if (pultryImagesController.capturedImages.isNotEmpty) {
|
||||
uploadStatusMessage.value = 'در حال آپلود عکسهای مرغداری...';
|
||||
final poultryImageFiles = pultryImages.toList();
|
||||
final poultryImageFiles = pultryImagesController.capturedImages
|
||||
.toList();
|
||||
final poultryUrls = await uploadImageBatch(poultryImageFiles);
|
||||
|
||||
if (poultryUrls != null && poultryUrls.isNotEmpty) {
|
||||
@@ -971,4 +953,10 @@ class CreateInspectionBottomSheetLogic extends GetxController
|
||||
showError: true,
|
||||
);
|
||||
}
|
||||
|
||||
void setUpPultryImagesListener() {
|
||||
pultryImagesController.addListener(() {
|
||||
pultryImages.assignAll(pultryImagesController.capturedImages);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ Widget step2Page(CreateInspectionBottomSheetLogic controller) {
|
||||
);
|
||||
}
|
||||
|
||||
Column generalConditionOfTheHall(CreateInspectionBottomSheetLogic controller) {
|
||||
Widget generalConditionOfTheHall(CreateInspectionBottomSheetLogic controller) {
|
||||
return Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
@@ -66,88 +66,100 @@ Column generalConditionOfTheHall(CreateInspectionBottomSheetLogic controller) {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 9,
|
||||
children: [
|
||||
Obx(
|
||||
() => SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
spacing: 8,
|
||||
children: [
|
||||
...controller.pultryImages.map(
|
||||
(entry) => Stack(
|
||||
children: [
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 80.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: AppColor.blackLightHover,
|
||||
),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.file(
|
||||
File(entry.path),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Delete button
|
||||
Positioned(
|
||||
top: 4,
|
||||
left: 4,
|
||||
child: GestureDetector(
|
||||
onTap: () => controller.removeImage(
|
||||
controller.hallImages,
|
||||
entry.path,
|
||||
),
|
||||
child: Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
spacing: 8,
|
||||
children: [
|
||||
ObxValue((data) {
|
||||
return Row(
|
||||
children: data.value
|
||||
.map(
|
||||
(entry) => Stack(
|
||||
children: [
|
||||
Container(
|
||||
height: 80.h,
|
||||
width: 80.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
color: AppColor.blackLightHover,
|
||||
),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.file(
|
||||
File(entry.path),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
// Delete button
|
||||
Positioned(
|
||||
top: 4,
|
||||
left: 4,
|
||||
child: GestureDetector(
|
||||
onTap: () => controller.removeImage(
|
||||
controller.hallImages,
|
||||
entry.path,
|
||||
),
|
||||
child: Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Upload indicator
|
||||
],
|
||||
// Upload indicator
|
||||
],
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}, controller.pultryImages),
|
||||
|
||||
// Add image button
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
Get.to(
|
||||
() => RImagePicker(
|
||||
controller: controller.pultryImagesController,
|
||||
),
|
||||
fullscreenDialog: true,
|
||||
transition: Transition.fade,
|
||||
duration: Duration(milliseconds: 300),
|
||||
);
|
||||
},
|
||||
child: 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,
|
||||
),
|
||||
),
|
||||
// Add image button
|
||||
GestureDetector(
|
||||
onTap: () => controller.pickImageFromCamera(
|
||||
controller.pultryImages,
|
||||
),
|
||||
child: 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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user