Procházet zdrojové kódy

[feat]分析亲密度,图片预览,增加点击,显示和隐藏标题栏

hezihao před 9 měsíci
rodič
revize
5f41f54b5e

+ 8 - 0
lib/module/intimacy_analyse/image_viewer/image_viewer_controller.dart

@@ -20,6 +20,9 @@ class ImageViewerController extends BaseController {
   /// 当前的查看的图片的索引
   Rx<int> currentIndex = 0.obs;
 
+  /// 是否显示标题栏
+  RxBool isShowTitleBar = true.obs;
+
   late PageController pageController;
 
   @override
@@ -77,6 +80,11 @@ class ImageViewerController extends BaseController {
     currentIndex.value = newIndex;
   }
 
+  /// 切换标题栏的显示和隐藏
+  void toggleShowTitleBar() {
+    isShowTitleBar.value = !isShowTitleBar.value;
+  }
+
   /// 获取对应类型的图片ImageProvider
   ImageProvider getImageProvider(ImageViewerItem item) {
     switch (item.type) {

+ 42 - 33
lib/module/intimacy_analyse/image_viewer/image_viewer_page.dart

@@ -81,6 +81,10 @@ class ImageViewerPage extends BasePage<ImageViewerController> {
               },
               builder: (BuildContext context, int index) {
                 return PhotoViewGalleryPageOptions.customChild(
+                  onTapDown: (context, details, controllerValue) {
+                    // 切换标题栏的显示和隐藏
+                    controller.toggleShowTitleBar();
+                  },
                   minScale: PhotoViewComputedScale.contained,
                   maxScale: PhotoViewComputedScale.covered * 2,
                   initialScale: PhotoViewComputedScale.contained * 0.8,
@@ -162,41 +166,46 @@ class ImageViewerPage extends BasePage<ImageViewerController> {
 
   /// 标题栏
   Widget _buildTitleBar() {
-    return Container(
-      height: kToolbarHeight,
-      // 宽度,匹配父组件
-      width: double.infinity,
-      color: ColorName.black,
-      padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 14.0),
-      child: Stack(
-        children: [
-          // 返回按钮
-          GestureDetector(
-            onTap: controller.clickBack,
-            child: Assets.images.iconImageViewerClose.image(
-              width: 24.w,
-              height: 24.h,
-            ),
-          ),
-          // 标题
-          Positioned(
-            left: 0,
-            top: 0,
-            right: 0,
-            child: Container(
-              alignment: Alignment.center,
-              child: Text(
-                StringName.preview,
-                style: TextStyle(
-                  fontSize: 16.sp,
-                  fontWeight: FontWeight.w500,
-                  color: ColorName.white,
+    return Obx(() {
+      return Visibility(
+        visible: controller.isShowTitleBar.value,
+        child: Container(
+          height: kToolbarHeight,
+          // 宽度,匹配父组件
+          width: double.infinity,
+          color: ColorName.black,
+          padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 14.0),
+          child: Stack(
+            children: [
+              // 返回按钮
+              GestureDetector(
+                onTap: controller.clickBack,
+                child: Assets.images.iconImageViewerClose.image(
+                  width: 24.w,
+                  height: 24.h,
                 ),
               ),
-            ),
+              // 标题
+              Positioned(
+                left: 0,
+                top: 0,
+                right: 0,
+                child: Container(
+                  alignment: Alignment.center,
+                  child: Text(
+                    StringName.preview,
+                    style: TextStyle(
+                      fontSize: 16.sp,
+                      fontWeight: FontWeight.w500,
+                      color: ColorName.white,
+                    ),
+                  ),
+                ),
+              ),
+            ],
           ),
-        ],
-      ),
-    );
+        ),
+      );
+    });
   }
 }