按钮添加splash

null_safety
小赖 4 years ago
parent 33b2dd8457
commit ca7a004c1b

@ -16,20 +16,20 @@ class _ExampleButtonState extends State<ExampleButton> {
title: 'Button', title: 'Button',
body: ListView( body: ListView(
children: [ children: [
ASButton.delete( ASButton.danger(
title: '删除订单', title: '危险按钮',
onPressed: () {}, onPressed: () {},
), ),
ASButton.info( ASButton.info(
title: '删除订单', title: '提示按钮',
onPressed: () {}, onPressed: () {},
), ),
ASButton.warn( ASButton.warn(
title: '删除订单', title: '警告按钮',
onPressed: () {}, onPressed: () {},
), ),
ASButton.opration( ASButton.operation(
title: '删除订单', title: '操作按钮',
onPressed: () {}, onPressed: () {},
), ),
SizedBox(height: 12.w), SizedBox(height: 12.w),
@ -51,7 +51,7 @@ class _ExampleButtonState extends State<ExampleButton> {
title: '支付', title: '支付',
onPressed: () {}, onPressed: () {},
), ),
ASButton.delete( ASButton.danger(
title: '删除', title: '删除',
onPressed: () {}, onPressed: () {},
), ),

@ -1,3 +1,4 @@
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -40,6 +41,8 @@ class ASButton extends StatefulWidget {
/// ///
final Color disableTextColor; final Color disableTextColor;
final Color splashColor;
ASButton({ ASButton({
Key key, Key key,
this.bgcolor, this.bgcolor,
@ -54,10 +57,11 @@ class ASButton extends StatefulWidget {
this.width, this.width,
this.disableColor, this.disableColor,
this.disableTextColor, this.disableTextColor,
this.splashColor,
}) : super(key: key); }) : super(key: key);
ASButton.warn( ASButton.danger({
{Key key, Key key,
this.textStyle, this.textStyle,
this.padding, this.padding,
this.radius, this.radius,
@ -66,10 +70,11 @@ class ASButton extends StatefulWidget {
@required this.title, @required this.title,
this.width, this.width,
this.disableColor, this.disableColor,
this.disableTextColor}) this.disableTextColor,
: outline = true, }) : outline = true,
outlineColor = Color(0xFFE50112), outlineColor = kDangerColor,
textColor = Color(0xFFE50112), textColor = kDangerColor,
splashColor = kDangerColor.withOpacity(0.2),
super(key: key); super(key: key);
ASButton.info( ASButton.info(
@ -82,13 +87,14 @@ class ASButton extends StatefulWidget {
this.onPressed, this.onPressed,
this.width, this.width,
this.disableColor, this.disableColor,
this.disableTextColor}) this.disableTextColor,
this.splashColor})
: outline = true, : outline = true,
outlineColor = Color(0x73000000), outlineColor = Color(0x73000000),
textColor = Color(0xD9000000), textColor = Color(0xD9000000),
super(key: key); super(key: key);
ASButton.delete( ASButton.warn(
{Key key, {Key key,
this.radius, this.radius,
this.outlineColor, this.outlineColor,
@ -98,12 +104,13 @@ class ASButton extends StatefulWidget {
this.onPressed, this.onPressed,
this.width, this.width,
this.disableColor, this.disableColor,
this.disableTextColor}) this.disableTextColor,
this.splashColor})
: bgcolor = Color(0xFFFFB600), : bgcolor = Color(0xFFFFB600),
textColor = Color(0xD9FFFFFF), textColor = Color(0xD9FFFFFF),
outline = false, outline = false,
super(key: key); super(key: key);
ASButton.opration( ASButton.operation(
{Key key, {Key key,
this.radius, this.radius,
this.outlineColor, this.outlineColor,
@ -113,7 +120,8 @@ class ASButton extends StatefulWidget {
this.onPressed, this.onPressed,
this.width, this.width,
this.disableColor, this.disableColor,
this.disableTextColor}) this.disableTextColor,
this.splashColor})
: bgcolor = Color(0xFFF2F2F2), : bgcolor = Color(0xFFF2F2F2),
textColor = Color(0xD9000000), textColor = Color(0xD9000000),
outline = false, outline = false,
@ -124,6 +132,7 @@ class ASButton extends StatefulWidget {
this.onPressed, this.onPressed,
this.outlineColor, this.outlineColor,
this.width, this.width,
this.splashColor,
}) : bgcolor = Color(0xFFFFBD32), }) : bgcolor = Color(0xFFFFBD32),
textColor = Color(0xFF0000000), textColor = Color(0xFF0000000),
textStyle = TextStyle(fontSize: 14.sp, fontWeight: FontWeight.bold), textStyle = TextStyle(fontSize: 14.sp, fontWeight: FontWeight.bold),
@ -158,7 +167,9 @@ class _ASButtonState extends State<ASButton> {
? BorderSide(color: widget.outlineColor, width: 0.5.w) ? BorderSide(color: widget.outlineColor, width: 0.5.w)
: BorderSide.none, : BorderSide.none,
borderRadius: BorderRadius.circular(widget.radius ?? 15.5.w)), 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, elevation: 0,
focusElevation: 0, focusElevation: 0,
highlightElevation: 0, highlightElevation: 0,

@ -17,3 +17,6 @@ const Color kForegroundColor = Color(0xFFFFFFFF);
/// ///
const Color kBackgroundColor = Color(0xFFF6F6F6); const Color kBackgroundColor = Color(0xFFF6F6F6);
///
const Color kDangerColor = Color(0xFFE50112);

Loading…
Cancel
Save