You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
4.6 KiB
Dart
143 lines
4.6 KiB
Dart
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hexcolor/hexcolor.dart';
|
|
|
|
import '../app_texts_widget.dart';
|
|
|
|
class AppButton extends StatefulWidget {
|
|
final GestureTapCallback onPressed;
|
|
final String title;
|
|
final IconData? iconData;
|
|
final Widget? icon;
|
|
final Color? color;
|
|
double fontSize;
|
|
final double padding;
|
|
final Color fontColor;
|
|
final bool loading;
|
|
final bool disabled;
|
|
final FontWeight fontWeight;
|
|
final bool hasBorder;
|
|
final Color borderColor;
|
|
final double radius;
|
|
final double vPadding;
|
|
final double hPadding;
|
|
final double height;
|
|
|
|
AppButton({
|
|
required this.onPressed,
|
|
this.title = '',
|
|
this.iconData,
|
|
this.icon,
|
|
this.color,
|
|
this.fontSize = 15,
|
|
this.padding = 8,
|
|
this.loading = false,
|
|
this.disabled = false,
|
|
this.fontColor = Colors.white,
|
|
this.fontWeight = FontWeight.normal,
|
|
this.vPadding = 0,
|
|
this.hPadding = 0,
|
|
this.radius = 8.0,
|
|
this.hasBorder = false,
|
|
this.borderColor = Colors.white,
|
|
this.height = 50,
|
|
});
|
|
|
|
_AppButtonState createState() => _AppButtonState();
|
|
}
|
|
|
|
class _AppButtonState extends State<AppButton> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (widget.fontSize == null) {
|
|
widget.fontSize = SizeConfig.getHeightMultiplier() *
|
|
(SizeConfig.isHeightVeryShort
|
|
? 2.1
|
|
: SizeConfig.isHeightShort
|
|
? 1.8
|
|
: 1.7);
|
|
}
|
|
return Container(
|
|
// height: MediaQuery.of(context).size.height * 0.075,
|
|
height: widget.height ??
|
|
SizeConfig.heightMultiplier! *
|
|
(SizeConfig.isHeightVeryShort
|
|
? 6
|
|
: SizeConfig.isHeightShort
|
|
? 5.5
|
|
: 5),
|
|
child: IgnorePointer(
|
|
ignoring: widget.loading || widget.disabled,
|
|
child: RawMaterialButton(
|
|
fillColor: widget.disabled
|
|
? Colors.grey
|
|
: widget.color != null
|
|
? widget.color
|
|
: HexColor("#D02127"),
|
|
splashColor: widget.color,
|
|
child: Padding(
|
|
padding: (widget.hPadding > 0 || widget.vPadding > 0)
|
|
? EdgeInsets.symmetric(vertical: widget.vPadding, horizontal: widget.hPadding)
|
|
: EdgeInsets.only(
|
|
top: widget.padding,
|
|
bottom: widget.padding,
|
|
//right: SizeConfig.widthMultiplier! * widget.padding,
|
|
//left: SizeConfig.widthMultiplier! * widget.padding
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
if (widget.icon != null) Container(width: 25, height: 25, child: widget.icon),
|
|
if (widget.iconData != null)
|
|
Icon(
|
|
widget.iconData,
|
|
color: Colors.white,
|
|
),
|
|
if (widget.icon != null || widget.iconData != null)
|
|
SizedBox(
|
|
width: 5.0,
|
|
),
|
|
widget.loading
|
|
? Padding(
|
|
padding: EdgeInsets.all(2.6),
|
|
child: SizedBox(
|
|
height: 19.0,
|
|
width: 19.0,
|
|
child: CircularProgressIndicator(
|
|
backgroundColor: Colors.white,
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
Colors.grey[300]!,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
: Container(
|
|
child: AppText(
|
|
widget.title,
|
|
color: widget.fontColor,
|
|
fontSize: widget.fontSize,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: -0.48,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
onPressed: widget.disabled ? () {} : widget.onPressed,
|
|
shape: RoundedRectangleBorder(
|
|
side: BorderSide(
|
|
color: widget.hasBorder
|
|
? widget.borderColor
|
|
: widget.disabled
|
|
? Colors.grey
|
|
: widget.color ?? Color(0xFFB8382C),
|
|
width: 0.8,
|
|
),
|
|
borderRadius: BorderRadius.all(Radius.circular(widget.radius))),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|