Merge branch 'master' of 192.168.2.201:laiiihz/ansu_ui

* 'master' of 192.168.2.201:laiiihz/ansu_ui:
  按钮修改
  添加渐变按钮
  添加渐变按钮

# Conflicts:
#	example/lib/example_button.dart
#	example/lib/main.dart
null_safety
小赖 4 years ago
commit fecf4c449b

@ -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 {
@ -17,33 +18,65 @@ class _ExampleButtonState extends State<ExampleButton> {
children: [
ASButton.delete(
title: '删除订单',
onpressed: () {},
onPressed: () {},
),
ASButton.info(
title: '删除订单',
onpressed: () {},
onPressed: () {},
),
ASButton.warn(
title: '删除订单',
onpressed: () {},
onPressed: () {},
),
ASButton.opration(
title: '删除订单',
onpressed: () {},
onPressed: () {},
),
SizedBox(height: 12.w),
ASLongButton.solid(
title: '确认',
onpressed: () {},
onPressed: () {},
),
ASLongButton.hollow(
title: '确认',
onpressed: () {},
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: () {},
),
],
),
ASLongButton.hollow(
title: '确认',
onPressed: () {},
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 100.w),
child: ASLongButton.solid(title: 'null', onPressed: () {}),
),
Row(
children: [
ASButton.order(
title: '立即下单',
onPressed: () {},
)
],
)
],
),
);

@ -1,6 +1,5 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class ExampleScaffold extends StatefulWidget {
ExampleScaffold({Key key}) : super(key: key);

@ -45,15 +45,8 @@ class _MyHomePageState extends State<MyHomePage> {
body: ListView(
padding: EdgeInsets.all(16.w),
children: [
ASButton.info(
title: 'Button', onpressed: () => Get.to(ExampleButton())),
ASButton.info(
title: 'Scaffold', onpressed: () => Get.to(ExampleScaffold())),
ASButton.info(
title: 'TabBar', onpressed: () => Get.to(ExampleTabBar())),
ASButton.info(
title: '数量选择器 NumericButton',
onpressed: () => Get.to(ExampleNumericButton())),
ASButton.info(title:'Button',onPressed: () => Get.to(ExampleButton())),
ASButton.info(title:'Scaffold', onPressed:() => Get.to(ExampleScaffold())),
],
),
);

@ -30,10 +30,16 @@ class ASButton extends StatefulWidget {
final EdgeInsets padding;
///
final VoidCallback onpressed;
final VoidCallback onPressed;
///
final double width;
///
final Color disableColor;
///
final Color disableTextColor;
ASButton({
Key key,
this.bgcolor,
@ -44,8 +50,10 @@ class ASButton extends StatefulWidget {
this.textStyle,
this.padding,
@required this.title,
this.onpressed,
this.onPressed,
this.width,
this.disableColor,
this.disableTextColor,
}) : super(key: key);
ASButton.warn(
@ -54,9 +62,11 @@ class ASButton extends StatefulWidget {
this.padding,
this.radius,
this.bgcolor,
this.onpressed,
this.onPressed,
@required this.title,
this.width})
this.width,
this.disableColor,
this.disableTextColor})
: outline = true,
outlineColor = Color(0xFFE50112),
textColor = Color(0xFFE50112),
@ -69,8 +79,10 @@ class ASButton extends StatefulWidget {
this.textStyle,
this.padding,
@required this.title,
this.onpressed,
this.width})
this.onPressed,
this.width,
this.disableColor,
this.disableTextColor})
: outline = true,
outlineColor = Color(0x73000000),
textColor = Color(0xD9000000),
@ -83,8 +95,10 @@ class ASButton extends StatefulWidget {
this.textStyle,
this.padding,
@required this.title,
this.onpressed,
this.width})
this.onPressed,
this.width,
this.disableColor,
this.disableTextColor})
: bgcolor = Color(0xFFFFB600),
textColor = Color(0xD9FFFFFF),
outline = false,
@ -96,12 +110,31 @@ class ASButton extends StatefulWidget {
this.textStyle,
this.padding,
@required this.title,
this.onpressed,
this.width})
this.onPressed,
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,14 +144,16 @@ 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,
onPressed: widget.onPressed,
child: widget.title is String
? 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,
);
}
}

@ -0,0 +1,126 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASGradientButton extends StatefulWidget {
///
///stringwidget
final dynamic title;
///
///
final Color textColor;
///
final double radius;
///
final TextStyle textStyle;
///
final EdgeInsetsGeometry padding;
///
final VoidCallback onPressed;
///
final List<Color> colors;
///
final AlignmentGeometry begin;
///
final AlignmentGeometry end;
///
final double width;
///
final Color disableColor;
///
final Color disableTextColor;
ASGradientButton(
{Key key,
@required this.title,
this.textColor,
this.radius,
this.textStyle,
this.padding,
this.onPressed,
this.colors,
this.width,
this.begin,
this.end,
this.disableColor,
this.disableTextColor})
: super(key: key);
ASGradientButton.pay({
Key key,
@required this.title,
this.textStyle,
this.onPressed,
this.disableColor,
this.disableTextColor,
}) : textColor = Color(0xD9FFFFFF),
radius = 19.w,
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
_ASGradientButtonState createState() => _ASGradientButtonState();
}
class _ASGradientButtonState extends State<ASGradientButton> {
@override
Widget build(BuildContext context) {
return Container(
width: widget.width ?? 110.w,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: widget.begin ?? Alignment.centerLeft,
end: widget.end ?? Alignment.centerRight,
colors: widget.colors ?? [Color(0xFFFFA700), Color(0xFFFFBD00)],
),
borderRadius: BorderRadius.circular(widget.radius ?? 20.w),
),
child: MaterialButton(
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(fontSize: 18.sp))
: widget.title,
padding: widget.padding ?? EdgeInsets.symmetric(vertical: 10.w),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(widget.radius ?? 20.w)),
elevation: 0,
),
);
}
}

@ -29,11 +29,17 @@ class ASLongButton extends StatefulWidget {
final Color outlineColor;
///
final VoidCallback onpressed;
final VoidCallback onPressed;
///
final double width;
///
final Color disableColor;
///
final Color disableTextColor;
ASLongButton(
{Key key,
@required this.title,
@ -44,8 +50,10 @@ class ASLongButton extends StatefulWidget {
this.padding,
this.outline = false,
this.outlineColor,
this.onpressed,
this.width})
this.onPressed,
this.width,
this.disableColor,
this.disableTextColor})
: super(key: key);
ASLongButton.solid({
@ -55,20 +63,24 @@ class ASLongButton extends StatefulWidget {
this.outlineColor,
this.radius,
@required this.title,
this.onpressed,
this.onPressed,
this.width,
this.disableTextColor,
}) : bgColor = Color(0xFFF6B72D),
textColor = Color(0xFFFFFFFF),
outline = false,
disableColor = Color(0xFFC1BDB5),
super(key: key);
ASLongButton.hollow(
{Key key,
this.radius,
this.textStyle,
this.padding,
this.onpressed,
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,
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