Browse Source

[feat]亲密度分析,渐变色按钮,支持描述文字,封装带锁图标的按钮

hezihao 7 months ago
parent
commit
b6c88ba79b

+ 1 - 7
lib/module/intimacy_analyse/analyse_report/intimacy_analyse_report_view.dart

@@ -172,13 +172,7 @@ class IntimacyAnalyseReportView
     return Container(
     return Container(
       margin: EdgeInsets.symmetric(horizontal: 16.w),
       margin: EdgeInsets.symmetric(horizontal: 16.w),
       width: double.maxFinite,
       width: double.maxFinite,
-      child: GradientTextBtn(
-        StringName.intimacyUnlockAnalyse,
-        color: ColorName.colorBrand,
-        leftIcon: Assets.images.iconIntimacyAnalyseUnlock.image(
-          width: 22,
-          height: 22,
-        ),
+      child: GradientTextBtn.withUnlock(
         onPressed: () {
         onPressed: () {
           controller.clickUnlockBtn(context);
           controller.clickUnlockBtn(context);
         },
         },

+ 6 - 33
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_page.dart

@@ -701,40 +701,13 @@ class IntimacyAnalyseUploadPage
   Widget _buildAnalyseBtn() {
   Widget _buildAnalyseBtn() {
     return Container(
     return Container(
       padding: EdgeInsets.only(top: 7.h, bottom: 6.h),
       padding: EdgeInsets.only(top: 7.h, bottom: 6.h),
-      decoration: BoxDecoration(
+      child: GradientTextBtn.withUnlock(
+        text: StringName.intimacyAnalyseAnalysisNow,
         color: ColorName.colorBrand,
         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,
-            ),
-          ),
-        ],
+        desc: StringName.intimacyAnalyseAnalysisUseAiTip,
+        radius: 30.r,
+        padding: EdgeInsets.symmetric(vertical: 7.h),
+        onPressed: () {},
       ),
       ),
     );
     );
   }
   }

+ 1 - 6
lib/module/intimacy_analyse/screenshot_reply/conversation_analysis/conversation_analysis_view.dart

@@ -376,12 +376,7 @@ class ConversationAnalysisView
     return Container(
     return Container(
       margin: EdgeInsets.symmetric(horizontal: 16.w),
       margin: EdgeInsets.symmetric(horizontal: 16.w),
       width: double.maxFinite,
       width: double.maxFinite,
-      child: GradientTextBtn(
-        StringName.intimacyUnlockAnalyse,
-        leftIcon: Assets.images.iconIntimacyAnalyseUnlock.image(
-          width: 22,
-          height: 22,
-        ),
+      child: GradientTextBtn.withUnlock(
         onPressed: () {
         onPressed: () {
           controller.clickUnlockBtn(context);
           controller.clickUnlockBtn(context);
         },
         },

+ 77 - 15
lib/widget/gradient_btn.dart

@@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
 
 
 import '../resource/assets.gen.dart';
 import '../resource/assets.gen.dart';
 import '../resource/colors.gen.dart';
 import '../resource/colors.gen.dart';
+import '../resource/string.gen.dart';
 
 
 /// 渐变色按钮
 /// 渐变色按钮
 class GradientBtn extends StatelessWidget {
 class GradientBtn extends StatelessWidget {
@@ -20,6 +21,9 @@ class GradientBtn extends StatelessWidget {
   /// 按钮圆角半径
   /// 按钮圆角半径
   final double radius;
   final double radius;
 
 
+  /// 内边距
+  final EdgeInsetsGeometry? padding;
+
   /// 子组件
   /// 子组件
   final Widget child;
   final Widget child;
 
 
@@ -33,6 +37,7 @@ class GradientBtn extends StatelessWidget {
     this.begin = Alignment.centerLeft,
     this.begin = Alignment.centerLeft,
     this.end = Alignment.centerRight,
     this.end = Alignment.centerRight,
     this.radius = 50,
     this.radius = 50,
+    this.padding = const EdgeInsets.symmetric(vertical: 14),
     required this.child,
     required this.child,
     required this.onPressed,
     required this.onPressed,
   });
   });
@@ -60,7 +65,7 @@ class GradientBtn extends StatelessWidget {
         onPressed();
         onPressed();
       },
       },
       child: Container(
       child: Container(
-        padding: EdgeInsets.symmetric(vertical: 14.h),
+        padding: padding,
         width: double.maxFinite,
         width: double.maxFinite,
         // 渐变背景
         // 渐变背景
         decoration: decoration,
         decoration: decoration,
@@ -78,6 +83,9 @@ class GradientTextBtn extends StatelessWidget {
   /// 按钮文字
   /// 按钮文字
   final String text;
   final String text;
 
 
+  /// 描述文字
+  final String? desc;
+
   /// 纯色颜色
   /// 纯色颜色
   final Color? color;
   final Color? color;
 
 
@@ -91,45 +99,99 @@ class GradientTextBtn extends StatelessWidget {
   /// 按钮圆角半径
   /// 按钮圆角半径
   final double radius;
   final double radius;
 
 
+  /// 内边距
+  final EdgeInsetsGeometry? padding;
+
   /// 点击回调
   /// 点击回调
   final VoidCallback onPressed;
   final VoidCallback onPressed;
 
 
+  /// 操作按钮,带解锁按钮
+  static GradientTextBtn withUnlock({
+    String? text,
+    Color? color,
+    String? desc,
+    double radius = 50,
+    EdgeInsetsGeometry? padding = const EdgeInsets.symmetric(vertical: 14),
+    required VoidCallback onPressed,
+  }) {
+    String btnText = text ?? "";
+    if (btnText.isEmpty) {
+      btnText = StringName.intimacyUnlockAnalyse;
+    }
+    return GradientTextBtn(
+      btnText,
+      desc: desc,
+      color: color ?? ColorName.colorBrand,
+      leftIcon: Assets.images.iconIntimacyAnalyseUnlock.image(
+        width: 22,
+        height: 22,
+      ),
+      radius: radius,
+      padding: padding,
+      onPressed: onPressed,
+    );
+  }
+
   const GradientTextBtn(
   const GradientTextBtn(
     this.text, {
     this.text, {
     super.key,
     super.key,
     this.leftIcon,
     this.leftIcon,
+    this.desc,
     this.color,
     this.color,
     this.colors = const [ColorName.purpleGradient3, ColorName.purpleGradient4],
     this.colors = const [ColorName.purpleGradient3, ColorName.purpleGradient4],
     this.begin = Alignment.centerLeft,
     this.begin = Alignment.centerLeft,
     this.end = Alignment.centerRight,
     this.end = Alignment.centerRight,
     this.radius = 50,
     this.radius = 50,
+    this.padding = const EdgeInsets.symmetric(vertical: 14),
     required this.onPressed,
     required this.onPressed,
   });
   });
 
 
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
+    String descStr = desc ?? "";
     return GradientBtn(
     return GradientBtn(
       color: color,
       color: color,
       colors: colors,
       colors: colors,
       radius: radius,
       radius: radius,
       onPressed: onPressed,
       onPressed: onPressed,
-      child: Row(
-        mainAxisAlignment: MainAxisAlignment.center,
+      padding: padding,
+      child: Column(
         children: [
         children: [
-          // 左侧图标
+          Row(
+            mainAxisAlignment: MainAxisAlignment.center,
+            children: [
+              // 左侧图标
+              Visibility(
+                visible: leftIcon != null,
+                child: Container(
+                  margin: EdgeInsets.only(right: 4.w),
+                  child: leftIcon,
+                ),
+              ),
+              // 文字
+              Text(
+                text,
+                style: TextStyle(
+                  color: ColorName.white,
+                  fontSize: 16.sp,
+                  fontWeight: FontWeight.bold,
+                ),
+              ),
+            ],
+          ),
+          // 描述
           Visibility(
           Visibility(
-            visible: leftIcon != null,
+            visible: descStr.isNotEmpty,
             child: Container(
             child: Container(
-              margin: EdgeInsets.only(right: 4.w),
-              child: leftIcon,
-            ),
-          ),
-          Text(
-            text,
-            style: TextStyle(
-              color: ColorName.white,
-              fontSize: 16.sp,
-              fontWeight: FontWeight.bold,
+              margin: EdgeInsets.only(top: 3.h),
+              child: Text(
+                descStr,
+                style: TextStyle(
+                  color: ColorName.white,
+                  fontSize: 10.sp,
+                  fontWeight: FontWeight.w400,
+                ),
+              ),
             ),
             ),
           ),
           ),
         ],
         ],