按钮修改

null_safety
张萌 4 years ago
parent 81e39621bc
commit 56c23c0c98

@ -1,4 +1,5 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:ansu_ui/buttons/as_gradientbutton.dart';
import 'package:flutter/material.dart';
class ExampleButton extends StatefulWidget {
@ -14,17 +15,60 @@ class _ExampleButtonState extends State<ExampleButton> {
return ASScaffold(
title: 'Button',
body: ListView(
children: [ ASButton.delete(title: '删除订单',onPressed: (){},),
ASButton.info(title: '删除订单',onPressed: (){},),
ASButton.warn(title: '删除订单',onPressed: (){},),
ASButton.opration(title: '删除订单',onPressed: (){},),
children: [
ASButton.delete(
title: '删除订单',
onPressed: () {},
),
ASButton.info(
title: '删除订单',
onPressed: () {},
),
ASButton.warn(
title: '删除订单',
onPressed: () {},
),
ASButton.opration(
title: '删除订单',
onPressed: () {},
),
SizedBox(height: 12.w),
ASLongButton.solid(title: '确认',onPressed: (){},),
ASLongButton.hollow(title: '确认',onPressed: (){},),
ASLongButton.solid(
title: '确认',
onPressed: () {},
),
ASLongButton.hollow(
title: '确认',
onPressed: () {},
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 100.w),
child: ASLongButton.solid(title: 'null',onPressed:(){} ),
child: ASLongButton.solid(title: 'null', onPressed: () {}),
),
Row(
children: [
ASGradientButton.pay(
title: '支付',
onPressed: () {},
),
ASButton.delete(
title: '删除',
onPressed: () {},
),
ASGradientButton.operation(
title: 'null',
onPressed: () {},
),
],
),
Row(
children: [
ASButton.order(
title: '立即下单',
onPressed: () {},
)
],
)
],
),
);

@ -34,6 +34,12 @@ class ASButton extends StatefulWidget {
///
final double width;
///
final Color disableColor;
///
final Color disableTextColor;
ASButton({
Key key,
this.bgcolor,
@ -46,6 +52,8 @@ class ASButton extends StatefulWidget {
@required this.title,
this.onPressed,
this.width,
this.disableColor,
this.disableTextColor,
}) : super(key: key);
ASButton.warn(
@ -56,7 +64,9 @@ class ASButton extends StatefulWidget {
this.bgcolor,
this.onPressed,
@required this.title,
this.width})
this.width,
this.disableColor,
this.disableTextColor})
: outline = true,
outlineColor = Color(0xFFE50112),
textColor = Color(0xFFE50112),
@ -70,7 +80,9 @@ class ASButton extends StatefulWidget {
this.padding,
@required this.title,
this.onPressed,
this.width})
this.width,
this.disableColor,
this.disableTextColor})
: outline = true,
outlineColor = Color(0x73000000),
textColor = Color(0xD9000000),
@ -84,7 +96,9 @@ class ASButton extends StatefulWidget {
this.padding,
@required this.title,
this.onPressed,
this.width})
this.width,
this.disableColor,
this.disableTextColor})
: bgcolor = Color(0xFFFFB600),
textColor = Color(0xD9FFFFFF),
outline = false,
@ -97,11 +111,30 @@ class ASButton extends StatefulWidget {
this.padding,
@required this.title,
this.onPressed,
this.width})
this.width,
this.disableColor,
this.disableTextColor})
: bgcolor = Color(0xFFF2F2F2),
textColor = Color(0xD9000000),
outline = false,
super(key: key);
ASButton.order({
Key key,
@required this.title,
this.onPressed,
this.outlineColor,
this.width,
}) : bgcolor = Color(0xFFFFBD32),
textColor=Color(0xFF0000000),
textStyle = TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold),
radius = 5.w,
outline = false,
disableColor = Color(0xFFFFDF9B),
disableTextColor = Color(0x73000000),
padding=EdgeInsets.symmetric(vertical: 8.w),
super(key: key);
@override
_ASButtonState createState() => _ASButtonState();
@ -111,6 +144,9 @@ class _ASButtonState extends State<ASButton> {
@override
Widget build(BuildContext context) {
return MaterialButton(
disabledColor: widget.disableColor ?? widget.bgcolor,
disabledTextColor: widget.disableTextColor ?? Color(0x73000000),
textColor: widget.textColor ?? Color(0xFFFFB600),
minWidth: widget.width ?? 75.w,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: widget.onPressed,
@ -118,7 +154,6 @@ class _ASButtonState extends State<ASButton> {
? Text(widget.title,
style: widget.textStyle ??
TextStyle(
color: widget.textColor ?? Color(0xFFFFB600),
fontSize: 13.sp))
: widget.title,
padding: widget.padding ?? EdgeInsets.symmetric(vertical: 6.w),
@ -129,6 +164,9 @@ class _ASButtonState extends State<ASButton> {
borderRadius: BorderRadius.circular(widget.radius ?? 15.5.w)),
color: widget.bgcolor ?? Color(0xFFFFFFFF),
elevation: 0,
focusElevation: 0,
highlightElevation: 0,
hoverElevation: 0,
);
}
}

@ -17,7 +17,7 @@ class ASGradientButton extends StatefulWidget {
final TextStyle textStyle;
///
final Padding padding;
final EdgeInsetsGeometry padding;
///
final VoidCallback onPressed;
@ -33,9 +33,15 @@ class ASGradientButton extends StatefulWidget {
///
final double width;
///
final Color disableColor;
///
final Color disableTextColor;
ASGradientButton(
{Key key,
this.title,
@required this.title,
this.textColor,
this.radius,
this.textStyle,
@ -44,20 +50,43 @@ class ASGradientButton extends StatefulWidget {
this.colors,
this.width,
this.begin,
this.end})
this.end,
this.disableColor,
this.disableTextColor})
: super(key: key);
ASGradientButton.pay({
Key key,
this.title,
@required this.title,
this.textStyle,
this.padding,
this.onPressed,
this.disableColor,
this.disableTextColor,
}) : textColor = Color(0xD9FFFFFF),
radius = 19.w,
colors = [Color(0xFFF89B14), Color(0xFFF86B140)],
colors = [Color(0xFFF89B14), Color(0xFFF86B14)],
width = 100.w,
begin = Alignment.centerLeft,
end = Alignment.centerRight,
padding = EdgeInsets.symmetric(vertical: 8.w),
super(key: key);
ASGradientButton.operation(
{Key key,
@required this.title,
this.textColor,
this.onPressed,
this.disableColor,
this.width,
this.radius,
this.begin,
this.end,
this.padding,
this.disableTextColor})
: textStyle = TextStyle(
color: Color(0xFFFFFFFF),
fontSize: 14.sp,
fontWeight: FontWeight.bold),
colors = [Color(0xFFFFA700), Color(0xFFFFBD00)],
super(key: key);
@override
@ -68,27 +97,28 @@ class _ASGradientButtonState extends State<ASGradientButton> {
@override
Widget build(BuildContext context) {
return Container(
width: widget.width ?? 100.w,
width: widget.width ?? 110.w,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: widget.begin ?? Alignment.centerLeft,
end: widget.end ?? Alignment.centerRight,
colors: widget.colors ?? [Color(0xFFF89B14), Color(0xFFF86B140)],
colors: widget.colors ?? [Color(0xFFFFA700), Color(0xFFFFBD00)],
),
borderRadius: BorderRadius.circular(widget.radius ?? 19.w),
borderRadius: BorderRadius.circular(widget.radius ?? 20.w),
),
child: MaterialButton(
minWidth: widget.width ?? 100.w,
disabledColor: widget.disableColor ?? Colors.grey,
textColor: widget.textColor ?? Color(0xD9FFFFFF),
disabledTextColor: widget.disableTextColor ?? Color(0x73000000),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: widget.onPressed,
child: widget.title is String
? Text(widget.title,
style: widget.textStyle ??
TextStyle(
color: widget.textColor ?? Color(0xD9FFFFFF),
fontSize: 18.sp))
style: widget.textStyle ?? TextStyle(fontSize: 18.sp))
: widget.title,
padding: widget.padding ?? EdgeInsets.symmetric(vertical: 8.w),
padding: widget.padding ?? EdgeInsets.symmetric(vertical: 10.w),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(widget.radius ?? 20.w)),
elevation: 0,
),
);

