import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../app_settings/app_colors.dart'; /* * 提交按钮 公用组件 * */ class SubmitBtn extends StatelessWidget { SubmitBtn({ required this.btnName, Key? key, this.borderRadius, this.color, this.padding, this.onClick, this.margin, this.width, this.backgroundColorList, this.isDelete, this.fontSize, this.isDisabled, }) : super(key: key); String? btnName; Function()? onClick; EdgeInsetsGeometry? margin; EdgeInsetsGeometry? padding; double? width; double? fontSize; Color? color; List? backgroundColorList; double? borderRadius; bool? isDelete; bool? isDisabled; @override Widget build(BuildContext context) { return Container( width: ScreenUtil().screenWidth - 40.w, constraints: BoxConstraints( minHeight: 60.h, // 设置最小高度 ), child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: isDisabled == false ? AppColors.btnDisableColor : (isDelete == true ? Colors.red : AppColors.mainColor), ), onPressed: () { if (onClick != null) { onClick!(); } }, child: Text( btnName!, textAlign: TextAlign.center, // 文本居中对齐 softWrap: true, // 允许换行 overflow: TextOverflow.visible, // 文本溢出时显示 style: TextStyle( color: Colors.white, fontSize: 24.sp, height: 1.2, // 行高 ), )), ); /* 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), decoration: BoxDecoration( borderRadius: BorderRadius.circular(borderRadius ?? 10.w), gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, colors: backgroundColorList ?? [ AppColors.mainColor, AppColors.mainColor, ], )), child: Center( child: Text(btnName!, style: TextStyle( fontSize: fontSize ?? 30.sp, height: 1.3, decoration: TextDecoration.none, fontWeight: FontWeight.w500, color: color ?? Colors.white)), ), ), onTap: () { if (onClick != null) { onClick!(); } }, ); */ } } /* * 底部添加白色按钮 公用组件 * */ class AddBottomWhiteBtn extends StatelessWidget { AddBottomWhiteBtn({ required this.btnName, Key? key, this.onClick, }) : super(key: key); String? btnName; Function()? onClick; @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!(); } }, ); } } /* * 边框按钮 公用组件 * */ class OutLineBtn extends StatelessWidget { OutLineBtn({ required this.btnName, Key? key, this.onClick, }) : super(key: key); String? btnName; Function()? onClick; @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)), )), ); } }