From bd07e09b4ae2a2e932bf7f841a6fee658a0585dc Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 24 Nov 2020 11:43:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B8=90=E5=8F=98?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/example_button.dart | 14 +++++++------- example/lib/example_scaffold.dart | 1 - example/lib/main.dart | 4 ++-- lib/buttons/as_button.dart | 14 +++++++------- lib/buttons/as_longbutton.dart | 10 +++++----- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/example/lib/example_button.dart b/example/lib/example_button.dart index 5c63dc7..43b82ec 100644 --- a/example/lib/example_button.dart +++ b/example/lib/example_button.dart @@ -14,16 +14,16 @@ class _ExampleButtonState extends State { 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:(){} ), ), ], ), diff --git a/example/lib/example_scaffold.dart b/example/lib/example_scaffold.dart index 072a3d7..ee5dd38 100644 --- a/example/lib/example_scaffold.dart +++ b/example/lib/example_scaffold.dart @@ -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); diff --git a/example/lib/main.dart b/example/lib/main.dart index e4431e8..051ebc0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -42,8 +42,8 @@ class _MyHomePageState extends State { title: '安速组件', body: ListView( children: [ - ASButton.info(title:'Button',onpressed: () => Get.to(ExampleButton())), - ASButton.info(title:'Scaffold', onpressed:() => Get.to(ExampleScaffold())), + ASButton.info(title:'Button',onPressed: () => Get.to(ExampleButton())), + ASButton.info(title:'Scaffold', onPressed:() => Get.to(ExampleScaffold())), ], ), ); diff --git a/lib/buttons/as_button.dart b/lib/buttons/as_button.dart index 7b0be49..e779b37 100644 --- a/lib/buttons/as_button.dart +++ b/lib/buttons/as_button.dart @@ -30,7 +30,7 @@ class ASButton extends StatefulWidget { final EdgeInsets padding; ///点击事件 - final VoidCallback onpressed; + final VoidCallback onPressed; ///宽度 final double width; @@ -44,7 +44,7 @@ class ASButton extends StatefulWidget { this.textStyle, this.padding, @required this.title, - this.onpressed, + this.onPressed, this.width, }) : super(key: key); @@ -54,7 +54,7 @@ class ASButton extends StatefulWidget { this.padding, this.radius, this.bgcolor, - this.onpressed, + this.onPressed, @required this.title, this.width}) : outline = true, @@ -69,7 +69,7 @@ class ASButton extends StatefulWidget { this.textStyle, this.padding, @required this.title, - this.onpressed, + this.onPressed, this.width}) : outline = true, outlineColor = Color(0x73000000), @@ -83,7 +83,7 @@ class ASButton extends StatefulWidget { this.textStyle, this.padding, @required this.title, - this.onpressed, + this.onPressed, this.width}) : bgcolor = Color(0xFFFFB600), textColor = Color(0xD9FFFFFF), @@ -96,7 +96,7 @@ class ASButton extends StatefulWidget { this.textStyle, this.padding, @required this.title, - this.onpressed, + this.onPressed, this.width}) : bgcolor = Color(0xFFF2F2F2), textColor = Color(0xD9000000), @@ -113,7 +113,7 @@ class _ASButtonState extends State { return MaterialButton( 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 ?? diff --git a/lib/buttons/as_longbutton.dart b/lib/buttons/as_longbutton.dart index a52b8ea..465af03 100644 --- a/lib/buttons/as_longbutton.dart +++ b/lib/buttons/as_longbutton.dart @@ -29,7 +29,7 @@ class ASLongButton extends StatefulWidget { final Color outlineColor; ///点击事件 - final VoidCallback onpressed; + final VoidCallback onPressed; ///宽度 final double width; @@ -44,7 +44,7 @@ class ASLongButton extends StatefulWidget { this.padding, this.outline = false, this.outlineColor, - this.onpressed, + this.onPressed, this.width}) : super(key: key); @@ -55,7 +55,7 @@ class ASLongButton extends StatefulWidget { this.outlineColor, this.radius, @required this.title, - this.onpressed, + this.onPressed, this.width, }) : bgColor = Color(0xFFF6B72D), textColor = Color(0xFFFFFFFF), @@ -66,7 +66,7 @@ class ASLongButton extends StatefulWidget { this.radius, this.textStyle, this.padding, - this.onpressed, + this.onPressed, @required this.title, this.width}) : bgColor = Color(0xFFFFFFFF), @@ -85,7 +85,7 @@ class _ASLongButtonState extends State { minWidth: widget.width ?? 280.w, disabledColor: Color(0xFFC1BDB5), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - onPressed: widget.onpressed, + onPressed: widget.onPressed, child: widget.title is String ? Text(widget.title, style: widget.textStyle ?? From 81e39621bcb96b6dc560b5348c6163dd488a05b1 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 24 Nov 2020 11:43:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B8=90=E5=8F=98?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/buttons/as_gradientbutton.dart | 96 ++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 lib/buttons/as_gradientbutton.dart diff --git a/lib/buttons/as_gradientbutton.dart b/lib/buttons/as_gradientbutton.dart new file mode 100644 index 0000000..a507c3a --- /dev/null +++ b/lib/buttons/as_gradientbutton.dart @@ -0,0 +1,96 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ASGradientButton extends StatefulWidget { + ///按钮文字 + ///动态类型,可以是string或者widget + final dynamic title; + + ///按钮文字颜色 + ///若已定义文字风格则此属性不生效 + final Color textColor; + + ///圆角 + final double radius; + + ///按钮文字风格 + final TextStyle textStyle; + + ///内边距 + final Padding padding; + + ///点击事件 + final VoidCallback onPressed; + + ///渐变颜色 + final List colors; + + ///开始位置 + final AlignmentGeometry begin; + + ///结束位置 + final AlignmentGeometry end; + + ///宽度 + final double width; + ASGradientButton( + {Key key, + this.title, + this.textColor, + this.radius, + this.textStyle, + this.padding, + this.onPressed, + this.colors, + this.width, + this.begin, + this.end}) + : super(key: key); + ASGradientButton.pay({ + Key key, + this.title, + this.textStyle, + this.padding, + this.onPressed, + }) : textColor = Color(0xD9FFFFFF), + radius = 19.w, + colors = [Color(0xFFF89B14), Color(0xFFF86B140)], + width = 100.w, + begin = Alignment.centerLeft, + end = Alignment.centerRight, + super(key: key); + + @override + _ASGradientButtonState createState() => _ASGradientButtonState(); +} + +class _ASGradientButtonState extends State { + @override + Widget build(BuildContext context) { + return Container( + width: widget.width ?? 100.w, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: widget.begin ?? Alignment.centerLeft, + end: widget.end ?? Alignment.centerRight, + colors: widget.colors ?? [Color(0xFFF89B14), Color(0xFFF86B140)], + ), + borderRadius: BorderRadius.circular(widget.radius ?? 19.w), + ), + child: MaterialButton( + minWidth: widget.width ?? 100.w, + 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)) + : widget.title, + padding: widget.padding ?? EdgeInsets.symmetric(vertical: 8.w), + elevation: 0, + ), + ); + } +} From 56c23c0c98440bf3a73ebda8429d4a5183b0ab14 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 24 Nov 2020 14:59:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/example_button.dart | 58 +++++++++++++++++++++++++---- lib/buttons/as_button.dart | 48 +++++++++++++++++++++--- lib/buttons/as_gradientbutton.dart | 60 ++++++++++++++++++++++-------- lib/buttons/as_longbutton.dart | 28 ++++++++++---- 4 files changed, 160 insertions(+), 34 deletions(-) diff --git a/example/lib/example_button.dart b/example/lib/example_button.dart index 43b82ec..8c014b5 100644 --- a/example/lib/example_button.dart +++ b/example/lib/example_button.dart @@ -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 { 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: () {}, + ) + ], + ) ], ), ); diff --git a/lib/buttons/as_button.dart b/lib/buttons/as_button.dart index e779b37..1d4ecc2 100644 --- a/lib/buttons/as_button.dart +++ b/lib/buttons/as_button.dart @@ -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 { @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 { ? 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 { borderRadius: BorderRadius.circular(widget.radius ?? 15.5.w)), color: widget.bgcolor ?? Color(0xFFFFFFFF), elevation: 0, + focusElevation: 0, + highlightElevation: 0, + hoverElevation: 0, ); } } diff --git a/lib/buttons/as_gradientbutton.dart b/lib/buttons/as_gradientbutton.dart index a507c3a..a0080dd 100644 --- a/lib/buttons/as_gradientbutton.dart +++ b/lib/buttons/as_gradientbutton.dart @@ -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 { @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, ), ); diff --git a/lib/buttons/as_longbutton.dart b/lib/buttons/as_longbutton.dart index 465af03..7f6454c 100644 --- a/lib/buttons/as_longbutton.dart +++ b/lib/buttons/as_longbutton.dart @@ -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 { 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 { borderRadius: BorderRadius.circular(widget.radius ?? 22.5.w)), color: widget.bgColor ?? Color(0xFFFFFFFF), elevation: 0, + // // focusElevation: 0, + // // hoverElevation: 0, + highlightElevation: 0, ); } }