Merge branch 'master' of 192.168.2.201:laiiihz/ansu_ui

* 'master' of 192.168.2.201:laiiihz/ansu_ui:
  小按钮组件,长按钮组件
null_safety
小赖 4 years ago
commit 3d27f334aa

@ -1,5 +1,6 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:ansu_ui/buttons/as_button.dart';
import 'package:ansu_ui/buttons/as_longbutton.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@ -45,7 +46,12 @@ class _MyHomePageState extends State<MyHomePage> {
body: ListView(
children: [
ASButton.delete('删除订单', () {}),
ASButton.info('删除订单', () {}),
ASButton.warn('删除订单', () {}),
ASButton.opration('删除订单', (){}),
SizedBox(height: 12.w),
ASLongButton.solid('确认', () {}),
ASLongButton.hollow('确认', () {}),
TextButton(
onPressed: () {
Get.to(ExampleScaffold());

@ -4,7 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
///
class ASButton extends StatefulWidget {
///
final Color color;
final Color bgcolor;
///
///stringwidget
@ -20,6 +20,7 @@ class ASButton extends StatefulWidget {
final Color outlineColor;
///
///
final Color textColor;
///
@ -33,7 +34,7 @@ class ASButton extends StatefulWidget {
ASButton({
Key key,
this.color,
this.bgcolor,
this.radius,
this.outline = false,
this.outlineColor,
@ -45,14 +46,14 @@ class ASButton extends StatefulWidget {
}) : super(key: key);
ASButton.warn(this.title, this.onpressed,
{Key key, this.textStyle, this.padding, this.radius, this.color})
{Key key, this.textStyle, this.padding, this.radius, this.bgcolor})
: outline = true,
outlineColor = Color(0xFFE50112),
textColor = Color(0xFFE50112),
super(key: key);
ASButton.info(this.title, this.onpressed,
{Key key, this.color, this.radius, this.textStyle, this.padding})
{Key key, this.bgcolor, this.radius, this.textStyle, this.padding})
: outline = true,
outlineColor = Color(0x73000000),
textColor = Color(0xD9000000),
@ -60,10 +61,16 @@ class ASButton extends StatefulWidget {
ASButton.delete(this.title, this.onpressed,
{Key key, this.radius, this.outlineColor, this.textStyle, this.padding})
: color = Color(0xFFFFB600),
: bgcolor = Color(0xFFFFB600),
textColor = Color(0xD9FFFFFF),
outline = false,
super(key: key);
ASButton.opration(this.title, this.onpressed,
{Key key, this.radius, this.outlineColor, this.textStyle, this.padding})
: bgcolor = Color(0xFFF2F2F2),
textColor = Color(0xD9000000),
outline = false,
super(key: key);
@override
_ASButtonState createState() => _ASButtonState();
@ -73,23 +80,23 @@ class _ASButtonState extends State<ASButton> {
@override
Widget build(BuildContext context) {
return MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: widget.onpressed,
child: widget.title is String
? Text(
widget.title,
style: widget.textStyle == null
? TextStyle(color: widget.textColor, fontSize: 13.sp)
: widget.textStyle,
)
? 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, horizontal: 12.w),
shape: RoundedRectangleBorder(
side: widget.outline
? BorderSide(color: widget.outlineColor, width: 0.5)
? BorderSide(color: widget.outlineColor, width: 0.5.w)
: BorderSide.none,
borderRadius: BorderRadius.circular(widget.radius ?? 15.5.w)),
color: widget.color ?? Color(0xFFFFFFFF),
color: widget.bgcolor ?? Color(0xFFFFFFFF),
elevation: 0,
);
}

@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASLongButton extends StatefulWidget {
///
///stringwidget
final dynamic title;
///
final Color bgColor;
///
///
final Color textColor;
///
final double radius;
///
final TextStyle textStyle;
///
final Padding padding;
///
final bool outline;
///
final Color outlineColor;
///
final VoidCallback onpressed;
ASLongButton(
{Key key,
@required this.title,
this.bgColor,
this.textColor,
this.radius,
this.textStyle,
this.padding,
this.outline = false,
this.outlineColor,
@required this.onpressed})
: super(key: key);
ASLongButton.solid(
this.title,
this.onpressed, {
Key key,
this.textStyle,
this.padding,
this.outlineColor,
this.radius,
}) : bgColor = Color(0xFFF6B72D),
textColor = Color(0xFFFFFFFF),
outline = false,
super(key: key);
ASLongButton.hollow(this.title, this.onpressed,
{Key key, this.radius, this.textStyle, this.padding})
: bgColor = Color(0xFFFFFFFF),
textColor = Color(0xFFF6B72D),
outline = true,
outlineColor = Color(0xFFF6B72D),
super(key: key);
@override
_ASLongButtonState createState() => _ASLongButtonState();
}
class _ASLongButtonState extends State<ASLongButton> {
@override
Widget build(BuildContext context) {
return MaterialButton(
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))
: widget.title,
padding: widget.padding ??
EdgeInsets.symmetric(vertical: 8.w, horizontal: 112.w),
shape: RoundedRectangleBorder(
side: widget.outline
? BorderSide(color: widget.outlineColor, width: 1.w)
: BorderSide.none,
borderRadius: BorderRadius.circular(widget.radius ?? 22.5.w)),
color: widget.bgColor ?? Color(0xFFFFFFFF),
elevation: 0,
);
}
}
Loading…
Cancel
Save