Browse Source

[feat]亲密度分析,图片预览页,使用PhotoViewGallery的自定义视图

hezihao 7 months ago
parent
commit
7fd85d5eb2
1 changed files with 19 additions and 5 deletions
  1. 19 5
      lib/module/intimacy_analyse/image_viewer/image_viewer_page.dart

+ 19 - 5
lib/module/intimacy_analyse/image_viewer/image_viewer_page.dart

@@ -80,16 +80,15 @@ class ImageViewerPage extends BasePage<ImageViewerController> {
                 controller.updateCurrentIndex(index);
               },
               builder: (BuildContext context, int index) {
-                return PhotoViewGalleryPageOptions(
+                return PhotoViewGalleryPageOptions.customChild(
                   minScale: PhotoViewComputedScale.contained,
                   maxScale: PhotoViewComputedScale.covered * 2,
-                  imageProvider: controller.getImageProvider(
-                    controller.imageViewerItemList[index],
-                  ),
                   initialScale: PhotoViewComputedScale.contained * 0.8,
+                  // 自定义视图
+                  child: _buildImageViewerItem(index),
                 );
               },
-              backgroundDecoration: BoxDecoration(color: ColorName.black),
+              // backgroundDecoration: BoxDecoration(color: ColorName.black),
               pageController: controller.pageController,
             );
           }),
@@ -117,6 +116,21 @@ class ImageViewerPage extends BasePage<ImageViewerController> {
     );
   }
 
+  /// 构建每一项
+  Widget _buildImageViewerItem(int index) {
+    return Stack(
+      fit: StackFit.expand,
+      children: [
+        Image(
+          image: controller.getImageProvider(
+            controller.imageViewerItemList[index],
+          ),
+          // fit: BoxFit.cover,
+        ),
+      ],
+    );
+  }
+
   /// 指示器
   Widget _buildIndicator() {
     return Center(