Explorar o código

[fit]修改_buildPhotoItem,显示缩略图

云天逵 hai 1 ano
pai
achega
9b127242bf

+ 9 - 8
lib/module/calendar/calendar_month_view.dart

@@ -57,20 +57,22 @@ class CalendarMonthPage extends BasePage<CalendarMonthController> {
                           "CalendarMonthPage buildBody ${controller.photoGroup
                               .value.images.length}");
                       return GridView.builder(
-
                           padding: EdgeInsets.symmetric(horizontal: 16.w),
                           scrollDirection: Axis.vertical,
                           // 设置为垂直方向滚动
                           physics: BouncingScrollPhysics(),
-
                           gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                             crossAxisCount: 3, // 每行显示 3 个元素
                             mainAxisSpacing: 8.w, // 垂直间距
                             crossAxisSpacing: 8.h, // 水平间距
                           ),
                           itemCount: controller.photoGroup.value.images.length,
-                          itemBuilder: _buildPhotoItem(
-                              controller.photoGroup.value.images));
+                          itemBuilder: (context, index) {
+                            return _buildPhotoItem(
+                                context,
+                                index,
+                                controller.photoGroup.value.images);
+                          });
                     }),
                   ),
                   Obx(() {
@@ -207,9 +209,8 @@ class CalendarMonthPage extends BasePage<CalendarMonthController> {
     );
   }
 
-  Widget Function(BuildContext, int) _buildPhotoItem(
-      List<AssetEntity> images) =>
-          (context, index) {
+  Widget _buildPhotoItem
+          (context, index, List<AssetEntity> images) {
         return Obx(() {
           final photoId = controller.photoGroup.value.images[index].id;
           final isSelected =
@@ -278,7 +279,7 @@ class CalendarMonthPage extends BasePage<CalendarMonthController> {
                 ],
               ));
         });
-      };
+      }
 
   Widget _bottomBarCard() {
     return GestureDetector(

+ 2 - 0
lib/module/calendar/calendar_view.dart

@@ -142,6 +142,8 @@ class CalendarPage extends BaseView<CalendarController> {
                             child: ClipRRect(
                               borderRadius: BorderRadius.circular(12.r),
                               child: AssetEntityImage(
+                                isOriginal: false,
+                                thumbnailSize: const ThumbnailSize.square(300),
                                 width: 146.w,
                                 height: 146.w,
                                 fit: BoxFit.cover,

+ 6 - 6
lib/module/calendar/selected_preview/calendar_selected_preview_view.dart

@@ -68,8 +68,10 @@ class CalendarSelectedPreviewPage
                               ),
                               itemCount:
                                   controller.photoGroup.value.images.length,
-                              itemBuilder: _buildPhotoItem(
-                                  controller.photoGroup.value.images)),
+                              itemBuilder: (context, index) {
+                                return _buildPhotoItem(context, index,
+                                    controller.photoGroup.value.images);
+                              }),
                         );
                       }),
                     ),
@@ -201,9 +203,7 @@ class CalendarSelectedPreviewPage
         ));
   }
 
-  Widget Function(BuildContext, int) _buildPhotoItem(
-          List<AssetEntity> images) =>
-      (context, index) {
+  Widget _buildPhotoItem(context, index,  List<AssetEntity> images) {
         return GestureDetector(
           onTap: () => controller.clickImage(index),
           child: Obx(() {
@@ -253,7 +253,7 @@ class CalendarSelectedPreviewPage
             );
           }),
         );
-      };
+      }
 
   Widget _noNoPicturesCard() {
     return Column(

+ 11 - 6
lib/module/locations_photo/locations_single_photo_view.dart

@@ -67,8 +67,13 @@ class LocationsSinglePhotoPage
                               ),
                               itemCount:
                               controller.photoGroup.value.images.length,
-                              itemBuilder: _buildPhotoItem(
-                                  controller.photoGroup.value.images)),
+                              itemBuilder: (context, index) {
+                                return _buildPhotoItem(
+                                    context,
+                                    index,
+                                    controller.photoGroup.value.images);
+                              }
+                          ),
                         );
                       }),
                     ),
@@ -184,9 +189,7 @@ class LocationsSinglePhotoPage
     );
   }
 
-  Widget Function(BuildContext, int) _buildPhotoItem(
-          List<AssetEntity> images) =>
-      (context, index) {
+  Widget _buildPhotoItem(context, index,List<AssetEntity> images) {
         final group = controller.photoGroup.value;
 
         return GestureDetector(
@@ -209,6 +212,8 @@ class LocationsSinglePhotoPage
                     borderRadius: BorderRadius.circular(9.27.sp),
                     child: AssetEntityImage(
                       group.images[index],
+                      isOriginal: false,
+                      thumbnailSize: const ThumbnailSize.square(300),
                       width: 104.w,
                       height: 104.w,
                       fit: BoxFit.cover,
@@ -245,7 +250,7 @@ class LocationsSinglePhotoPage
             );
           }),
         );
