1
0
mirror of https://github.com/git-touch/git-touch synced 2025-02-08 23:58:46 +01:00

37 lines
1.0 KiB
Dart
Raw Normal View History

2020-01-04 22:47:48 +08:00
import 'package:flutter/cupertino.dart';
2019-09-29 00:25:14 +08:00
import 'package:flutter/material.dart';
import 'package:git_touch/models/theme.dart';
import 'package:provider/provider.dart';
class ActionEntry extends StatelessWidget {
2021-05-16 15:16:35 +08:00
final IconData? iconData;
final String? url;
final VoidCallback? onTap;
2020-01-31 16:54:01 +08:00
ActionEntry({this.url, this.iconData, this.onTap});
2019-09-29 00:25:14 +08:00
@override
Widget build(BuildContext context) {
2020-01-31 16:54:01 +08:00
final theme = Provider.of<ThemeModel>(context);
switch (theme.theme) {
2019-09-29 00:25:14 +08:00
case AppThemeType.cupertino:
2020-01-04 22:47:48 +08:00
return CupertinoButton(
minSize: 0,
2019-09-29 13:47:18 +08:00
child: Icon(iconData, size: 22),
2020-01-04 22:47:48 +08:00
padding: EdgeInsets.zero,
2020-01-31 16:54:01 +08:00
onPressed: () {
2021-05-16 15:16:35 +08:00
if (onTap != null) onTap!();
if (url != null) theme.push(context, url!);
2020-01-31 16:54:01 +08:00
},
2019-09-29 00:25:14 +08:00
);
default:
return IconButton(
icon: Icon(iconData),
2020-01-31 16:54:01 +08:00
onPressed: () {
2021-05-16 15:16:35 +08:00
if (onTap != null) onTap!();
if (url != null) theme.push(context, url!);
2020-01-31 16:54:01 +08:00
},
2019-09-29 00:25:14 +08:00
);
}
}
}