diff --git a/lib/pages/community.dart b/lib/pages/community.dart index 82910c4..9cf71ba 100644 --- a/lib/pages/community.dart +++ b/lib/pages/community.dart @@ -3,7 +3,6 @@ import 'package:esys_flutter_share/esys_flutter_share.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:intl/intl.dart'; import 'package:lemmy_api_client/lemmy_api_client.dart'; import 'package:url_launcher/url_launcher.dart' as ul; @@ -18,6 +17,7 @@ import '../util/text_color.dart'; import '../widgets/badge.dart'; import '../widgets/bottom_modal.dart'; import '../widgets/fullscreenable_image.dart'; +import '../widgets/info_table_popup.dart'; import '../widgets/markdown_text.dart'; import '../widgets/sortable_infinite_list.dart'; @@ -131,33 +131,13 @@ class CommunityPage extends HookWidget { leading: Icon(Icons.info_outline), title: Text('Nerd stuff'), onTap: () { - showDialog( - context: context, - child: SimpleDialog( - contentPadding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 15, - ), - children: [ - Table( - children: [ - TableRow(children: [ - Text('created by:'), - Text('@${community.creatorName}'), - ]), - TableRow(children: [ - Text('hot rank:'), - Text(community.hotRank.toString()), - ]), - TableRow(children: [ - Text('published:'), - Text( - '''${DateFormat.yMMMd().format(community.published)}''' - ''' ${DateFormat.Hms().format(community.published)}'''), - ]), - ], - ), - ])); + showInfoTablePopup(context, { + 'id:': community.id, + 'actorId': community.actorId, + 'created by:': '@${community.creatorName}', + 'hot rank:': community.hotRank.toString(), + 'published:': community.published.toString(), + }); }, ), ], diff --git a/lib/pages/instance.dart b/lib/pages/instance.dart index 73dd575..d8b2551 100644 --- a/lib/pages/instance.dart +++ b/lib/pages/instance.dart @@ -3,17 +3,15 @@ import 'package:esys_flutter_share/esys_flutter_share.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:intl/intl.dart'; import 'package:lemmy_api_client/lemmy_api_client.dart'; -import 'package:url_launcher/url_launcher.dart' as ul; import '../hooks/stores.dart'; import '../util/extensions/api.dart'; import '../util/goto.dart'; import '../util/text_color.dart'; import '../widgets/badge.dart'; -import '../widgets/bottom_modal.dart'; import '../widgets/fullscreenable_image.dart'; +import '../widgets/info_table_popup.dart'; import '../widgets/markdown_text.dart'; import '../widgets/sortable_infinite_list.dart'; import 'communities_list.dart'; @@ -70,73 +68,15 @@ class InstancePage extends HookWidget { final site = siteSnap.data; void _openMoreMenu(BuildContext c) { - showModalBottomSheet( - backgroundColor: Colors.transparent, - context: c, - builder: (context) => BottomModal( - child: Column( - children: [ - ListTile( - leading: Icon(Icons.open_in_browser), - title: Text('Open in browser'), - onTap: () async => await ul.canLaunch('https://$instanceUrl') - ? ul.launch('https://$instanceUrl') - : Scaffold.of(context).showSnackBar( - SnackBar(content: Text("can't open in browser"))), - ), - ListTile( - leading: Icon(Icons.info_outline), - title: Text('Nerd stuff'), - onTap: () { - showDialog( - context: context, - child: SimpleDialog( - contentPadding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 15, - ), - children: [ - Table( - children: [ - TableRow(children: [ - Text('url:'), - Text(instanceUrl), - ]), - TableRow(children: [ - Text('creator:'), - Text('@${site.site.creatorName}') - ]), - TableRow(children: [ - Text('version:'), - Text(site.version), - ]), - TableRow(children: [ - Text('enableDownvotes:'), - Text(site.site.enableDownvotes.toString()), - ]), - TableRow(children: [ - Text('enableNsfw:'), - Text(site.site.enableNsfw.toString()), - ]), - TableRow(children: [ - Text('published:'), - Text(DateFormat.yMMMMd() - .format(site.site.published)), - ]), - TableRow(children: [ - Text('updated:'), - Text(DateFormat.yMMMMd() - .format(site.site.updated)), - ]), - ], - ), - ])); - }, - ), - ], - ), - ), - ); + showInfoTablePopup(context, { + 'url:': instanceUrl, + 'creator:': '@${site.site.creatorName}', + 'version:': site.version, + 'enableDownvotes:': site.site.enableDownvotes.toString(), + 'enableNsfw:': site.site.enableNsfw.toString(), + 'published:': site.site.published, + 'updated:': site.site.updated, + }); } return Scaffold( diff --git a/lib/widgets/comment.dart b/lib/widgets/comment.dart index dee70ec..f28f804 100644 --- a/lib/widgets/comment.dart +++ b/lib/widgets/comment.dart @@ -4,7 +4,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:intl/intl.dart'; import 'package:lemmy_api_client/lemmy_api_client.dart'; import 'package:timeago/timeago.dart' as timeago; import 'package:url_launcher/url_launcher.dart' as ul; @@ -17,6 +16,7 @@ import '../util/goto.dart'; import '../util/intl.dart'; import '../util/text_color.dart'; import 'bottom_modal.dart'; +import 'info_table_popup.dart'; import 'markdown_text.dart'; import 'write_comment.dart'; @@ -45,56 +45,20 @@ class Comment extends HookWidget { _showCommentInfo(BuildContext context) { final com = commentTree.comment; - showDialog( - context: context, - child: SimpleDialog( - contentPadding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 15, - ), - children: [ - Table( - children: [ - TableRow(children: [ - Text('upvotes:'), - Text(com.upvotes.toString()), - ]), - TableRow(children: [ - Text('downvotes:'), - Text(com.downvotes.toString()), - ]), - TableRow(children: [ - Text('score:'), - Text(com.score.toString()), - ]), - TableRow(children: [ - Text('% of upvotes:'), - Text( - '''${(100 * (com.upvotes / (com.upvotes + com.downvotes))).toInt()}%'''), - ]), - TableRow(children: [ - Text('hotrank:'), - Text(com.hotRank.toString()), - ]), - TableRow(children: [ - Text('hotrank active:'), - Text(com.hotRankActive.toString()), - ]), - TableRow(children: [ - Text('published:'), - Text('''${DateFormat.yMMMd().format(com.published)}''' - ''' ${DateFormat.Hms().format(com.published)}'''), - ]), - TableRow(children: [ - Text('updated:'), - Text(com.updated != null - ? '''${DateFormat.yMMMd().format(com.updated)}''' - ''' ${DateFormat.Hms().format(com.updated)}''' - : 'never'), - ]), - ], - ), - ])); + showInfoTablePopup(context, { + 'id': com.id.toString(), + 'apId': com.apId.toString(), + 'userId': com.userId.toString(), + 'upvotes:': com.upvotes.toString(), + 'downvotes:': com.downvotes.toString(), + 'score:': com.score.toString(), + '% of upvotes:': + '${(100 * (com.upvotes / (com.upvotes + com.downvotes)))}%', + 'hotRank:': com.hotRank.toString(), + 'hotRankActive:': com.hotRankActive.toString(), + 'published:': com.published.toString(), + 'updated': com.updated.toString(), + }); } bool get isOP => commentTree.comment.creatorId == postCreatorId; diff --git a/lib/widgets/post.dart b/lib/widgets/post.dart index a079841..fc1c6fc 100644 --- a/lib/widgets/post.dart +++ b/lib/widgets/post.dart @@ -17,6 +17,7 @@ import '../util/extensions/api.dart'; import '../util/goto.dart'; import 'bottom_modal.dart'; import 'fullscreenable_image.dart'; +import 'info_table_popup.dart'; import 'markdown_text.dart'; import 'save_post_button.dart'; @@ -73,59 +74,21 @@ class Post extends HookWidget { leading: Icon(Icons.info_outline), title: Text('Nerd stuff'), onTap: () { - showDialog( - context: context, - child: SimpleDialog( - contentPadding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 15, - ), - children: [ - Table( - children: [ - TableRow(children: [ - Text('upvotes:'), - Text(post.upvotes.toString()), - ]), - TableRow(children: [ - Text('downvotes:'), - Text(post.downvotes.toString()), - ]), - TableRow(children: [ - Text('score:'), - Text(post.score.toString()), - ]), - TableRow(children: [ - Text('% of upvotes:'), - Text( - '''${(100 * (post.upvotes / (post.upvotes + post.downvotes))).toInt()}%'''), - ]), - TableRow(children: [ - Text('hotrank:'), - Text(post.hotRank.toString()), - ]), - TableRow(children: [ - Text('hotrank active:'), - Text(post.hotRankActive.toString()), - ]), - TableRow(children: [ - Text('published:'), - Text( - '''${DateFormat.yMMMd().format(post.published)}''' - ''' ${DateFormat.Hms().format(post.published)}'''), - ]), - TableRow(children: [ - Text('updated:'), - Text(post.updated != null - ? '''${DateFormat.yMMMd().format(post.updated)}''' - ''' ${DateFormat.Hms().format(post.updated)}''' - : 'never'), - ]), - ], - ), - ], - ), - ); + showInfoTablePopup(context, { + 'id:': post.id.toString(), + 'apId:': post.apId, + 'upvotes:': post.upvotes.toString(), + 'downvotes:': post.downvotes.toString(), + 'score': post.score.toString(), + '% of upvotes:': + '''${(100 * (post.upvotes / (post.upvotes + post.downvotes))).toInt()}%''', + 'hotRank:': post.hotRank.toString(), + 'hotRank active': post.hotRankActive.toString(), + 'local:': post.local.toString(), + 'published:': post.published.toString(), + 'updated': post.updated?.toString() ?? 'never', + 'newestActivityTime:': post.newestActivityTime.toString(), + }); }, ), ],