-      };
+      }
 
   Widget _noNoPicturesCard() {
     return Column(

+ 64 - 59
lib/module/people_photo/people_photo_view.dart

@@ -264,7 +264,9 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
                       crossAxisSpacing: 8.h,
                     ),
                     itemCount: controller.photoGroup.value.images.length,
-                    itemBuilder: _buildPhotoItem(),
+                    itemBuilder: ((context, index) {
+                      return _buildPhotoItem(context, index);
+                    }),
                   )
                 : GridView.builder(
                     scrollDirection: Axis.horizontal,
@@ -276,7 +278,9 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
                       childAspectRatio: 1,
                     ),
                     itemCount: controller.photoGroup.value.images.length,
-                    itemBuilder: _buildPhotoItem(),
+                    itemBuilder: ((context, index) {
+                      return _buildPhotoItem(context, index);
+                    }),
                   ),
           ),
         ],
@@ -284,65 +288,66 @@ class PeoplePhotoPage extends BasePage<PeoplePhotoController> {
     );
   }
 
-  Widget Function(BuildContext, int) _buildPhotoItem() => (context, index) {
-        return GestureDetector(
-          onTap: () {
-            controller.clickImage(index);
-            print("点击图片");
-          },
-          child: Obx(() {
-            final isSelected = controller.photoGroup.value
-                .isImageSelected(controller.photoGroup.value.images[index]);
-            return Stack(
-              children: [
-                Container(
-                  width: 70.w,
-                  height: 70.w,
-                  decoration: ShapeDecoration(
-                    color: Colors.white.withValues(alpha: 0.12),
-                    shape: RoundedRectangleBorder(
-                      borderRadius: BorderRadius.circular(9.27.sp),
-                    ),
-                  ),
-                  child: ClipRRect(
-                      borderRadius: BorderRadius.circular(9.27.sp),
-                      child: AssetEntityImage(controller.photoGroup.value.images[index],
-                          thumbnailSize: const ThumbnailSize.square(300),
-                          isOriginal: false,
-                          fit: BoxFit.cover,
-                          frameBuilder: Styles.customFrameBuilder(
-                            opacity: 0.22,
-                            width: 80.w,
-                            height: 80.w,
-                          ))),
+  Widget _buildPhotoItem(context, index) {
+    return GestureDetector(
+      onTap: () {
+        controller.clickImage(index);
+        print("点击图片");
+      },
+      child: Obx(() {
+        final isSelected = controller.photoGroup.value
+            .isImageSelected(controller.photoGroup.value.images[index]);
+        return Stack(
+          children: [
+            Container(
+              width: 70.w,
+              height: 70.w,
+              decoration: ShapeDecoration(
+                color: Colors.white.withValues(alpha: 0.12),
+                shape: RoundedRectangleBorder(
+                  borderRadius: BorderRadius.circular(9.27.sp),
                 ),
-                Positioned(
-                    right: 6.w,
-                    bottom: 6.h,
-                    child: GestureDetector(
-                      onTap: () {
-                        controller.toggleImageSelection(index);
-                      },
-                      child: Container(
-                        child: isSelected
-                            ? Center(
-                                child: Assets.images.iconSelected.image(
-                                  width: 20.w,
-                                  height: 20.h,
-                                ),
-                              )
-                            : Center(
-                                child: Assets.images.iconUnselected.image(
-                                width: 20.w,
-                                height: 20.h,
-                              )),
-                      ),
-                    )),
-              ],
-            );
-          }),
+              ),
+              child: ClipRRect(
+                  borderRadius: BorderRadius.circular(9.27.sp),
+                  child: AssetEntityImage(
+                      controller.photoGroup.value.images[index],
+                      thumbnailSize: const ThumbnailSize.square(300),
+                      isOriginal: false,
+                      fit: BoxFit.cover,
+                      frameBuilder: Styles.customFrameBuilder(
+                        opacity: 0.22,
+                        width: 80.w,
+                        height: 80.w,
+                      ))),
+            ),
+            Positioned(
+                right: 6.w,
+                bottom: 6.h,
+                child: GestureDetector(
+                  onTap: () {
+                    controller.toggleImageSelection(index);
+                  },
+                  child: Container(
+                    child: isSelected
+                        ? Center(
+                            child: Assets.images.iconSelected.image(
+                              width: 20.w,
+                              height: 20.h,
+                            ),
+                          )
+                        : Center(
+                            child: Assets.images.iconUnselected.image(
+                            width: 20.w,
+                            height: 20.h,
+                          )),
+                  ),
+                )),
+          ],
         );
-      };
+      }),
+    );
+  }
 
   Widget _noNoPicturesCard() {
     return Column(

+ 57 - 62
lib/module/photo_preview/phtoto_selected_preview_view.dart

@@ -50,7 +50,7 @@ class PhotoSelectedPreviewPage
                 if (controller.photoGroups.isEmpty ||
                     controller.photoGroups[0].images.isEmpty) {
                   return _noNoPicturesCard();
-                }else if (controller.isKeepAll.value) {
+                } else if (controller.isKeepAll.value) {
                   return _finishCleanCard();
                 }
                 return Column(
@@ -72,7 +72,9 @@ class PhotoSelectedPreviewPage
                               ),
                               itemCount:
                                   controller.photoGroups[0].images.length,
-                              itemBuilder: _buildPhotoItem(
+                              itemBuilder: (context, index) => _buildPhotoItem(
+                                  context,
+                                  index,
                                   controller.photoGroups[0].images)),
                         );
                       }),
@@ -96,14 +98,12 @@ class PhotoSelectedPreviewPage
           return IgnorePointer(
             child: Assets.images.bgPhotoSelectedPreviewFinish.image(
               width: 360.w,
-
             ),
           );
         } else {
           return IgnorePointer(
             child: Assets.images.bgHome.image(
               width: 360.w,
-
             ),
           );
         }
