implement info table popup

This commit is contained in:
krawieck 2020-10-26 18:47:49 +01:00
parent 53f19c5c57
commit e4055f073e
4 changed files with 49 additions and 202 deletions

View File

@ -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(),
});
},
),
],

View File

@ -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(

View File

@ -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;

View File

@ -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(),
});
},
),
],