You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansu_ui/lib/buttons/as_long_button.dart

117 lines
2.8 KiB

4 years ago
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ansu_ui/styles/as_colors.dart';
class ASLongButton extends StatelessWidget {
///按钮文字
///动态类型可以是string或者widget
final dynamic title;
///按钮背景颜色
final Color? bgColor;
///按钮文字颜色
///若已定义文字风格则此属性不生效
final Color? textColor;
///圆角
final double? radius;
///按钮文字风格
final TextStyle? textStyle;
///内边距
final EdgeInsetsGeometry? padding;
///是否有边框
final bool outline;
///边框颜色
final Color? outlineColor;
///点击事件
final VoidCallback? onPressed;
4 years ago
///宽度
final double? width;
4 years ago
4 years ago
///不可点击颜色
final Color? disableColor;
4 years ago
///不可点击文字颜色
final Color? disableTextColor;
4 years ago
ASLongButton(
{Key? key,
required this.title,
this.bgColor,
this.textColor,
this.radius,
this.textStyle,
this.padding,
this.outline = false,
this.outlineColor,
this.onPressed,
4 years ago
this.width,
this.disableColor,
this.disableTextColor})
: super(key: key);
4 years ago
ASLongButton.solid({
Key? key,
this.textStyle,
this.padding,
this.outlineColor,
this.radius,
required this.title,
this.onPressed,
4 years ago
this.width,
4 years ago
this.disableTextColor,
4 years ago
this.bgColor = kPrimaryColor,
}) : textColor = kLightTextColor,
outline = false,
4 years ago
disableColor = Color(0xFFC1BDB5),
super(key: key);
4 years ago
ASLongButton.hollow(
{Key? key,
4 years ago
this.radius,
this.textStyle,
this.padding,
this.onPressed,
required this.title,
4 years ago
this.width,
this.disableColor,
this.disableTextColor})
4 years ago
: bgColor = kForegroundColor,
textColor = kDarkPrimaryColor,
outline = true,
4 years ago
outlineColor = kDarkPrimaryColor,
super(key: key);
4 years ago
@override
Widget build(BuildContext context) {
return MaterialButton(
minWidth: width ?? 280.w,
disabledColor: disableColor,
textColor: textColor ?? kLightTextColor,
disabledTextColor: disableTextColor,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: onPressed,
child: title is String
? Text(title, style: textStyle ?? TextStyle(fontSize: 20.sp))
: title,
padding:
padding as EdgeInsetsGeometry? ?? EdgeInsets.symmetric(vertical: 8.w),
shape: RoundedRectangleBorder(
side: outline
? BorderSide(color: outlineColor!, width: 1.w)
: BorderSide.none,
borderRadius: BorderRadius.circular(radius ?? 22.5.w)),
color: bgColor ?? kForegroundColor,
elevation: 0,
4 years ago
highlightElevation: 0,
splashColor: ColorTool.getSplashColor(bgColor),
);
}
}