@@ -211,69 +211,64 @@ class PhotoSelectedPreviewPage
         ));
   }
 
-  Widget Function(BuildContext, int) _buildPhotoItem(
-          List<AssetEntity> images) =>
-      (context, index) {
-        final group =
-            controller.getGroupByImages(controller.photoGroups[0].images);
-
-        return GestureDetector(
-          onTap: () =>
-              controller.clickImage(images, index, controller.photosType),
-          child: Obx(() {
-            var isSelected = group.isImageSelected(images[index]);
-            return Stack(
-              children: [
-                Container(
+  Widget _buildPhotoItem(context, index, List<AssetEntity> images) {
+    final group = controller.getGroupByImages(controller.photoGroups[0].images);
+    return GestureDetector(
+      onTap: () => controller.clickImage(images, index, controller.photosType),
+      child: Obx(() {
+        var isSelected = group.isImageSelected(images[index]);
+        return Stack(
+          children: [
+            Container(
+              width: 104.w,
+              height: 104.w,
+              decoration: ShapeDecoration(
+                color: Colors.white.withValues(alpha: 0.12),
+                shape: RoundedRectangleBorder(
+                  borderRadius: BorderRadius.circular(9.27.sp),
+                ),
+              ),
+              child: ClipRRect(
+                borderRadius: BorderRadius.circular(9.27.sp),
+                child: AssetEntityImage(
+                  group.images[index],
                   width: 104.w,
+                  isOriginal: false,
+                  thumbnailSize: const ThumbnailSize.square(300),
                   height: 104.w,
-                  decoration: ShapeDecoration(
-                    color: Colors.white.withValues(alpha: 0.12),
-                    shape: RoundedRectangleBorder(
-                      borderRadius: BorderRadius.circular(9.27.sp),
-                    ),
-                  ),
-                  child: ClipRRect(
-                    borderRadius: BorderRadius.circular(9.27.sp),
-                    child: AssetEntityImage(
-                      group.images[index],
-                      width: 104.w,
-                      thumbnailSize: const ThumbnailSize.square(300),
-                      height: 104.w,
-                      fit: BoxFit.cover,
-                      frameBuilder: Styles.customFrameBuilder(
-                        width: 104.w,
-                        height: 104.w,
-                      ),
-                    ),
+                  fit: BoxFit.cover,
+                  frameBuilder: Styles.customFrameBuilder(
+                    width: 104.w,
+                    height: 104.w,
                   ),
                 ),
-                Positioned(
-                  right: 8.w,
-                  bottom: 8.h,
-                  child: GestureDetector(
-                      onTap: () =>
-                          controller.toggleImageSelection(images, index),
-                      child: Container(
-                        child: isSelected
-                            ? Center(
-                                child: Assets.images.iconSelected.image(
-                                  width: 20.w,
-                                  height: 20.h,
-                                ),
-                              )
-                            : Center(
-                                child: Assets.images.iconUnselected.image(
-                                width: 20.w,
-                                height: 20.h,
-                              )),
-                      )),
-                ),
-              ],
-            );
-          }),
+              ),
+            ),
+            Positioned(
+              right: 8.w,
+              bottom: 8.h,
+              child: GestureDetector(
+                  onTap: () => controller.toggleImageSelection(images, index),
+                  child: Container(
+                    child: isSelected
+                        ? Center(
+                            child: Assets.images.iconSelected.image(
+                              width: 20.w,
+                              height: 20.h,
+                            ),
+                          )
+                        : Center(
+                            child: Assets.images.iconUnselected.image(
+                            width: 20.w,
+                            height: 20.h,
+                          )),
+                  )),
+            ),
+          ],
         );
-      };
+      }),
+    );
+  }
 
   Widget _noNoPicturesCard() {
     return Column(

+ 59 - 59
lib/module/screenshots_blurry/screenshots_view.dart

@@ -64,8 +64,10 @@ class ScreenshotsPage extends BasePage<ScreenShotsController> {
                             ),
                             itemCount:
                                 controller.photoGroup.value.images.length,
-                            itemBuilder: _buildPhotoItem(
-                                controller.photoGroup.value.images)),
+                            itemBuilder: (context, index) {
+                              return _buildPhotoItem(context, index,
+                                  controller.photoGroup.value.images);
+                            }),
                       );
                     }),
                   ),
