1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Show posts targets

This commit is contained in:
Pierre HUBERT 2019-05-23 18:37:56 +02:00
parent 14b6f17042
commit d62d23bd44
3 changed files with 20 additions and 1 deletions

View File

@ -20,6 +20,7 @@ class _NewestPostsScreenState extends State<NewestPostsScreen> {
Widget build(BuildContext context) {
return PostsListWidget(
getPostsList: _postsHelper.getLatest,
showPostsTarget: true,
);
}

View File

@ -39,15 +39,18 @@ class PostTile extends StatefulWidget {
final Post post;
final UsersList usersInfo;
final void Function(Post) onDeletedPost;
final bool showPostTarget;
const PostTile({
Key key,
@required this.post,
@required this.usersInfo,
@required this.onDeletedPost,
@required this.showPostTarget,
}) : assert(post != null),
assert(usersInfo != null),
assert(onDeletedPost != null),
assert(showPostTarget != null),
super(key: key);
@override
@ -75,6 +78,17 @@ class _PostTileState extends State<PostTile> {
set _sendingComment(bool sending) => setState(() => _submitting = sending);
String _getPostTarget() {
if (!widget.showPostTarget ||
(!widget.post.isGroupPost &&
widget.post.userID == widget.post.userPageID)) return "";
return " > " +
(widget.post.isGroupPost
? "Group"
: widget.usersInfo.getUser(widget.post.userPageID).displayName);
}
Widget _buildHeaderRow() {
// Header row
return Row(
@ -91,7 +105,7 @@ class _PostTileState extends State<PostTile> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
_user.displayName,
_user.displayName + _getPostTarget(),
style: _userNameStyle,
),
Text(diffTimeFromNowToStr(widget.post.timeSent)),

View File

@ -16,11 +16,14 @@ import 'package:flutter/material.dart';
class PostsListWidget extends StatefulWidget {
final Future<PostsList> Function() getPostsList;
final bool showPostsTarget;
const PostsListWidget({
Key key,
@required this.getPostsList,
@required this.showPostsTarget,
}) : assert(getPostsList != null),
assert(showPostsTarget != null),
super(key: key);
@override
@ -75,6 +78,7 @@ class _PostsListWidgetState extends State<PostsListWidget> {
post: _list[i],
usersInfo: _users,
onDeletedPost: _removePost,
showPostTarget: widget.showPostsTarget,
),
);
}