ソースを参照

更新预览页删除功能

云天逵 1 年間 前
コミット
037c92fe51

+ 13 - 3
lib/module/people_photo/photo_group.dart

@@ -7,6 +7,7 @@ class PhotoGroup {
 
   // 照片组中的图片数量
   final int imageCount;
+
   // 照片组的选择状态
   final RxBool isSelected;
 
@@ -19,8 +20,10 @@ class PhotoGroup {
   // 照片组的位置
   final String? location;
 
+  // 获取已选中的图片数量
   int get selectedCount => selectedImages.where((selected) => selected).length;
 
+  // 构造函数
   PhotoGroup({
     required this.imageCount,
     required this.title,
@@ -28,11 +31,18 @@ class PhotoGroup {
     required this.images,
     this.location,
   })  : isSelected = isSelected.obs,
-        selectedImages = List.generate(images.length, (_) => isSelected).obs;
+        selectedImages = RxList<bool>.filled(images.length, isSelected);
 
+  // 切换选择所有图片的状态
   void toggleSelectAll(bool value) {
     isSelected.value = value;
-    selectedImages.assignAll(List.generate(images.length, (_) => value));
+    selectedImages.assignAll(List.filled(images.length, value));
   }
 
-}
+  // 更新图片的选择状态
+  void updateImageSelection(int index, bool isSelected) {
+    if (index >= 0 && index < images.length) {
+      selectedImages[index] = isSelected;
+    }
+  }
+}

+ 12 - 0
lib/module/photo_preview/photo_preview_controller.dart

@@ -273,18 +273,30 @@ class PhotoPreviewController extends BaseController {
     switch(photosType){
       case PhotosType.peoplePhotos:
         ImagePickerUtil.updatePhotoGroupDate(PhotosType.peoplePhotos);
+        PeoplePhotoController controller = Get.find<PeoplePhotoController>();
+        controller.loadPeoplePhoto();
+        controller.restoreSelections();
         break;
       case PhotosType.screenshots:
         ImagePickerUtil.updatePhotoGroupDate(PhotosType.screenshots);
+        ScreenShotsController controller = Get.find<ScreenShotsController>();
+        controller.loadScreenshots();
+        controller.restoreSelections();
         break;
       case PhotosType.similarPhotos:
         ImagePickerUtil.updatePhotoGroupDate(PhotosType.similarPhotos);
+        SimilarPhotoController controller = Get.find<SimilarPhotoController>();
+        controller.loadSimilarPhotos();
         break;
       case PhotosType.locationPhotos:
         ImagePickerUtil.updatePhotoGroupDate(PhotosType.locationPhotos);
+        LocationsSinglePhotoController controller = Get.find<LocationsSinglePhotoController>();
+        controller.loadLocationsSinglePhoto();
         break;
       case PhotosType.blurryPhotos:
         ImagePickerUtil.updatePhotoGroupDate(PhotosType.blurryPhotos);
+        ScreenShotsController controller = Get.find<ScreenShotsController>();
+        controller.loadScreenshots();
         break;
     }
     _initData();