@@ -189,67 +191,65 @@ class ScreenshotsPage extends BasePage<ScreenShotsController> {
         ));
   }
 
-  Widget Function(BuildContext, int) _buildPhotoItem(
-          List<AssetEntity> images) =>
-      (context, index) {
-        return GestureDetector(
-          onTap: () => controller.clickImage(index),
-          child: Obx(() {
-            final photoId = controller.photoGroup.value.images[index].id;
-            final isSelected =
-                controller.photoGroup.value.selectedPhotosIds.contains(photoId);
-            return Stack(
-              children: [
-                Container(
+  Widget _buildPhotoItem(context, index, List<AssetEntity> images) {
+    return GestureDetector(
+      onTap: () => controller.clickImage(index),
+      child: Obx(() {
+        final photoId = controller.photoGroup.value.images[index].id;
+        final isSelected =
+            controller.photoGroup.value.selectedPhotosIds.contains(photoId);
+        return Stack(
+          children: [
+            Container(
+                width: 104.w,
+                height: 104.w,
+                decoration: ShapeDecoration(
+                  color: Colors.white.withValues(alpha: 0.12),
+                  shape: RoundedRectangleBorder(
+                    borderRadius: BorderRadius.circular(9.27.sp),
+                  ),
+                ),
+                child: ClipRRect(
+                  borderRadius: BorderRadius.circular(9.27.sp),
+                  child: AssetEntityImage(
+                    controller.photoGroup.value.images[index],
                     width: 104.w,
                     height: 104.w,
-                    decoration: ShapeDecoration(
-                      color: Colors.white.withValues(alpha: 0.12),
-                      shape: RoundedRectangleBorder(
-                        borderRadius: BorderRadius.circular(9.27.sp),
-                      ),
+                    thumbnailSize: const ThumbnailSize.square(300),
+                    fit: BoxFit.cover,
+                    frameBuilder: Styles.customFrameBuilder(
+                      opacity: 0.22,
+                      width: 80.w,
+                      height: 80.w,
                     ),
-                    child: ClipRRect(
-                      borderRadius: BorderRadius.circular(9.27.sp),
-                      child: AssetEntityImage(
-                        controller.photoGroup.value.images[index],
-                        width: 104.w,
-                        height: 104.w,
-                        thumbnailSize: const ThumbnailSize.square(300),
-                        fit: BoxFit.cover,
-                        frameBuilder: Styles.customFrameBuilder(
-                          opacity: 0.22,
-                          width: 80.w,
-                          height: 80.w,
-                        ),
-                        isOriginal: false,
-                      ),
-                    )),
-                Positioned(
-                  right: 8.w,
-                  bottom: 8.h,
-                  child: GestureDetector(
-                      onTap: () => controller.toggleImageSelection(index),
-                      child: Container(
-                        child: isSelected
-                            ? Center(
-                                child: Assets.images.iconSelected.image(
-                                  width: 20.w,
-                                  height: 20.h,
-                                ),
-                              )
-                            : Center(
-                                child: Assets.images.iconUnselected.image(
-                                width: 20.w,
-                                height: 20.h,
-                              )),
-                      )),
-                ),
-              ],
-            );
-          }),
+                    isOriginal: false,
+                  ),
+                )),
+            Positioned(
+              right: 8.w,
+              bottom: 8.h,
+              child: GestureDetector(
+                  onTap: () => controller.toggleImageSelection(index),
+                  child: Container(
+                    child: isSelected
+                        ? Center(
+                            child: Assets.images.iconSelected.image(
+                              width: 20.w,
+                              height: 20.h,
+                            ),
+                          )
+                        : Center(
+                            child: Assets.images.iconUnselected.image(
+                            width: 20.w,
+                            height: 20.h,
+                          )),
+                  )),
+            ),
+          ],
         );
-      };
+      }),
+    );
+  }
 
   Widget _noNoPicturesCard() {
     return Column(