2023-07-10 17:50:31 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
|
|
|
|
import '../app_settings/app_colors.dart';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 提交按钮 公用组件
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
class SubmitBtn extends StatelessWidget {
|
2024-06-03 13:50:07 +08:00
|
|
|
SubmitBtn({
|
2025-03-20 17:54:14 +08:00
|
|
|
required this.btnName,
|
|
|
|
|
Key? key,
|
2024-06-03 13:50:07 +08:00
|
|
|
this.borderRadius,
|
|
|
|
|
this.color,
|
|
|
|
|
this.padding,
|
|
|
|
|
this.onClick,
|
|
|
|
|
this.margin,
|
|
|
|
|
this.width,
|
|
|
|
|
this.backgroundColorList,
|
|
|
|
|
this.isDelete,
|
|
|
|
|
this.fontSize,
|
|
|
|
|
this.isDisabled,
|
|
|
|
|
}) : super(key: key);
|
2023-07-15 15:11:28 +08:00
|
|
|
String? btnName;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
Function()? onClick;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
EdgeInsetsGeometry? margin;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
EdgeInsetsGeometry? padding;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
double? width;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
double? fontSize;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
Color? color;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
List<Color>? backgroundColorList;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-15 15:11:28 +08:00
|
|
|
double? borderRadius;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2023-07-27 15:26:30 +08:00
|
|
|
bool? isDelete;
|
|
|
|
|
|
2023-07-29 09:25:21 +08:00
|
|
|
bool? isDisabled;
|
2024-04-30 09:51:12 +08:00
|
|
|
|
2023-07-10 17:50:31 +08:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2024-04-30 09:51:12 +08:00
|
|
|
return Container(
|
2023-07-26 09:23:25 +08:00
|
|
|
width: ScreenUtil().screenWidth - 40.w,
|
2025-03-20 17:54:14 +08:00
|
|
|
constraints: BoxConstraints(
|
|
|
|
|
minHeight: 60.h, // 设置最小高度
|
|
|
|
|
),
|
2023-07-26 09:23:25 +08:00
|
|
|
child: ElevatedButton(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
2023-07-29 17:04:03 +08:00
|
|
|
backgroundColor: isDisabled == false
|
2023-08-07 10:32:24 +08:00
|
|
|
? AppColors.btnDisableColor
|
2023-07-29 17:04:03 +08:00
|
|
|
: (isDelete == true ? Colors.red : AppColors.mainColor),
|
2023-07-26 09:23:25 +08:00
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (onClick != null) {
|
|
|
|
|
onClick!();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
btnName!,
|
2025-03-20 17:54:14 +08:00
|
|
|
textAlign: TextAlign.center, // 文本居中对齐
|
|
|
|
|
softWrap: true, // 允许换行
|
|
|
|
|
overflow: TextOverflow.visible, // 文本溢出时显示
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
fontSize: 24.sp,
|
|
|
|
|
height: 1.2, // 行高
|
|
|
|
|
),
|
2023-07-26 09:23:25 +08:00
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
/*
|
2023-07-10 17:50:31 +08:00
|
|
|
return GestureDetector(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: width??690.w,
|
|
|
|
|
padding: padding??EdgeInsets.only(
|
|
|
|
|
top: 20.w,
|
|
|
|
|
bottom: 20.w
|
|
|
|
|
),
|
|
|
|
|
margin: margin??EdgeInsets.only(top: 30.w),
|
2023-07-26 09:23:25 +08:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(borderRadius ?? 10.w),
|
|
|
|
|
gradient: LinearGradient(
|
2023-07-10 17:50:31 +08:00
|
|
|
begin: Alignment.centerLeft,
|
|
|
|
|
end: Alignment.centerRight,
|
2023-07-26 09:23:25 +08:00
|
|
|
colors: backgroundColorList ??
|
|
|
|
|
[
|
|
|
|
|
AppColors.mainColor,
|
|
|
|
|
AppColors.mainColor,
|
|
|
|
|
],
|
|
|
|
|
)),
|
2023-07-10 17:50:31 +08:00
|
|
|
child: Center(
|
2023-07-26 09:23:25 +08:00
|
|
|
child: Text(btnName!,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: fontSize ?? 30.sp,
|
|
|
|
|
height: 1.3,
|
|
|
|
|
decoration: TextDecoration.none,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
color: color ?? Colors.white)),
|
2023-07-10 17:50:31 +08:00
|
|
|
),
|
|
|
|
|
),
|
2023-07-26 09:23:25 +08:00
|
|
|
onTap: () {
|
|
|
|
|
if (onClick != null) {
|
2023-07-15 15:11:28 +08:00
|
|
|
onClick!();
|
2023-07-10 17:50:31 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
2023-07-26 09:23:25 +08:00
|
|
|
*/
|
2023-07-10 17:50:31 +08:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-29 17:04:03 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 底部添加白色按钮 公用组件
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
class AddBottomWhiteBtn extends StatelessWidget {
|
|
|
|
|
AddBottomWhiteBtn({
|
2025-03-20 17:54:14 +08:00
|
|
|
required this.btnName,
|
|
|
|
|
Key? key,
|
2023-07-29 17:04:03 +08:00
|
|
|
this.onClick,
|
|
|
|
|
}) : super(key: key);
|
2024-06-03 13:50:07 +08:00
|
|
|
String? btnName;
|
|
|
|
|
|
|
|
|
|
Function()? onClick;
|
2023-07-29 17:04:03 +08:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 90.h,
|
|
|
|
|
margin: EdgeInsets.only(left: 20.w, right: 20.w),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white, borderRadius: BorderRadius.circular(8.w)),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Image.asset(
|
|
|
|
|
'images/icon_btn_add.png',
|
|
|
|
|
width: 28.w,
|
|
|
|
|
height: 28.w,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 6.w,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
btnName!,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: AppColors.mainColor,
|
|
|
|
|
fontSize: 24.sp,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onTap: () {
|
|
|
|
|
if (onClick != null) {
|
|
|
|
|
onClick!();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-17 18:54:19 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 边框按钮 公用组件
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
class OutLineBtn extends StatelessWidget {
|
|
|
|
|
OutLineBtn({
|
2025-03-20 17:54:14 +08:00
|
|
|
required this.btnName,
|
|
|
|
|
Key? key,
|
2023-08-17 18:54:19 +08:00
|
|
|
this.onClick,
|
|
|
|
|
}) : super(key: key);
|
2024-06-03 13:50:07 +08:00
|
|
|
String? btnName;
|
|
|
|
|
|
|
|
|
|
Function()? onClick;
|
2023-08-17 18:54:19 +08:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: ScreenUtil().screenWidth - 40.w,
|
|
|
|
|
height: 60.h,
|
|
|
|
|
child: OutlinedButton(
|
|
|
|
|
style: OutlinedButton.styleFrom(
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (onClick != null) {
|
|
|
|
|
onClick!();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
btnName!,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: AppColors.mainColor, fontSize: ScreenUtil().setSp(24)),
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|