@ -34,6 +34,12 @@ class ASLongButton extends StatefulWidget {
///
final double width;
///
final Color disableColor;
///
final Color disableTextColor;
ASLongButton(
{Key key,
@required this.title,
@ -45,7 +51,9 @@ class ASLongButton extends StatefulWidget {
this.outline = false,
this.outlineColor,
this.onPressed,
this.width})
this.width,
this.disableColor,
this.disableTextColor})
: super(key: key);
ASLongButton.solid({
@ -57,9 +65,11 @@ class ASLongButton extends StatefulWidget {
@required this.title,
this.onPressed,
this.width,
this.disableTextColor,
}) : bgColor = Color(0xFFF6B72D),
textColor = Color(0xFFFFFFFF),
outline = false,
disableColor = Color(0xFFC1BDB5),
super(key: key);
ASLongButton.hollow(
{Key key,
@ -68,7 +78,9 @@ class ASLongButton extends StatefulWidget {
this.padding,
this.onPressed,
@required this.title,
this.width})
this.width,
this.disableColor,
this.disableTextColor})
: bgColor = Color(0xFFFFFFFF),
textColor = Color(0xFFF6B72D),
outline = true,
@ -83,15 +95,14 @@ class _ASLongButtonState extends State<ASLongButton> {
Widget build(BuildContext context) {
return MaterialButton(
minWidth: widget.width ?? 280.w,
disabledColor: Color(0xFFC1BDB5),
disabledColor: widget.disableColor ?? widget.bgColor,
textColor: widget.textColor ?? Color(0xFFFFFFFF),
disabledTextColor: widget.disableTextColor ?? Color(0x73000000),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: widget.onPressed,
child: widget.title is String
? Text(widget.title,
style: widget.textStyle ??
TextStyle(
color: widget.textColor ?? Color(0xFFFFFFFF),
fontSize: 20.sp))
style: widget.textStyle ?? TextStyle(fontSize: 20.sp))
: widget.title,
padding: widget.padding ?? EdgeInsets.symmetric(vertical: 8.w),
shape: RoundedRectangleBorder(
@ -101,6 +112,9 @@ class _ASLongButtonState extends State<ASLongButton> {
borderRadius: BorderRadius.circular(widget.radius ?? 22.5.w)),
color: widget.bgColor ?? Color(0xFFFFFFFF),
elevation: 0,
// // focusElevation: 0,
// // hoverElevation: 0,
highlightElevation: 0,
);
}
}

Loading…
Cancel
Save