修改按钮,add bottom button

null_safety
张萌 4 years ago
parent fbfc9c7b74
commit f2eac8911d

@ -0,0 +1,49 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:ansu_ui/buttons/as_bottom_button.dart';
import 'package:flutter/material.dart';
class ExampleBottomButton extends StatefulWidget {
ExampleBottomButton({Key key}) : super(key: key);
@override
_ExampleBottomButtonState createState() => _ExampleBottomButtonState();
}
class _ExampleBottomButtonState extends State<ExampleBottomButton> {
@override
Widget build(BuildContext context) {
return ASScaffold(
title: 'BottomButton',
body: Center(),
bottomNavigationBar: Column(
mainAxisSize: MainAxisSize.min,
children: [
ASBottomButton.infinity(
title: 'null',
onPressed: () {},
),
ASBottomButton.gradient(
title: '新增地址',
onPressed: () {},
),
Row(
children: [
SizedBox(
width: 112.w,
child: ASBottomButton.shortWhite(
title: 'null',
onPressed: () {},
),
),
Expanded(
child: ASBottomButton.gradient(
title: 'null',
onPressed: () {},
))
],
)
],
),
);
}
}

@ -1,4 +1,5 @@
import 'package:ansu_ui/ansu_ui.dart'; import 'package:ansu_ui/ansu_ui.dart';
import 'package:example/example_bottom_button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -44,6 +45,7 @@ class _MyHomePageState extends State<MyHomePage> {
children: [ children: [
ASButton.info(title:'Button',onPressed: () => Get.to(ExampleButton())), ASButton.info(title:'Button',onPressed: () => Get.to(ExampleButton())),
ASButton.info(title:'Scaffold', onPressed:() => Get.to(ExampleScaffold())), ASButton.info(title:'Scaffold', onPressed:() => Get.to(ExampleScaffold())),
ASButton.info(title: 'BottomBottun',onPressed: () => Get.to(ExampleBottomButton()),),
], ],
), ),
); );

@ -0,0 +1,142 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASBottomButton extends StatefulWidget {
///
final dynamic title;
///
final Color bgcolor;
///
final Color textColor;
///
final TextStyle textStyle;
///
final EdgeInsetsGeometry padding;
///
final Color disableColor;
///
final Color disableTextColor;
///
final double width;
///
final AlignmentGeometry begin;
///
final AlignmentGeometry end;
///
final List<Color> colors;
///
final VoidCallback onPressed;
ASBottomButton(
{Key key,
this.title,
this.bgcolor,
this.textColor,
this.textStyle,
this.padding,
this.disableColor,
this.disableTextColor,
this.width,
this.begin,
this.end,
this.colors,
this.onPressed})
: super(key: key);
ASBottomButton.infinity({
Key key,
@required this.title,
this.onPressed,
this.textStyle,
this.padding,
this.disableColor,
this.disableTextColor,
this.begin,
this.end,
this.colors,
}) : bgcolor = Color(0xFFF6B72D),
textColor = Color(0xFFFFFFFF),
width = double.infinity,
super(key: key);
ASBottomButton.gradient(
{Key key,
@required this.title,
this.onPressed,
this.bgcolor,
this.textStyle,
this.padding,
this.disableColor,
this.disableTextColor,
this.begin,
this.end})
: colors = [Color(0xFFFFA700), Color(0xFFFFBD00)],
textColor = Color(0xFFFFFFFF),
width = double.infinity,
super(key: key);
ASBottomButton.shortWhite({
Key key,
@required this.title,
this.onPressed,
this.bgcolor,
this.textStyle,
this.padding,
this.disableColor,
this.disableTextColor,
this.begin,
this.end,
}) : colors = [Color(0xFFFBFBFB), Color(0xFFFFFFFF)],
textColor = Color(0xFFFFB800),
width = double.infinity,
super(key: key);
@override
_ASBottomButtonState createState() => _ASBottomButtonState();
}
class _ASBottomButtonState extends State<ASBottomButton> {
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
width: widget.width ?? double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: widget.begin ?? Alignment.bottomRight,
end: widget.end ?? Alignment.topLeft,
colors: widget.colors ?? [widget.bgcolor, widget.bgcolor]),
),
child: MaterialButton(
onPressed: widget.onPressed,
textColor: widget.textColor ?? Color(0xFFFFFFFF),
disabledColor: widget.disableColor,
disabledTextColor: widget.disableTextColor,
padding: widget.padding ??
EdgeInsets.symmetric(
vertical: 13.w,
),
elevation: 0,
hoverElevation: 0,
highlightElevation: 0,
focusElevation: 0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: widget.title is String
? Text(widget.title,
style: widget.textStyle ??
TextStyle(fontSize: 20.sp, fontWeight: FontWeight.bold))
: widget.title,
),
);
}
}

