mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +01:00
feat: use popup menu button for material
This commit is contained in:
parent
9c4cd73814
commit
951c50c2a9
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:share/share.dart';
|
||||
@ -9,8 +8,14 @@ import 'package:share/share.dart';
|
||||
class ActionItem {
|
||||
String text;
|
||||
void Function() onPress;
|
||||
IconData iconData;
|
||||
|
||||
ActionItem({
|
||||
@required this.text,
|
||||
@required this.onPress,
|
||||
this.iconData,
|
||||
});
|
||||
|
||||
ActionItem({@required this.text, @required this.onPress});
|
||||
ActionItem.share(String url)
|
||||
: text = 'Share',
|
||||
onPress = (() {
|
||||
@ -38,9 +43,8 @@ class ActionButton extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
switch (Provider.of<ThemeModel>(context).theme) {
|
||||
case AppThemeType.cupertino:
|
||||
default:
|
||||
return ActionEntry(
|
||||
iconData: iconData,
|
||||
return GestureDetector(
|
||||
child: Icon(iconData, size: 22),
|
||||
onTap: () async {
|
||||
var value = await showCupertinoModalPopup<int>(
|
||||
context: context,
|
||||
@ -71,6 +75,21 @@ class ActionButton extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
);
|
||||
default:
|
||||
return PopupMenuButton(
|
||||
icon: Icon(iconData),
|
||||
itemBuilder: (context) {
|
||||
return items.asMap().entries.map((entry) {
|
||||
return PopupMenuItem(
|
||||
value: entry.key,
|
||||
child: Text(entry.value.text),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
onSelected: (selected) {
|
||||
items[selected].onPress();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user