Kaynağa Gözat

[feat]亲密度分析,首页的报告预览,复用封装的报告组件

hezihao 7 ay önce
ebeveyn
işleme
322c49867e

+ 38 - 112
lib/module/intimacy_analyse/analyse_report/intimacy_analyse_report_view.dart

@@ -1,16 +1,10 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
-import 'package:get/get.dart';
 import 'package:keyboard/base/base_view.dart';
-import 'package:keyboard/module/intimacy_analyse/analyse_report/widget/report_item_widget.dart';
-import 'package:keyboard/module/intimacy_analyse/analyse_report/widget/report_title_widget.dart';
-
-import '../../../data/bean/intimacy_analyse_report.dart';
 import '../../../resource/assets.gen.dart';
 import '../../../resource/colors.gen.dart';
 import '../../../resource/string.gen.dart';
-import '../../../widget/avatar/avatar_image_widget.dart';
-import '../../../widget/markdown/markdown_viewer.dart';
+import '../widget/intimacy_analyse_report_widget.dart';
 import '../widget/intimacy_user_widget.dart';
 import 'intimacy_analyse_report_view_controller.dart';
 
@@ -28,21 +22,44 @@ class IntimacyAnalyseReportView
   Widget buildBody(BuildContext context) {
     return Stack(
       children: [
-        Column(
-          children: [
-            SizedBox(height: 35.h),
-            // 亲密度档案
-            Row(
-              mainAxisAlignment: MainAxisAlignment.center,
-              children: [_buildIntimacyArchives()],
+        Positioned.fill(
+          child: SizedBox(
+            width: double.infinity,
+            height: double.infinity,
+            child: SingleChildScrollView(
+              child: Column(
+                children: [
+                  SizedBox(height: 35.h),
+                  // 亲密度档案
+                  Row(
+                    mainAxisAlignment: MainAxisAlignment.center,
+                    children: [_buildIntimacyArchives()],
+                  ),
+                  SizedBox(height: 12.h),
+                  // 切换亲密度
+                  _buildIntimacyArchivesSwitchLayout(),
+                  SizedBox(height: 18.h),
+                  // 报告预览
+                  IntimacyAnalyseReportWidget(
+                    reportContent: controller.reportPreviewData.value,
+                    isPreview: true,
+                  ),
+                  SizedBox(height: 120.h),
+                ],
+              ),
             ),
-            SizedBox(height: 12.h),
-            // 切换亲密度
-            _buildIntimacyArchivesSwitchLayout(),
-            SizedBox(height: 18.h),
-            // 报告预览
-            Expanded(child: _buildReportPreview()),
-          ],
+          ),
+        ),
+        // 底部阴影
+        Positioned(
+          left: 0,
+          right: 0,
+          bottom: 0,
+          child: Container(
+            child: Assets.images.bgIntimacyAnalyseReportPreviewMask.image(
+              height: 126,
+            ),
+          ),
         ),
         // 解锁按钮
         Positioned.fill(
@@ -92,97 +109,6 @@ class IntimacyAnalyseReportView
     );
   }
 
-  /// 报告预览布局-顶部布局-包含:图标和标题
-  Widget _buildReportPreviewTopLayout() {
-    return Row(
-      children: [
-        Assets.images.iconIntimacyAnalyseReportPreviewLove.image(
-          width: 50,
-          height: 48,
-        ),
-        Assets.images.iconIntimacyAnalyseReportPreviewTitle.image(
-          width: 178,
-          height: 24,
-        ),
-      ],
-    );
-  }
-
-  /// 报告预览
-  Widget _buildReportPreview() {
-    return Obx(() {
-      // 卡片背景
-      return Stack(
-        // 让大小,撑满父组件
-        fit: StackFit.expand,
-        children: [
-          // 中间内容
-          Container(
-            margin: EdgeInsets.only(left: 12, right: 12, bottom: 0),
-            padding: EdgeInsets.only(bottom: 12),
-            decoration: BoxDecoration(
-              image: DecorationImage(
-                image: Assets.images.bgIntimacyAnalyseReportPreview.provider(),
-                fit: BoxFit.fill,
-              ),
-            ),
-            // 圆角背景
-            child: Stack(
-              children: [
-                // 图标和标题
-                _buildReportPreviewTopLayout(),
-                Container(
-                  margin: EdgeInsets.only(
-                    top: 51,
-                    left: 12,
-                    right: 12,
-                    bottom: 5,
-                  ),
-                  decoration: ShapeDecoration(
-                    color: ColorName.white,
-                    shape: RoundedRectangleBorder(
-                      borderRadius: BorderRadius.circular(20.r),
-                    ),
-                  ),
-                  child: Padding(
-                    padding: const EdgeInsets.only(
-                      left: 14,
-                      right: 14,
-                      bottom: 90,
-                    ),
-                    // 内容
-                    child: Stack(
-                      // 撑满父组件
-                      fit: StackFit.expand,
-                      children: [
-                        MarkdownViewer(
-                          content: controller.reportPreviewData.value,
-                          // 允许滚动
-                          enableContentScroll: true,
-                        ),
-                      ],
-                    ),
-                  ),
-                ),
-              ],
-            ),
-          ),
-          // 底部阴影
-          Positioned(
-            left: 0,
-            right: 0,
-            bottom: 0,
-            child: Container(
-              child: Assets.images.bgIntimacyAnalyseReportPreviewMask.image(
-                height: 126,
-              ),
-            ),
-          ),
-        ],
-      );
-    });
-  }
-
   /// 底部布局
   Widget _buildBottomLayout(BuildContext context) {
     return Column(

+ 21 - 21
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_controller.dart

@@ -31,29 +31,29 @@ class IntimacyAnalyseUploadController extends BaseController {
   /// 是否上传页
   RxBool isUploadPage = false.obs;
 
-  // /// 报告的markdown数据
-  // RxString reportMarkdownData =
-  //     '''
-  // **性格匹配度**
-  //
-  // ● 互补型:一方外向活泼,另一方沉稳内敛,形成动态平衡。
-  // ● 相似型:三观一致,兴趣重叠,减少摩擦但需警惕新鲜感流失。
-  // ● 关键结论:差异是火花的来源,但核心价值观需一致(如家庭观、金钱观)。
-  //
-  // **沟通模式分析**
-  //
-  // ● 语言风格:幽默调侃型 vs 理性分析型 → 需找到共同表达方式。
-  // ● 冲突解决:回避型 vs 直面型 → 建议建立“冷静-沟通”机制。
-  // ● 情感需求:一方需要高频互动,另一方偏好独立空间 → 需协商平衡点。
-  //
-  // **爱情语言测试**
-  //
-  // ● 根据盖瑞·查普曼的“五种爱之语”理论,分析双方的情感表达偏好:
-  // ● 你的主要爱语:肯定的言辞(如情话、鼓励)
-  // '''.obs;
+  /// 报告的markdown数据
+  RxString reportMarkdownData =
+      '''
+  **性格匹配度**
+
+  ● 互补型:一方外向活泼,另一方沉稳内敛,形成动态平衡。
+  ● 相似型:三观一致,兴趣重叠,减少摩擦但需警惕新鲜感流失。
+  ● 关键结论:差异是火花的来源,但核心价值观需一致(如家庭观、金钱观)。
+
+  **沟通模式分析**
+
+  ● 语言风格:幽默调侃型 vs 理性分析型 → 需找到共同表达方式。
+  ● 冲突解决:回避型 vs 直面型 → 建议建立“冷静-沟通”机制。
+  ● 情感需求:一方需要高频互动,另一方偏好独立空间 → 需协商平衡点。
+
+  **爱情语言测试**
+
+  ● 根据盖瑞·查普曼的“五种爱之语”理论,分析双方的情感表达偏好:
+  ● 你的主要爱语:肯定的言辞(如情话、鼓励)
+  '''.obs;
 
   // TODO hezihao,测试报告生成中
-  RxString reportMarkdownData = "".obs;
+  // RxString reportMarkdownData = "".obs;
 
   /// 报告是否已解锁
   Rx<bool> isReportUnlock = true.obs;

+ 0 - 1
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_page.dart

@@ -210,7 +210,6 @@ class IntimacyAnalyseUploadPage
       ),
       contentWidget: Column(
         children: [
-          SizedBox(height: 14.h),
           // 图片九宫格
           Container(
             margin: EdgeInsets.only(left: 12.w, right: 12.w),

+ 46 - 2
lib/module/intimacy_analyse/widget/intimacy_analyse_report_widget.dart

@@ -16,14 +16,23 @@ class IntimacyAnalyseReportWidget extends StatelessWidget {
   /// 是否已解锁
   final bool unlock;
 
+  /// 是否是预览
+  final bool isPreview;
+
   const IntimacyAnalyseReportWidget({
     super.key,
     required this.reportContent,
-    required this.unlock,
+    this.unlock = false,
+    this.isPreview = false,
   });
 
   @override
   Widget build(BuildContext context) {
+    if (isPreview) {
+      return PreviewReportCardWidget(
+        previewReportContent: reportContent,
+      );
+    }
     // 未解锁
     if (!unlock) {
       return UnlockReportCardWidget();
@@ -36,6 +45,42 @@ class IntimacyAnalyseReportWidget extends StatelessWidget {
   }
 }
 
+/// 预览报告卡片
+class PreviewReportCardWidget extends StatelessWidget {
+  final String previewReportContent;
+
+  const PreviewReportCardWidget({
+    super.key,
+    required this.previewReportContent,
+  });
+
+  @override
+  Widget build(BuildContext context) {
+    return ReportCardFrameWidget(
+      child: Column(
+        mainAxisSize: MainAxisSize.min,
+        children: [
+          SizedBox(height: 10.h),
+          Container(
+            decoration: ShapeDecoration(
+              color: ColorName.white,
+              shape: RoundedRectangleBorder(
+                borderRadius: BorderRadius.circular(30.r),
+              ),
+            ),
+            child: MarkdownViewer(
+              // 内容
+              content: previewReportContent,
+              // 不允许滚动
+              enableContentScroll: false,
+            ),
+          ),
+        ],
+      ),
+    );
+  }
+}
+
 /// 已有报告组件
 class ExistReportCardWidget extends StatelessWidget {
   /// 报告内容,Markdown格式
@@ -303,7 +348,6 @@ class ExistReportCardWidget extends StatelessWidget {
   /// 报告详情
   Widget _buildReportDetail() {
     return Container(
-      height: 424.h,
       decoration: ShapeDecoration(
         color: ColorName.white,
         shape: RoundedRectangleBorder(