2020-07-21 17:22:41 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2020-09-09 14:13:44 +00:00
|
|
|
class ActionButton extends StatelessWidget {
|
|
|
|
ActionButton(
|
|
|
|
{@required this.image,
|
2021-03-03 18:54:23 +00:00
|
|
|
@required this.title,
|
|
|
|
this.route,
|
|
|
|
this.onClick,
|
2022-03-30 15:57:04 +00:00
|
|
|
this.alignment = Alignment.center,
|
|
|
|
this.textColor});
|
2020-07-21 17:22:41 +00:00
|
|
|
|
|
|
|
final Image image;
|
|
|
|
final String title;
|
|
|
|
final String route;
|
|
|
|
final Alignment alignment;
|
2021-03-03 18:54:23 +00:00
|
|
|
final void Function() onClick;
|
2022-03-30 15:57:04 +00:00
|
|
|
final Color textColor;
|
2020-07-21 17:22:41 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-03-30 15:57:04 +00:00
|
|
|
var _textColor = textColor ?? Theme.of(context)
|
|
|
|
.accentTextTheme
|
|
|
|
.display3
|
|
|
|
.backgroundColor;
|
|
|
|
|
2020-07-21 17:22:41 +00:00
|
|
|
return Container(
|
2022-03-30 15:57:04 +00:00
|
|
|
padding: EdgeInsets.only(top: 14, bottom: 16, left: 10, right: 10),
|
2020-07-21 17:22:41 +00:00
|
|
|
alignment: alignment,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
2021-03-03 18:54:23 +00:00
|
|
|
if (route?.isNotEmpty ?? false) {
|
2020-07-21 17:22:41 +00:00
|
|
|
Navigator.of(context, rootNavigator: true).pushNamed(route);
|
2021-03-03 18:54:23 +00:00
|
|
|
} else {
|
|
|
|
onClick?.call();
|
2020-07-21 17:22:41 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
2022-03-15 14:13:34 +00:00
|
|
|
shape: BoxShape.circle),
|
2020-07-21 17:22:41 +00:00
|
|
|
child: image,
|
|
|
|
),
|
|
|
|
),
|
2022-03-15 14:13:34 +00:00
|
|
|
SizedBox(height: 4),
|
2020-07-21 17:22:41 +00:00
|
|
|
Text(
|
|
|
|
title,
|
2020-12-11 18:46:20 +00:00
|
|
|
style: TextStyle(
|
2022-03-15 14:13:34 +00:00
|
|
|
fontSize: 10,
|
2022-03-30 15:57:04 +00:00
|
|
|
color: _textColor),
|
2020-07-21 17:22:41 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2021-03-03 18:54:23 +00:00
|
|
|
}
|