@ -125,15 +125,13 @@ class ASButton extends StatefulWidget {
this.outlineColor, this.outlineColor,
this.width, this.width,
}) : bgcolor = Color(0xFFFFBD32), }) : bgcolor = Color(0xFFFFBD32),
textColor=Color(0xFF0000000), textColor = Color(0xFF0000000),
textStyle = TextStyle( textStyle = TextStyle(fontSize: 14.sp, fontWeight: FontWeight.bold),
fontSize: 14.sp,
fontWeight: FontWeight.bold),
radius = 5.w, radius = 5.w,
outline = false, outline = false,
disableColor = Color(0xFFFFDF9B), disableColor = Color(0xFFFFDF9B),
disableTextColor = Color(0x73000000), disableTextColor = Color(0x73000000),
padding=EdgeInsets.symmetric(vertical: 8.w), padding = EdgeInsets.symmetric(vertical: 8.w),
super(key: key); super(key: key);
@override @override
@ -144,17 +142,15 @@ class _ASButtonState extends State<ASButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialButton( return MaterialButton(
disabledColor: widget.disableColor ?? widget.bgcolor, disabledColor: widget.disableColor,
disabledTextColor: widget.disableTextColor ?? Color(0x73000000), disabledTextColor: widget.disableTextColor,
textColor: widget.textColor ?? Color(0xFFFFB600), textColor: widget.textColor ?? Color(0xFFFFB600),
minWidth: widget.width ?? 75.w, minWidth: widget.width ?? 75.w,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: widget.onPressed, onPressed: widget.onPressed,
child: widget.title is String child: widget.title is String
? Text(widget.title, ? Text(widget.title,
style: widget.textStyle ?? style: widget.textStyle ?? TextStyle(fontSize: 13.sp))
TextStyle(
fontSize: 13.sp))
: widget.title, : widget.title,
padding: widget.padding ?? EdgeInsets.symmetric(vertical: 6.w), padding: widget.padding ?? EdgeInsets.symmetric(vertical: 6.w),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(

@ -65,8 +65,8 @@ class ASGradientButton extends StatefulWidget {
radius = 19.w, radius = 19.w,
colors = [Color(0xFFF89B14), Color(0xFFF86B14)], colors = [Color(0xFFF89B14), Color(0xFFF86B14)],
width = 100.w, width = 100.w,
begin = Alignment.centerLeft, begin = Alignment.topCenter,
end = Alignment.centerRight, end = Alignment.bottomCenter,
padding = EdgeInsets.symmetric(vertical: 8.w), padding = EdgeInsets.symmetric(vertical: 8.w),
super(key: key); super(key: key);
@ -100,16 +100,16 @@ class _ASGradientButtonState extends State<ASGradientButton> {
width: widget.width ?? 110.w, width: widget.width ?? 110.w,
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: widget.begin ?? Alignment.centerLeft, begin: widget.begin ?? Alignment.topCenter,
end: widget.end ?? Alignment.centerRight, end: widget.end ?? Alignment.bottomCenter,
colors: widget.colors ?? [Color(0xFFFFA700), Color(0xFFFFBD00)], colors: widget.colors ?? [Color(0xFFFFA700), Color(0xFFFFBD00)],
), ),
borderRadius: BorderRadius.circular(widget.radius ?? 20.w), borderRadius: BorderRadius.circular(widget.radius ?? 20.w),
), ),
child: MaterialButton( child: MaterialButton(
disabledColor: widget.disableColor ?? Colors.grey, disabledColor: widget.disableColor,
textColor: widget.textColor ?? Color(0xD9FFFFFF), textColor: widget.textColor ?? Color(0xD9FFFFFF),
disabledTextColor: widget.disableTextColor ?? Color(0x73000000), disabledTextColor: widget.disableTextColor,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: widget.onPressed, onPressed: widget.onPressed,
child: widget.title is String child: widget.title is String

@ -95,9 +95,9 @@ class _ASLongButtonState extends State<ASLongButton> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialButton( return MaterialButton(
minWidth: widget.width ?? 280.w, minWidth: widget.width ?? 280.w,
disabledColor: widget.disableColor ?? widget.bgColor, disabledColor: widget.disableColor,
textColor: widget.textColor ?? Color(0xFFFFFFFF), textColor: widget.textColor ?? Color(0xFFFFFFFF),
disabledTextColor: widget.disableTextColor ?? Color(0x73000000), disabledTextColor: widget.disableTextColor,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: widget.onPressed, onPressed: widget.onPressed,
child: widget.title is String child: widget.title is String

Loading…
Cancel
Save