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;
|
|
|
|
|
2022-04-22 15:02:31 +00:00
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
if (route?.isNotEmpty ?? false) {
|
|
|
|
Navigator.of(context, rootNavigator: true).pushNamed(route);
|
|
|
|
} else {
|
|
|
|
onClick?.call();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
padding: EdgeInsets.only(top: 14, bottom: 16, left: 10, right: 10),
|
|
|
|
alignment: alignment,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
2020-07-21 17:22:41 +00:00
|
|
|
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-04-22 15:02:31 +00:00
|
|
|
SizedBox(height: 4),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10,
|
|
|
|
color: _textColor),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2020-07-21 17:22:41 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2021-03-03 18:54:23 +00:00
|
|
|
}
|