import 'dart:ui';
import 'package:flutter/material.dart';
class SQButtonType{
static final raisedButton = '1';
static final outlineButton = '2';
}
Widget SQButton({
@required VoidCallback onPressed,
@required String text,
@required String buttonType,
TextStyle textStyle,
Color textColor,
Color bgColor,
Color disabledColor,
Color borderColor,
double borderWith,
double fontSize = 15,
EdgeInsetsGeometry margin,
double width,
double height,
bool enable = true,
double borderSideWidth = 0,
Color focusColor,
Color hoverColor,
Color highlightColor = const Color(0xffeeeeee),
Color splashColor,
Brightness colorBrightness,
double elevation,
double focusElevation,
double hoverElevation,
double highlightElevation,
double disabledElevation,
EdgeInsetsGeometry padding,
ShapeBorder shape,
Clip clipBehavior = Clip.none,
FocusNode focusNode,
bool autofocus = false,
MaterialTapTargetSize materialTapTargetSize, // raisebtn
Duration animationDuration,
BorderSide borderSide,
Color highlightedBorderColor, // outlinebtn
Color disabledBorderColor // outlinebtn
}) {
if(buttonType == SQButtonType.raisedButton){
Color tColor = enable ? (textColor?? Colors.black) : Colors.black54;
return ButtonTheme(
height: height,
minWidth: width,
child: RaisedButton(
onPressed: onPressed,
child: Text(text,maxLines: 1,
style: textStyle == null ? TextStyle(color: tColor, fontSize: fontSize) : textStyle,
),
color: bgColor,
disabledElevation: 0,
disabledColor: disabledColor,
shape: shape ?? StadiumBorder(side:borderSide ?? BorderSide(width: borderSideWidth,color: borderColor)),
focusColor: focusColor,
hoverColor: hoverColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorBrightness: colorBrightness,
elevation: elevation,
focusElevation: focusElevation,
hoverElevation: hoverElevation,
highlightElevation: highlightElevation,
padding: padding,
clipBehavior: clipBehavior,
focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
animationDuration: animationDuration,
),
);
} else if(buttonType == SQButtonType.outlineButton) {
Color tColor = enable ? (textColor?? Colors.black) : Colors.black54;
return ButtonTheme(
height: height,
minWidth: width,
child: OutlineButton(
borderSide: borderSide ?? new BorderSide(color: borderColor,width: borderSideWidth),
onPressed: () {
if(enable) {
onPressed();
}
},
child: Text(text,
textAlign: TextAlign.center,
style: textStyle == null ? TextStyle(
color: tColor,
fontSize: fontSize) : textStyle,
),
color: bgColor,
highlightedBorderColor: borderColor,
highlightColor: highlightColor,
shape: shape ?? StadiumBorder(),
focusColor: focusColor,
hoverColor: hoverColor,
splashColor: splashColor,
highlightElevation: highlightElevation,
disabledBorderColor: disabledBorderColor,
padding: padding,
clipBehavior: clipBehavior,
focusNode: focusNode,
autofocus: autofocus,
),
);
}
return Container();
}
/////////////////////////////////
import 'package:flutter/material.dart';
class CustomBGDialog extends StatefulWidget {
final double bgVWidth;
final double bgVHeight;
final double bgRadius;
final EdgeInsets bgEdgetInsets;
final Color bgViewColor;
final List<Widget> topList;
final Widget bottomWidget;
CustomBGDialog({@required this.bgVWidth, @required this.bgVHeight, this.bgRadius = 6, @required this.bgEdgetInsets, this.bgViewColor = Colors.white, @required this.topList, @required this.bottomWidget, Key key}) : super(key: key);
@override
State<CustomBGDialog> createState() => _CustomBGDialogState();
}
class _CustomBGDialogState extends State<CustomBGDialog> {
@override
Widget build(BuildContext context) {
List<Widget> lsw = [];
lsw.addAll(lsw);
lsw.add(Flexible(flex: 1, child:Container()));
lsw.add(widget.bottomWidget);
return Material(
color: Colors.transparent,
child:
Center(
// ClipRRect 创建圆角矩形 要不然发现下边button不是圆角
child: Container(
padding: widget.bgEdgetInsets,
// alignment: Alignment.center,
width: widget.bgVWidth,
height: widget.bgVHeight,
decoration: BoxDecoration(
borderRadius:BorderRadius.circular(widget.bgRadius),
color: widget.bgViewColor ?? Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
offset: Offset(0.0, 15.0), //阴影xy轴偏移量
blurRadius: 15.0, //阴影模糊程度
spreadRadius: 1.0 //阴影扩散程度
)
]
),
// padding: widget.bgEdgetInsets ?? EdgeInsets.fromLTRB(10, 15, 10, 15),
// width: SIZE_SCALE(260),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: lsw,
),
)
),
);
}
}
////////////////////////
import 'package:flutter/material.dart';
import 'custom_common_btn_widget.dart';
Widget BottomBtnThem({@required String cancelText, @required Color cancelBGColor, @required Color cancelBColor,@required TextStyle cancelSt, Function cancelCallBack,
@required String confrimText, @required Color confrimBGColor, @required Color confirmBColor, @required TextStyle confirmSt,Function confirmCallBack}){
List <Widget> wls = [];
if(cancelText != null){
wls.addAll([
Expanded(flex: 1, child: SQButton(onPressed: cancelCallBack, buttonType: SQButtonType.raisedButton)),
SizedBox(width: 15,),
Expanded(flex: 1, child: SQButton(onPressed: cancelCallBack, buttonType: SQButtonType.raisedButton),
),
]);
} else {
wls.addAll([
Expanded(flex: 1, child: Container()),
Expanded(flex: 3, child: Expanded(flex: 1, child: SQButton(onPressed: cancelCallBack, buttonType: SQButtonType.raisedButton))),
Expanded(flex: 1, child: Container())
]);
}
return Container(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: wls),
);
}
浙公网安备 33010602011771号