|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
import 'package:flutter/foundation.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 icon;
|
|
|
|
final Color color;
|
|
|
|
final double fontSize;
|
|
|
|
final double padding;
|
|
|
|
final bool loading;
|
|
|
|
final bool disabled;
|
|
|
|
|
|
|
|
AppButton(
|
|
|
|
{@required this.onPressed,
|
|
|
|
this.title,
|
|
|
|
this.icon,
|
|
|
|
this.color,
|
|
|
|
this.fontSize = 2,
|
|
|
|
this.padding = 13,
|
|
|
|
this.loading = false,
|
|
|
|
this.disabled = false});
|
|
|
|
|
|
|
|
_AppButtonState createState() => _AppButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AppButtonState extends State<AppButton>{
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return
|
|
|
|
IgnorePointer(
|
|
|
|
ignoring: widget.loading,
|
|
|
|
child: RawMaterialButton(
|
|
|
|
fillColor: widget.color != null ? widget.color : HexColor("#B8382C"),
|
|
|
|
splashColor: widget.color,
|
|
|
|
child: Padding(
|
|
|
|
padding: 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)
|
|
|
|
Icon(
|
|
|
|
widget.icon,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
if (widget.icon != 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],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: AppText(
|
|
|
|
widget.title.toUpperCase(),
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: SizeConfig.textMultiplier * widget.fontSize,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: widget.onPressed,
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(6))),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|