git-touch-android-ios-app/lib/widgets/mutation_button.dart

46 lines
1.2 KiB
Dart
Raw Normal View History

2020-01-12 07:49:46 +01:00
import 'package:flutter/cupertino.dart';
import 'package:git_touch/models/theme.dart';
2020-02-06 07:23:54 +01:00
import 'package:git_touch/widgets/link.dart';
2020-01-12 07:49:46 +01:00
import 'package:provider/provider.dart';
class MutationButton extends StatelessWidget {
2020-02-06 07:23:54 +01:00
final bool active;
2020-01-12 07:49:46 +01:00
final String text;
final String url;
final VoidCallback onTap;
2020-01-12 07:49:46 +01:00
MutationButton({
2020-02-06 07:23:54 +01:00
@required this.active,
2020-01-12 07:49:46 +01:00
@required this.text,
this.url,
this.onTap,
2020-01-12 07:49:46 +01:00
});
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
2020-02-06 07:23:54 +01:00
final textColor = active ? theme.palette.background : theme.palette.primary;
final backgroundColor =
active ? theme.palette.primary : theme.palette.background;
return Link(
url: url,
onTap: onTap,
2020-02-06 07:23:54 +01:00
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 12,
vertical: 4,
),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.all(Radius.circular(20)),
border: Border.all(color: theme.palette.primary),
),
child: Text(
text,
style: TextStyle(fontSize: 17, color: textColor),
2020-01-14 06:33:02 +01:00
),
2020-01-12 07:49:46 +01:00
),
);
}
}