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

47 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 {
2021-05-16 09:16:35 +02:00
final bool? active;
2020-01-12 07:49:46 +01:00
final String text;
2021-05-16 09:16:35 +02:00
final String? url;
final VoidCallback? onTap;
2020-01-12 07:49:46 +01:00
MutationButton({
2021-05-16 09:16:35 +02:00
required this.active,
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);
2021-05-16 09:16:35 +02:00
final textColor =
active! ? theme.palette.background : theme.palette.primary;
2020-02-06 07:23:54 +01:00
final backgroundColor =
2021-05-16 09:16:35 +02:00
active! ? theme.palette.primary : theme.palette.background;
return LinkWidget(
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
),
);
}
}