2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class PrimaryButton extends StatelessWidget {
|
|
|
|
const PrimaryButton(
|
|
|
|
{@required this.onPressed,
|
|
|
|
@required this.text,
|
|
|
|
@required this.color,
|
2020-04-24 17:34:32 +00:00
|
|
|
@required this.textColor,
|
2020-01-17 13:26:17 +00:00
|
|
|
this.isDisabled = false,
|
|
|
|
this.onDisabledPressed});
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
final VoidCallback onPressed;
|
2020-01-17 13:26:17 +00:00
|
|
|
final VoidCallback onDisabledPressed;
|
2020-01-08 12:26:34 +00:00
|
|
|
final Color color;
|
2020-04-24 17:34:32 +00:00
|
|
|
final Color textColor;
|
2020-01-08 12:26:34 +00:00
|
|
|
final String text;
|
2020-01-16 16:05:07 +00:00
|
|
|
final bool isDisabled;
|
2020-01-08 12:26:34 +00:00
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ButtonTheme(
|
|
|
|
minWidth: double.infinity,
|
2020-04-24 17:34:32 +00:00
|
|
|
height: 52.0,
|
2020-01-04 19:31:52 +00:00
|
|
|
child: FlatButton(
|
2020-01-17 13:26:17 +00:00
|
|
|
onPressed: isDisabled
|
|
|
|
? (onDisabledPressed != null ? onDisabledPressed : null)
|
|
|
|
: onPressed,
|
2020-05-01 15:57:22 +00:00
|
|
|
color: isDisabled ? color.withOpacity(0.5) : color,
|
|
|
|
disabledColor: color.withOpacity(0.5),
|
2020-01-04 19:31:52 +00:00
|
|
|
shape: RoundedRectangleBorder(
|
2020-05-29 15:10:11 +00:00
|
|
|
borderRadius: BorderRadius.circular(26.0),
|
|
|
|
),
|
2020-01-04 19:31:52 +00:00
|
|
|
child: Text(text,
|
2020-05-01 15:57:22 +00:00
|
|
|
textAlign: TextAlign.center,
|
2020-01-04 19:31:52 +00:00
|
|
|
style: TextStyle(
|
2020-04-24 17:34:32 +00:00
|
|
|
fontSize: 15.0,
|
|
|
|
fontWeight: FontWeight.w600,
|
2020-01-17 13:26:17 +00:00
|
|
|
color: isDisabled
|
2020-08-19 17:57:06 +00:00
|
|
|
? textColor.withOpacity(0.5)
|
2020-04-24 17:34:32 +00:00
|
|
|
: textColor)),
|
2020-01-04 19:31:52 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LoadingPrimaryButton extends StatelessWidget {
|
|
|
|
const LoadingPrimaryButton(
|
|
|
|
{@required this.onPressed,
|
2020-05-01 15:57:22 +00:00
|
|
|
@required this.text,
|
|
|
|
@required this.color,
|
|
|
|
@required this.textColor,
|
|
|
|
this.isDisabled = false,
|
|
|
|
this.isLoading = false});
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
final VoidCallback onPressed;
|
|
|
|
final Color color;
|
2020-05-01 15:57:22 +00:00
|
|
|
final Color textColor;
|
2020-01-08 12:26:34 +00:00
|
|
|
final bool isLoading;
|
|
|
|
final bool isDisabled;
|
|
|
|
final String text;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ButtonTheme(
|
|
|
|
minWidth: double.infinity,
|
2020-05-01 15:57:22 +00:00
|
|
|
height: 52.0,
|
2020-01-04 19:31:52 +00:00
|
|
|
child: FlatButton(
|
|
|
|
onPressed: (isLoading || isDisabled) ? null : onPressed,
|
|
|
|
color: color,
|
2020-05-01 15:57:22 +00:00
|
|
|
disabledColor: color.withOpacity(0.5),
|
2020-01-04 19:31:52 +00:00
|
|
|
shape: RoundedRectangleBorder(
|
2020-05-01 15:57:22 +00:00
|
|
|
borderRadius: BorderRadius.circular(26.0)),
|
2020-01-04 19:31:52 +00:00
|
|
|
child: isLoading
|
|
|
|
? CupertinoActivityIndicator(animating: true)
|
|
|
|
: Text(text,
|
2020-05-01 15:57:22 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15.0,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: isDisabled
|
2020-08-19 17:57:06 +00:00
|
|
|
? textColor.withOpacity(0.5)
|
2020-05-01 15:57:22 +00:00
|
|
|
: textColor
|
|
|
|
)),
|
2020-01-04 19:31:52 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PrimaryIconButton extends StatelessWidget {
|
|
|
|
const PrimaryIconButton({
|
|
|
|
@required this.onPressed,
|
|
|
|
@required this.iconData,
|
|
|
|
@required this.text,
|
|
|
|
@required this.color,
|
|
|
|
@required this.borderColor,
|
|
|
|
@required this.iconColor,
|
|
|
|
@required this.iconBackgroundColor,
|
|
|
|
});
|
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
final VoidCallback onPressed;
|
|
|
|
final IconData iconData;
|
|
|
|
final Color color;
|
|
|
|
final Color borderColor;
|
|
|
|
final Color iconColor;
|
|
|
|
final Color iconBackgroundColor;
|
|
|
|
final String text;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ButtonTheme(
|
|
|
|
minWidth: double.infinity,
|
|
|
|
height: 56.0,
|
|
|
|
child: FlatButton(
|
|
|
|
onPressed: onPressed,
|
|
|
|
color: color,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
side: BorderSide(color: borderColor),
|
|
|
|
borderRadius: BorderRadius.circular(10.0)),
|
|
|
|
child: Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: 28.0,
|
|
|
|
height: 56.0,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.circle, color: iconBackgroundColor),
|
|
|
|
child: Icon(iconData, color: iconColor, size: 22.0),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 56.0,
|
|
|
|
child: Center(
|
|
|
|
child: Text(text,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16.0,
|
2020-01-08 12:26:34 +00:00
|
|
|
color:
|
|
|
|
Theme.of(context).primaryTextTheme.button.color)),
|
2020-01-04 19:31:52 +00:00
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PrimaryImageButton extends StatelessWidget {
|
|
|
|
const PrimaryImageButton(
|
|
|
|
{@required this.onPressed,
|
|
|
|
@required this.image,
|
|
|
|
@required this.text,
|
2020-04-24 12:01:19 +00:00
|
|
|
@required this.color,
|
2020-05-29 15:10:11 +00:00
|
|
|
@required this.textColor,
|
|
|
|
this.borderColor = Colors.transparent});
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
final VoidCallback onPressed;
|
|
|
|
final Image image;
|
|
|
|
final Color color;
|
2020-04-24 12:01:19 +00:00
|
|
|
final Color textColor;
|
2020-05-29 15:10:11 +00:00
|
|
|
final Color borderColor;
|
2020-01-08 12:26:34 +00:00
|
|
|
final String text;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ButtonTheme(
|
|
|
|
minWidth: double.infinity,
|
2020-04-24 12:01:19 +00:00
|
|
|
height: 52.0,
|
2020-01-04 19:31:52 +00:00
|
|
|
child: FlatButton(
|
|
|
|
onPressed: onPressed,
|
|
|
|
color: color,
|
|
|
|
shape: RoundedRectangleBorder(
|
2020-05-29 15:10:11 +00:00
|
|
|
side: BorderSide(color: borderColor),
|
2020-04-24 12:01:19 +00:00
|
|
|
borderRadius: BorderRadius.circular(26.0)),
|
|
|
|
child:Center(
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
image,
|
|
|
|
SizedBox(width: 15),
|
|
|
|
Text(
|
|
|
|
text,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15,
|
2020-04-24 17:34:32 +00:00
|
|
|
fontWeight: FontWeight.w600,
|
2020-04-24 12:01:19 +00:00
|
|
|
color: textColor
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
2020-01-04 19:31:52 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|