Bladeren bron

[feat]亲密度分析,报告卡片,增加生成中布局

hezihao 7 maanden geleden
bovenliggende
commit
450c08679e

BIN
assets/images/icon_intimacy_analysis_report_creating.webp


+ 3 - 0
assets/string/base/string.xml

@@ -245,6 +245,9 @@
     <string name="intimacy_analyse_model">模型</string>
 
     <string name="intimacy_analyse_analysis_result">分析结果</string>
+    <string name="intimacy_analyse_analysis_now">立即分析</string>
+    <string name="intimacy_analyse_report_creating">报告生成中...</string>
+    <string name="intimacy_analyse_analysis_use_ai_tip">报告内容由AI大数据解读,请勿作为决策依据</string>
 
     <string name="my_self">自己</string>
     <string name="and">与</string>

+ 12 - 12
lib/di/get_it.config.dart

@@ -73,12 +73,24 @@ extension GetItInjectableX on _i174.GetIt {
     final networkModule = _$NetworkModule();
     gh.factory<_i256.AboutController>(() => _i256.AboutController());
     gh.factory<_i923.BrowserController>(() => _i923.BrowserController());
+    gh.factory<_i1057.ChangeBirthdayController>(
+      () => _i1057.ChangeBirthdayController(),
+    );
+    gh.factory<_i315.ChangeGenderController>(
+      () => _i315.ChangeGenderController(),
+    );
+    gh.factory<_i859.ChangeNicknameController>(
+      () => _i859.ChangeNicknameController(),
+    );
     gh.factory<_i987.IntimacyAnalyseReportController>(
       () => _i987.IntimacyAnalyseReportController(),
     );
     gh.factory<_i977.IntimacyAnalyseController>(
       () => _i977.IntimacyAnalyseController(),
     );
+    gh.factory<_i666.IntimacyAnalyseUploadController>(
+      () => _i666.IntimacyAnalyseUploadController(),
+    );
     gh.factory<_i279.IntimacyAnalyseScreenshotReplyController>(
       () => _i279.IntimacyAnalyseScreenshotReplyController(),
     );
@@ -91,18 +103,6 @@ extension GetItInjectableX on _i174.GetIt {
     gh.factory<_i415.KeyboardMethodHandler>(
       () => _i415.KeyboardMethodHandler(),
     );
-    gh.factory<_i666.IntimacyAnalyseUploadController>(
-      () => _i666.IntimacyAnalyseUploadController(),
-    );
-    gh.factory<_i1057.ChangeBirthdayController>(
-      () => _i1057.ChangeBirthdayController(),
-    );
-    gh.factory<_i315.ChangeGenderController>(
-      () => _i315.ChangeGenderController(),
-    );
-    gh.factory<_i859.ChangeNicknameController>(
-      () => _i859.ChangeNicknameController(),
-    );
     gh.singleton<_i361.Dio>(
       () => networkModule.createStreamDio(),
       instanceName: 'streamDio',

+ 0 - 19
lib/module/intimacy_analyse/analyse_report/intimacy_analyse_report_view_controller.dart

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

+ 23 - 0
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_controller.dart

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

+ 112 - 22
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_page.dart

@@ -17,6 +17,7 @@ import '../../../router/app_pages.dart';
 import '../../../utils/string_format_util.dart';
 import '../../../widget/actionbtn/action_btn.dart';
 import '../../../widget/gradient_text.dart';
+import '../widget/intimacy_analyse_report_widget.dart';
 import '../widget/intimacy_user_widget.dart';
 import '../widget/option_select_widget.dart';
 import '../widget/step_card.dart';
@@ -254,9 +255,9 @@ class IntimacyAnalyseUploadPage
               children: [
                 // 预测方向
                 _buildDirectionResult(),
-                SizedBox(width: 12.w,),
+                SizedBox(width: 12.w),
                 // 模型
-                _buildAiModelResult()
+                _buildAiModelResult(),
               ],
             ),
           ),
@@ -265,6 +266,18 @@ class IntimacyAnalyseUploadPage
     );
   }
 
