Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #111 from krawieck/from-comment-to-post
Browse files Browse the repository at this point in the history
Allow user to go from comment to post
  • Loading branch information
shilangyu authored Jan 16, 2021
2 parents e5d0c58 + 96d6c36 commit 12cdd04
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
29 changes: 27 additions & 2 deletions lib/widgets/comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Comment extends HookWidget {
final int indent;
final int postCreatorId;
final CommentTree commentTree;
final bool detached;

final bool wasVoted;

Expand All @@ -40,23 +41,40 @@ class Comment extends HookWidget {
this.commentTree, {
this.indent = 0,
@required this.postCreatorId,
this.detached = false,
}) : wasVoted =
(commentTree.comment.myVote ?? VoteType.none) != VoteType.none;

_showCommentInfo(BuildContext context) {
final com = commentTree.comment;
showInfoTablePopup(context, {
'id': com.id,
'creatorId': com.creatorId,
'postId': com.postId,
'postName': com.postName,
'parentId': com.parentId,
'removed': com.removed,
'read': com.read,
'published': com.published,
'updated': com.updated,
'deleted': com.deleted,
'apId': com.apId,
'local': com.local,
'communityId': com.communityId,
'communityActorId': com.communityActorId,
'communityLocal': com.communityLocal,
'communityName': com.communityName,
'communityIcon': com.communityIcon,
'banned': com.banned,
'bannedFromCommunity': com.bannedFromCommunity,
'creatorActirId': com.creatorActorId,
'userId': com.userId,
'upvotes': com.upvotes,
'downvotes': com.downvotes,
'score': com.score,
'% of upvotes': '${100 * (com.upvotes / (com.upvotes + com.downvotes))}%',
'hotRank': com.hotRank,
'hotRankActive': com.hotRankActive,
'published': com.published,
'updated': com.updated,
});
}

Expand Down Expand Up @@ -263,6 +281,13 @@ class Comment extends HookWidget {
content: Text('comment copied to clipboard'))));
}),
const Spacer(),
if (detached)
_CommentAction(
icon: Icons.link,
onPressed: () =>
goToPost(context, comment.instanceHost, comment.postId),
tooltip: 'go to post',
),
_CommentAction(
icon: Icons.more_horiz,
onPressed: () => _openMoreMenu(context),
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/sortable_infinite_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class InfiniteCommentList extends StatelessWidget {
builder: (comment) => Comment(
CommentTree(comment),
postCreatorId: null,
detached: true,
),
fetcher: fetcher,
);
Expand Down

0 comments on commit 12cdd04

Please sign in to comment.