Jelajahi Sumber

[feat]亲密度分析,抽取卡片标题组件

hezihao 7 bulan lalu
induk
melakukan
899ee2c8b2

+ 17 - 13
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_page.dart

@@ -132,12 +132,14 @@ class IntimacyAnalyseUploadPage
   /// 上传步骤卡片
   Widget _buildUploadStepCard() {
     return UploadStepCard(
-      stepLabel: StringFormatUtil.formatStr(
-        StringName.intimacyAnalyseStep,
-        1.toString(),
+      topTitleWidget: StepTitleWidget(
+        stepLabel: StringFormatUtil.formatStr(
+          StringName.intimacyAnalyseStep,
+          1.toString(),
+        ),
+        stepTitle: StringName.intimacyAnalyseStepTitleSelectImage,
+        stepDesc: StringName.intimacyAnalyseUploadCardTip,
       ),
-      stepTitle: StringName.intimacyAnalyseStepTitleSelectImage,
-      stepDesc: StringName.intimacyAnalyseUploadCardTip,
       // 底部,添加上当前的亲密关系
       bottomChild: _buildRecommendIntimacy(),
     );
@@ -147,12 +149,14 @@ class IntimacyAnalyseUploadPage
   Widget _buildPredictionDirectionStepCard() {
     return StepCard(
       bgImageProvider: Assets.images.bgIntimacyAnalyseNormalCard.provider(),
-      stepLabel: StringFormatUtil.formatStr(
-        StringName.intimacyAnalyseStep,
-        2.toString(),
+      topTitleWidget: StepTitleWidget(
+        stepLabel: StringFormatUtil.formatStr(
+          StringName.intimacyAnalyseStep,
+          2.toString(),
+        ),
+        stepTitle: StringName.intimacyAnalyseStepTitleSelectPredictionDirection,
+        stepDesc: StringName.intimacyAnalysePredictionDirectionCardTip,
       ),
-      stepTitle: StringName.intimacyAnalyseStepTitleSelectPredictionDirection,
-      stepDesc: StringName.intimacyAnalysePredictionDirectionCardTip,
       contentWidget: Column(
         children: [
           Container(
@@ -190,9 +194,9 @@ class IntimacyAnalyseUploadPage
   Widget _buildAnalysisResultCard() {
     return StepCard(
       bgImageProvider: Assets.images.bgIntimacyAnalyseUploadCard.provider(),
-      stepLabel: "",
-      stepTitle: StringName.intimacyAnalyseAnalysisResult,
-      stepDesc: "",
+      topTitleWidget: StepTitleWidget(
+        stepTitle: StringName.intimacyAnalyseAnalysisResult,
+      ),
       topIconWidget: Assets.images.iconIntimacyAnalysisResultTop.image(
         height: 63.h,
         width: 103.w,

+ 12 - 10
lib/module/intimacy_analyse/screenshot_reply/conversation_analysis/conversation_analysis_view.dart

@@ -88,8 +88,10 @@ class ConversationAnalysisView
   /// 上传步骤卡片
   Widget _buildUploadCard() {
     return UploadStepCard(
-      stepTitle: StringName.intimacyConversationAnalysis,
-      stepDesc: StringName.intimacyConversationAnalysisCardTip,
+      topTitleWidget: StepTitleWidget(
+        stepTitle: StringName.intimacyConversationAnalysis,
+        stepDesc: StringName.intimacyConversationAnalysisCardTip,
+      ),
     );
   }
 
@@ -101,10 +103,7 @@ class ConversationAnalysisView
       // 圆角背景
       decoration: BoxDecoration(
         gradient: LinearGradient(
-          colors: [
-            Color(0xFFEFE9FF),
-            Color(0xFFFBFAFF),
-          ],
+          colors: [Color(0xFFEFE9FF), Color(0xFFFBFAFF)],
           begin: Alignment.topCenter,
           end: Alignment.bottomRight,
         ),
@@ -169,7 +168,9 @@ class ConversationAnalysisView
   Widget _buildAnalysisResultCard() {
     return StepCard(
       bgImageProvider: Assets.images.bgIntimacyAnalyseUploadCard.provider(),
-      stepTitle: StringName.intimacyAnalyseAnalysisResult,
+      topTitleWidget: StepTitleWidget(
+        stepTitle: StringName.intimacyAnalyseAnalysisResult,
+      ),
       topIconWidget: Assets.images.iconIntimacyAnalysisResultTop.image(
         height: 63.h,
         width: 103.w,
@@ -289,9 +290,10 @@ class ConversationAnalysisView
   Widget _buildChatRecordSampleCard() {
     return StepCard(
       bgImageProvider: Assets.images.bgIntimacyAnalyseUploadCard.provider(),
-      stepLabel: "",
-      stepTitle: StringName.intimacyConversationAnalysis,
-      stepDesc: StringName.intimacyConversationAnalysisCardTip,
+      topTitleWidget: StepTitleWidget(
+        stepTitle: StringName.intimacyConversationAnalysis,
+        stepDesc: StringName.intimacyConversationAnalysisCardTip,
+      ),
       topIconWidget: Assets.images.iconIntimacyAnalyseUploadTop.image(
         height: 63.h,
         width: 103.w,

+ 4 - 3
lib/module/intimacy_analyse/screenshot_reply/scan_image_reply/scan_image_reply_view.dart

@@ -138,9 +138,10 @@ class ScanImageReplyView extends BaseView<ScanImageReplyController> {
 
     return StepCard(
       bgImageProvider: Assets.images.bgIntimacyAnalyseUploadCard.provider(),
-      stepLabel: "",
-      stepTitle: StringName.intimacyUploadScreenshot,
-      stepDesc: StringName.intimacyAnalyseUploadScreenshotCardTip,
+      topTitleWidget: StepTitleWidget(
+        stepTitle: StringName.intimacyUploadScreenshot,
+        stepDesc: StringName.intimacyAnalyseUploadScreenshotCardTip,
+      ),
       topIconWidget: Assets.images.iconIntimacyAnalyseUploadTop.image(
         height: 63.h,
         width: 103.w,

+ 4 - 14
lib/module/intimacy_analyse/widget/step/upload_step_card.dart

@@ -8,23 +8,15 @@ import '../step_card.dart';
 
 /// 上传步骤卡片
 class UploadStepCard extends StatelessWidget {
-  /// 步骤标签
-  final String? stepLabel;
-
-  /// 步骤标题
-  final String? stepTitle;
-
-  /// 步骤描述
-  final String? stepDesc;
+  /// 顶部标题区域的组件
+  final Widget? topTitleWidget;
 
   /// 底部的子组件,可以没有
   final Widget? bottomChild;
 
   const UploadStepCard({
     super.key,
-    this.stepLabel,
-    required this.stepTitle,
-    required this.stepDesc,
+    this.topTitleWidget,
     this.bottomChild,
   });
 
@@ -32,9 +24,7 @@ class UploadStepCard extends StatelessWidget {
   Widget build(BuildContext context) {
     return StepCard(
       bgImageProvider: Assets.images.bgIntimacyAnalyseUploadCard.provider(),
-      stepLabel: stepLabel,
-      stepTitle: stepTitle,
-      stepDesc: stepDesc,
+      topTitleWidget: topTitleWidget,
       // 顶部的图标
       topIconWidget: Assets.images.iconIntimacyAnalyseUploadTop.image(
         height: 63.h,

+ 43 - 57
lib/module/intimacy_analyse/widget/step_card.dart

@@ -7,58 +7,27 @@ import '../intimacy_analyse_upload/widget/step_label_widget.dart';
 /// 步骤卡片,支持设置卡片背景、步骤标题、步骤描述、顶部图标和内容区域
 class StepCard extends StatelessWidget {
   /// 卡片背景
-  final ImageProvider? bgImageProvider;
+  final ImageProvider bgImageProvider;
 
-  /// 步骤标签
-  final String? stepLabel;
-
-  /// 步骤标题
-  final String? stepTitle;
+  /// 顶部标题区域的组件
+  final Widget? topTitleWidget;
 
-  /// 步骤描述
-  final String? stepDesc;
-
-  /// 顶部图标
+  /// 顶部图标组件
   final Image? topIconWidget;
 
   /// 内容组件
   final Widget contentWidget;
 
-  /// 是否有步骤
-  final bool hasStep;
-
   const StepCard({
     super.key,
-    this.bgImageProvider,
-    this.stepLabel,
-    this.stepTitle,
-    this.stepDesc,
-    this.hasStep = true,
+    required this.bgImageProvider,
+    this.topTitleWidget,
     required this.contentWidget,
     this.topIconWidget,
   });
 
   @override
   Widget build(BuildContext context) {
-    BoxDecoration decoration;
-    // 没有背景图,使用渐变背景
-    if (bgImageProvider == null) {
-      decoration = BoxDecoration(
-        gradient: LinearGradient(
-          colors: [Color(0xFFEFE9FF), Color(0xFFFBFAFF)],
-          begin: Alignment.topCenter,
-          end: Alignment.bottomRight,
-        ),
-        shape: BoxShape.rectangle,
-        border: Border.all(color: ColorName.white80, width: 1.w),
-        borderRadius: BorderRadius.all(Radius.circular(20.r)),
-      );
-    } else {
-      // 背景图
-      decoration = BoxDecoration(
-        image: DecorationImage(image: bgImageProvider!, fit: BoxFit.fill),
-      );
-    }
     return Container(
       margin: EdgeInsets.only(left: 12.w, top: 10.h, right: 12.w),
       child: Stack(
@@ -71,12 +40,27 @@ class StepCard extends StatelessWidget {
               : Positioned(top: -11.h, right: 0, child: topIconWidget!),
           // 卡片背景
           Container(
-            decoration: decoration,
+            // 渐变背景
+            // decoration: BoxDecoration(
+            //   gradient: LinearGradient(
+            //     colors: [Color(0xFFEFE9FF), Color(0xFFFBFAFF)],
+            //     begin: Alignment.topCenter,
+            //     end: Alignment.bottomRight,
+            //   ),
+            //   shape: BoxShape.rectangle,
+            //   border: Border.all(color: ColorName.white80, width: 1.w),
+            //   borderRadius: BorderRadius.all(Radius.circular(20.r)),
+            // ),
+            // 卡片背景
+            decoration: BoxDecoration(
+              image: DecorationImage(image: bgImageProvider!, fit: BoxFit.fill),
+            ),
             child: Column(
               // 左对齐
               crossAxisAlignment: CrossAxisAlignment.start,
               children: [
-                _buildStepLayout(),
+                // 顶部标题区域
+                topTitleWidget != null ? topTitleWidget! : SizedBox(),
                 // 内容区域
                 contentWidget,
                 SizedBox(height: 12.h),
@@ -87,15 +71,29 @@ class StepCard extends StatelessWidget {
       ),
     );
   }
+}
 
-  /// 步骤
-  Widget _buildStepLayout() {
-    if (!hasStep) {
-      return SizedBox();
-    }
+/// 步骤标题组件
+class StepTitleWidget extends StatelessWidget {
+  /// 步骤标签
+  final String? stepLabel;
 
-    String stepDescStr = stepDesc ?? "";
+  /// 步骤标题
+  final String? stepTitle;
+
+  /// 步骤描述
+  final String? stepDesc;
 
+  const StepTitleWidget({
+    super.key,
+    this.stepLabel,
+    this.stepTitle,
+    this.stepDesc,
+  });
+
+  @override
+  Widget build(BuildContext context) {
+    String stepDescStr = stepDesc ?? "";
     return Column(
       children: [
         // 步骤标题
@@ -124,18 +122,6 @@ class StepCard extends StatelessWidget {
     return stepLabelStr.isNotEmpty == true;
   }
 
-  /// 是否有步骤标题
-  bool _hasStepTitle() {
-    String stepTitleStr = stepTitle ?? "";
-    return stepTitleStr.isNotEmpty == true;
-  }
-
-  /// 是否有步骤标题
-  bool _hasStepDesc() {
-    String stepDescStr = stepDesc ?? "";
-    return stepDescStr.isNotEmpty == true;
-  }
-
   /// 步骤标题
   Widget _buildStepTitle() {
     String stepTitleStr = stepTitle ?? "";