|
|
@@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
import '../resource/assets.gen.dart';
|
|
|
import '../resource/colors.gen.dart';
|
|
|
+import '../resource/string.gen.dart';
|
|
|
|
|
|
/// 渐变色按钮
|
|
|
class GradientBtn extends StatelessWidget {
|
|
|
@@ -20,6 +21,9 @@ class GradientBtn extends StatelessWidget {
|
|
|
/// 按钮圆角半径
|
|
|
final double radius;
|
|
|
|
|
|
+ /// 内边距
|
|
|
+ final EdgeInsetsGeometry? padding;
|
|
|
+
|
|
|
/// 子组件
|
|
|
final Widget child;
|
|
|
|
|
|
@@ -33,6 +37,7 @@ class GradientBtn extends StatelessWidget {
|
|
|
this.begin = Alignment.centerLeft,
|
|
|
this.end = Alignment.centerRight,
|
|
|
this.radius = 50,
|
|
|
+ this.padding = const EdgeInsets.symmetric(vertical: 14),
|
|
|
required this.child,
|
|
|
required this.onPressed,
|
|
|
});
|
|
|
@@ -60,7 +65,7 @@ class GradientBtn extends StatelessWidget {
|
|
|
onPressed();
|
|
|
},
|
|
|
child: Container(
|
|
|
- padding: EdgeInsets.symmetric(vertical: 14.h),
|
|
|
+ padding: padding,
|
|
|
width: double.maxFinite,
|
|
|
// 渐变背景
|
|
|
decoration: decoration,
|
|
|
@@ -78,6 +83,9 @@ class GradientTextBtn extends StatelessWidget {
|
|
|
/// 按钮文字
|
|
|
final String text;
|
|
|
|
|
|
+ /// 描述文字
|
|
|
+ final String? desc;
|
|
|
+
|
|
|
/// 纯色颜色
|
|
|
final Color? color;
|
|
|
|
|
|
@@ -91,45 +99,99 @@ class GradientTextBtn extends StatelessWidget {
|
|
|
/// 按钮圆角半径
|
|
|
final double radius;
|
|
|
|
|
|
+ /// 内边距
|
|
|
+ final EdgeInsetsGeometry? padding;
|
|
|
+
|
|
|
/// 点击回调
|
|
|
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(
|
|
|
this.text, {
|
|
|
super.key,
|
|
|
this.leftIcon,
|
|
|
+ this.desc,
|
|
|
this.color,
|
|
|
this.colors = const [ColorName.purpleGradient3, ColorName.purpleGradient4],
|
|
|
this.begin = Alignment.centerLeft,
|
|
|
this.end = Alignment.centerRight,
|
|
|
this.radius = 50,
|
|
|
+ this.padding = const EdgeInsets.symmetric(vertical: 14),
|
|
|
required this.onPressed,
|
|
|
});
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
+ String descStr = desc ?? "";
|
|
|
return GradientBtn(
|
|
|
color: color,
|
|
|
colors: colors,
|
|
|
radius: radius,
|
|
|
onPressed: onPressed,
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ padding: padding,
|
|
|
+ child: Column(
|
|
|
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(
|
|
|
- visible: leftIcon != null,
|
|
|
+ visible: descStr.isNotEmpty,
|
|
|
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,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
],
|