+  /// 分析报告
+  Widget _buildAnalysisReport() {
+    return Column(
+      children: [
+        SizedBox(height: 12.h),
+        IntimacyAnalyseReportWidget(
+          reportContent: controller.reportMarkdownData.value,
+        ),
+      ],
+    );
+  }
+
   /// 预测方向结果
   Widget _buildDirectionResult() {
     return Expanded(
@@ -544,14 +557,34 @@ class IntimacyAnalyseUploadPage
 
   /// 底部操作按钮
   Widget _buildBottomActionBtn() {
-    return Container(
-      width: double.maxFinite,
-      margin: EdgeInsets.only(left: 13.w, top: 8.h, right: 13.w, bottom: 20.h),
-      child: ActionBtn(
-        leftBtn: _buildAiModelSwitchBtn(),
-        rightBtn: _buildNextBtn(),
-      ),
-    );
+    if (controller.isUploadPage.value) {
+      // 上传页
+      return Container(
+        width: double.maxFinite,
+        margin: EdgeInsets.only(
+          left: 13.w,
+          top: 8.h,
+          right: 13.w,
+          bottom: 20.h,
+        ),
+        child: ActionBtn(
+          leftBtn: _buildAiModelSwitchBtn(),
+          rightBtn: _buildNextBtn(),
+        ),
+      );
+    } else {
+      // 结果页
+      return Container(
+        width: double.maxFinite,
+        margin: EdgeInsets.only(
+          left: 13.w,
+          top: 8.h,
+          right: 13.w,
+          bottom: 20.h,
+        ),
+        child: _buildAnalyseBtn(),
+      );
+    }
   }
 
   /// Ai模型切换按钮
@@ -649,24 +682,81 @@ class IntimacyAnalyseUploadPage
     );
   }
 
+  /// 分析按钮
+  Widget _buildAnalyseBtn() {
+    return Container(
+      padding: EdgeInsets.only(top: 7.h, bottom: 6.h),
+      decoration: BoxDecoration(
+        color: ColorName.colorBrand,
+        borderRadius: BorderRadius.all(Radius.circular(30.r)),
+      ),
+      child: Column(
+        children: [
+          // 标题
+          Row(
+            mainAxisAlignment: MainAxisAlignment.center,
+            crossAxisAlignment: CrossAxisAlignment.center,
+            children: [
+              Assets.images.iconLock.image(width: 22.w, height: 22.h),
+              SizedBox(width: 2.w),
+              Text(
+                StringName.intimacyAnalyseAnalysisNow,
+                style: TextStyle(
+                  color: ColorName.white,
+                  fontSize: 16.sp,
+                  fontWeight: FontWeight.w500,
+                ),
+              ),
+            ],
+          ),
+          SizedBox(height: 3.h),
+          // 描述
+          Text(
+            StringName.intimacyAnalyseAnalysisUseAiTip,
+            style: TextStyle(
+              color: ColorName.white,
+              fontSize: 10.sp,
+              fontWeight: FontWeight.w400,
+            ),
+          ),
+        ],
+      ),
+    );
+  }
+
+  /// 构建卡片列表
+  Widget _buildCardList() {
+    // 上传页
+    if (controller.isUploadPage.value) {
+      return Column(
+        children: [
+          // 上传卡片
+          _buildUploadStepCard(),
+          // 预测方向卡片
+          _buildPredictionDirectionStepCard(),
+        ],
+      );
+    } else {
+      // 报告页
+      return Column(
+        children: [
+          // 分析结果卡片
+          _buildAnalysisResultCard(),
+          // 报告结果卡片
+          _buildAnalysisReport(),
+        ],
+      );
+    }
+  }
+
   /// 内容
   Widget _buildContent() {
     return Expanded(
       child: Stack(
         children: [
-          // 长列表
+          // 卡片列表
           SingleChildScrollView(
-            child: Column(
-              children: [
-                // 上传卡片
-                _buildUploadStepCard(),
-                // 分析结果卡片
-                _buildAnalysisResultCard(),
-                // 预测方向卡片
-                _buildPredictionDirectionStepCard(),
-                SizedBox(height: 80.h),
-              ],
-            ),
+            child: Column(children: [_buildCardList(), SizedBox(height: 80.h)]),
           ),
           // 底部操作按钮
           Positioned(

+ 63 - 78
lib/module/intimacy_analyse/widget/intimacy_analyse_report_widget.dart

@@ -1,5 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:keyboard/resource/string.gen.dart';
 
 import '../../../resource/assets.gen.dart';
 import '../../../resource/colors.gen.dart';
@@ -15,90 +16,41 @@ class IntimacyAnalyseReportWidget extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     // 卡片背景
-    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,
-                    top: 20,
-                    bottom: 14,
-                  ),
-                  // 内容
-                  child: Container(
-                    color: Colors.red,
-                    height: 424.h,
-                    child: LayoutBuilder(
-                      builder: (
-                        BuildContext context,
-                        BoxConstraints constraints,
-                      ) {
-                        return SingleChildScrollView(
-                          physics: BouncingScrollPhysics(),
-                          // 渲染Markdown
-                          child: ConstrainedBox(
-                            constraints: BoxConstraints(
-                              // 确保最小高度
-                              minHeight: constraints.maxHeight,
-                            ),
-                            child: MarkdownViewer(content: reportContent),
-                          ),
-                        );
-                      },
-                    ),
-                  ),
-                ),
-              ),
-            ],
-          ),
+    return Container(
+      height: 424.h,
+      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,
         ),
