cake_wallet/lib/src/screens/dashboard/widgets/action_button.dart

60 lines
1.5 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2020-09-09 14:13:44 +00:00
class ActionButton extends StatelessWidget {
ActionButton(
{@required this.image,
@required this.title,
this.route,
this.onClick,
2022-03-30 15:57:04 +00:00
this.alignment = Alignment.center,
this.textColor});
final Image image;
final String title;
final String route;
final Alignment alignment;
final void Function() onClick;
2022-03-30 15:57:04 +00:00
final Color textColor;
@override
Widget build(BuildContext context) {
2022-03-30 15:57:04 +00:00
var _textColor = textColor ?? Theme.of(context)
.accentTextTheme
.display3
.backgroundColor;
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(
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle),
child: image,
),
SizedBox(height: 4),
Text(
title,
style: TextStyle(
fontSize: 10,
color: _textColor),
)
],
),
),
);
}
}