From ca7a004c1b70189301cd040a6d2cb46fdad74e22 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 25 Nov 2020 09:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=B7=BB=E5=8A=A0splash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/example_button.dart | 14 ++++----- lib/buttons/as_button.dart | 51 ++++++++++++++++++++------------- lib/styles/as_colors.dart | 3 ++ 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/example/lib/example_button.dart b/example/lib/example_button.dart index 1687eb2..8db99bf 100644 --- a/example/lib/example_button.dart +++ b/example/lib/example_button.dart @@ -16,20 +16,20 @@ class _ExampleButtonState extends State { title: 'Button', body: ListView( children: [ - ASButton.delete( - title: '删除订单', + ASButton.danger( + title: '危险按钮', onPressed: () {}, ), ASButton.info( - title: '删除订单', + title: '提示按钮', onPressed: () {}, ), ASButton.warn( - title: '删除订单', + title: '警告按钮', onPressed: () {}, ), - ASButton.opration( - title: '删除订单', + ASButton.operation( + title: '操作按钮', onPressed: () {}, ), SizedBox(height: 12.w), @@ -51,7 +51,7 @@ class _ExampleButtonState extends State { title: '支付', onPressed: () {}, ), - ASButton.delete( + ASButton.danger( title: '删除', onPressed: () {}, ), diff --git a/lib/buttons/as_button.dart b/lib/buttons/as_button.dart index 3c0d252..1aeba66 100644 --- a/lib/buttons/as_button.dart +++ b/lib/buttons/as_button.dart @@ -1,3 +1,4 @@ +import 'package:ansu_ui/styles/as_colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -40,6 +41,8 @@ class ASButton extends StatefulWidget { ///不可点击时文字颜色 final Color disableTextColor; + + final Color splashColor; ASButton({ Key key, this.bgcolor, @@ -54,22 +57,24 @@ class ASButton extends StatefulWidget { this.width, this.disableColor, this.disableTextColor, + this.splashColor, }) : super(key: key); - ASButton.warn( - {Key key, - this.textStyle, - this.padding, - this.radius, - this.bgcolor, - this.onPressed, - @required this.title, - this.width, - this.disableColor, - this.disableTextColor}) - : outline = true, - outlineColor = Color(0xFFE50112), - textColor = Color(0xFFE50112), + ASButton.danger({ + Key key, + this.textStyle, + this.padding, + this.radius, + this.bgcolor, + this.onPressed, + @required this.title, + this.width, + this.disableColor, + this.disableTextColor, + }) : outline = true, + outlineColor = kDangerColor, + textColor = kDangerColor, + splashColor = kDangerColor.withOpacity(0.2), super(key: key); ASButton.info( @@ -82,13 +87,14 @@ class ASButton extends StatefulWidget { this.onPressed, this.width, this.disableColor, - this.disableTextColor}) + this.disableTextColor, + this.splashColor}) : outline = true, outlineColor = Color(0x73000000), textColor = Color(0xD9000000), super(key: key); - ASButton.delete( + ASButton.warn( {Key key, this.radius, this.outlineColor, @@ -98,12 +104,13 @@ class ASButton extends StatefulWidget { this.onPressed, this.width, this.disableColor, - this.disableTextColor}) + this.disableTextColor, + this.splashColor}) : bgcolor = Color(0xFFFFB600), textColor = Color(0xD9FFFFFF), outline = false, super(key: key); - ASButton.opration( + ASButton.operation( {Key key, this.radius, this.outlineColor, @@ -113,7 +120,8 @@ class ASButton extends StatefulWidget { this.onPressed, this.width, this.disableColor, - this.disableTextColor}) + this.disableTextColor, + this.splashColor}) : bgcolor = Color(0xFFF2F2F2), textColor = Color(0xD9000000), outline = false, @@ -124,6 +132,7 @@ class ASButton extends StatefulWidget { this.onPressed, this.outlineColor, this.width, + this.splashColor, }) : bgcolor = Color(0xFFFFBD32), textColor = Color(0xFF0000000), textStyle = TextStyle(fontSize: 14.sp, fontWeight: FontWeight.bold), @@ -158,7 +167,9 @@ class _ASButtonState extends State { ? BorderSide(color: widget.outlineColor, width: 0.5.w) : BorderSide.none, borderRadius: BorderRadius.circular(widget.radius ?? 15.5.w)), - color: widget.bgcolor ?? Color(0xFFFFFFFF), + color: widget.bgcolor ?? kForegroundColor, + splashColor: widget.splashColor, + highlightColor: widget.splashColor, elevation: 0, focusElevation: 0, highlightElevation: 0, diff --git a/lib/styles/as_colors.dart b/lib/styles/as_colors.dart index a287086..2b7c412 100644 --- a/lib/styles/as_colors.dart +++ b/lib/styles/as_colors.dart @@ -17,3 +17,6 @@ const Color kForegroundColor = Color(0xFFFFFFFF); ///背景色 const Color kBackgroundColor = Color(0xFFF6F6F6); + +///危险色 +const Color kDangerColor = Color(0xFFE50112);