diff --git a/lib/models/theme.dart b/lib/models/theme.dart index 7328eba..0062d1e 100644 --- a/lib/models/theme.dart +++ b/lib/models/theme.dart @@ -262,64 +262,6 @@ class ThemeModel with ChangeNotifier { // ); } - Future showDialogOptions( - BuildContext context, List> options) { - var title = Text('Pick your reaction'); - var cancelWidget = Text('Cancel'); - - switch (theme) { - case AppThemeType.cupertino: - return showCupertinoDialog( - context: context, - builder: (BuildContext context) { - return CupertinoAlertDialog( - title: title, - actions: options.map((option) { - return CupertinoDialogAction( - child: option.widget, - onPressed: () { - Navigator.pop(context, option.value); - }, - ); - }).toList() - ..add( - CupertinoDialogAction( - child: cancelWidget, - isDestructiveAction: true, - onPressed: () { - Navigator.pop(context, null); - }, - ), - ), - ); - }, - ); - default: - return showDialog( - context: context, - builder: (BuildContext context) { - return SimpleDialog( - title: title, - children: options.map((option) { - return SimpleDialogOption( - child: option.widget, - onPressed: () { - Navigator.pop(context, option.value); - }, - ); - }).toList() - ..add(SimpleDialogOption( - child: cancelWidget, - onPressed: () { - Navigator.pop(context, null); - }, - )), - ); - }, - ); - } - } - static Timer _debounce; String _selectedItem; diff --git a/lib/widgets/comment_item.dart b/lib/widgets/comment_item.dart index e5bb0c0..8d92cbc 100644 --- a/lib/widgets/comment_item.dart +++ b/lib/widgets/comment_item.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:git_touch/models/auth.dart'; import 'package:git_touch/models/theme.dart'; +import 'package:git_touch/widgets/action_button.dart'; import 'package:git_touch/widgets/markdown_view.dart'; import 'package:provider/provider.dart'; import 'package:timeago/timeago.dart' as timeago; @@ -37,9 +38,10 @@ class _GhEmojiActionState extends State { get payload => widget.payload; - onReaction(String emojiKey, bool isRemove) async { + onReaction(String emojiKey) async { if (emojiKey == null) return; + final isRemove = _hasReacted(emojiKey); var id = payload['id'] as String; var operation = isRemove ? 'remove' : 'add'; await Provider.of(context).query(''' @@ -75,7 +77,7 @@ mutation { return Link( onTap: () { - onReaction(emojiKey, _hasReacted(emojiKey)); + onReaction(emojiKey); }, child: Container( padding: EdgeInsets.all(4), @@ -95,20 +97,18 @@ mutation { }), Link( onTap: () async { - final result = await theme.showDialogOptions( + await theme.showActions( context, emojiMap.entries.map((entry) { - var emojiKey = entry.key; - return DialogOption( - value: emojiKey, - widget: Container( - decoration: _getDecorationByKey(emojiKey), - child: Text(emojiKey + ' ' + entry.value), - ), + final emojiKey = entry.key; + return ActionItem( + text: emojiKey + ' ' + entry.value, + onTap: (_) { + onReaction(emojiKey); + }, ); }).toList(), ); - onReaction(result, _hasReacted(result)); }, child: Container( padding: EdgeInsets.all(4),