-        // 底部阴影
-        Positioned(
-          left: 0,
-          right: 0,
-          bottom: 0,
-          child: Container(
-            child: Assets.images.bgIntimacyAnalyseReportPreviewMask.image(
-              height: 126,
+      ),
+      child: Stack(
+        children: [
+          // 图标和标题
+          _buildReportTopLayout(),
+          // 内容
+          Container(
+            margin: EdgeInsets.only(top: 51, left: 12, right: 12, bottom: 5),
+            decoration: ShapeDecoration(
+              color: ColorName.white,
+              shape: RoundedRectangleBorder(
+                borderRadius: BorderRadius.circular(30.r),
+              ),
             ),
+            child:
+                reportContent.isEmpty
+                    ? _buildCreatingLayout()
+                    : _buildReportContentLayout(),
           ),
-        ),
-      ],
+        ],
+      ),
     );
   }
 
-  /// 报告预览布局-顶部布局-包含:图标和标题
-  Widget _buildReportPreviewTopLayout() {
+  /// 报告的顶部布局-包含:图标和标题
+  Widget _buildReportTopLayout() {
     return Row(
       children: [
         Assets.images.iconIntimacyAnalyseReportPreviewLove.image(
@@ -112,4 +64,37 @@ class IntimacyAnalyseReportWidget extends StatelessWidget {
       ],
     );
   }
+
+  /// 报告内容布局
+  Widget _buildReportContentLayout() {
+    return MarkdownViewer(content: reportContent);
+  }
+
+  /// 生成中布局
+  Widget _buildCreatingLayout() {
+    return Center(
+      child: Column(
+        // 垂直水平都居中
+        mainAxisAlignment: MainAxisAlignment.center,
+        crossAxisAlignment: CrossAxisAlignment.center,
+        children: [
+          // 图标
+          Assets.images.iconIntimacyAnalysisReportCreating.image(
+            width: 82,
+            height: 82,
+          ),
+          SizedBox(height: 3.h),
+          // 文字
+          Text(
+            StringName.intimacyAnalyseReportCreating,
+            style: TextStyle(
+              fontSize: 14.sp,
+              color: ColorName.black60,
+              fontWeight: FontWeight.w400,
+            ),
+          ),
+        ],
+      ),
+    );
+  }
 }

+ 6 - 0
lib/resource/assets.gen.dart

@@ -472,6 +472,11 @@ class $AssetsImagesGen {
     'assets/images/icon_intimacy_analyse_upload_top.webp',
   );
 
+  /// File path: assets/images/icon_intimacy_analysis_report_creating.webp
+  AssetGenImage get iconIntimacyAnalysisReportCreating => const AssetGenImage(
+    'assets/images/icon_intimacy_analysis_report_creating.webp',
+  );
+
   /// File path: assets/images/icon_intimacy_analysis_result_top.webp
   AssetGenImage get iconIntimacyAnalysisResultTop => const AssetGenImage(
     'assets/images/icon_intimacy_analysis_result_top.webp',
@@ -904,6 +909,7 @@ class $AssetsImagesGen {
     iconIntimacyAnalyseReportPreviewTitle,
     iconIntimacyAnalyseUnlock,
     iconIntimacyAnalyseUploadTop,
+    iconIntimacyAnalysisReportCreating,
     iconIntimacyAnalysisResultTop,
     iconKeyboardBanner,
     iconKeyboardBannerClose,

+ 6 - 0
lib/resource/string.gen.dart

@@ -178,6 +178,9 @@ class StringName {
   static final String intimacyAnalysePredictionDirection = 'intimacy_analyse_prediction_direction'.tr; // 预测方向
   static final String intimacyAnalyseModel = 'intimacy_analyse_model'.tr; // 模型
   static final String intimacyAnalyseAnalysisResult = 'intimacy_analyse_analysis_result'.tr; // 分析结果
+  static final String intimacyAnalyseAnalysisNow = 'intimacy_analyse_analysis_now'.tr; // 立即分析
+  static final String intimacyAnalyseReportCreating = 'intimacy_analyse_report_creating'.tr; // 报告生成中...
+  static final String intimacyAnalyseAnalysisUseAiTip = 'intimacy_analyse_analysis_use_ai_tip'.tr; // 报告内容由AI大数据解读,请勿作为决策依据
   static final String mySelf = 'my_self'.tr; // 自己
   static final String and = 'and'.tr; // 与
   static final String intimacyRelation = 'intimacy_relation'.tr; // 亲密关系
@@ -364,6 +367,9 @@ class StringMultiSource {
       'intimacy_analyse_prediction_direction': '预测方向',
       'intimacy_analyse_model': '模型',
       'intimacy_analyse_analysis_result': '分析结果',
+      'intimacy_analyse_analysis_now': '立即分析',
+      'intimacy_analyse_report_creating': '报告生成中...',
+      'intimacy_analyse_analysis_use_ai_tip': '报告内容由AI大数据解读,请勿作为决策依据',
       'my_self': '自己',
       'and': '与',
       'intimacy_relation': '亲密关系',