From 972cee0a186772f74013c7a93784d6a315585c80 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 15 Jun 2019 08:27:20 +0200 Subject: [PATCH] Can click on user account image for posts to open user page --- lib/ui/tiles/post_tile.dart | 14 +++++++++++++- lib/ui/widgets/posts_list_widget.dart | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/ui/tiles/post_tile.dart b/lib/ui/tiles/post_tile.dart index d4ddb52..8f28099 100644 --- a/lib/ui/tiles/post_tile.dart +++ b/lib/ui/tiles/post_tile.dart @@ -19,6 +19,7 @@ import 'package:comunic/ui/widgets/network_image_widget.dart'; import 'package:comunic/utils/date_utils.dart'; import 'package:comunic/utils/files_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; +import 'package:comunic/utils/navigation_utils.dart'; import 'package:comunic/utils/post_utils.dart'; import 'package:comunic/utils/ui_utils.dart'; import 'package:flutter/material.dart'; @@ -42,6 +43,7 @@ class PostTile extends StatefulWidget { final GroupsList groupsInfo; final void Function(Post) onDeletedPost; final bool showPostTarget; + final bool userNamesClickable; const PostTile({ Key key, @@ -50,11 +52,13 @@ class PostTile extends StatefulWidget { @required this.onDeletedPost, @required this.showPostTarget, @required this.groupsInfo, + @required this.userNamesClickable, }) : assert(post != null), assert(usersInfo != null), assert(onDeletedPost != null), assert(showPostTarget != null), assert(groupsInfo != null), + assert(userNamesClickable != null), super(key: key); @override @@ -100,7 +104,15 @@ class _PostTileState extends State { // User account image Padding( padding: const EdgeInsets.only(right: 8.0, left: 8.0), - child: AccountImageWidget(user: _user), + child: InkWell( + child: AccountImageWidget(user: _user), + onTap: widget.userNamesClickable + ? () => openUserPage( + userID: _user.id, + context: context, + ) + : null, + ), ), // Column with user name + post target diff --git a/lib/ui/widgets/posts_list_widget.dart b/lib/ui/widgets/posts_list_widget.dart index e31c99a..a7b531c 100644 --- a/lib/ui/widgets/posts_list_widget.dart +++ b/lib/ui/widgets/posts_list_widget.dart @@ -20,15 +20,18 @@ class PostsListWidget extends StatefulWidget { final Future Function() getPostsList; final bool showPostsTarget; final bool buildListView; + final bool userNamesClickable; const PostsListWidget({ Key key, @required this.getPostsList, @required this.showPostsTarget, + this.userNamesClickable = true, this.buildListView = true, }) : assert(getPostsList != null), assert(showPostsTarget != null), assert(buildListView != null), + assert(userNamesClickable != null), super(key: key); @override @@ -106,6 +109,7 @@ class _PostsListWidgetState extends State { groupsInfo: _groups, onDeletedPost: _removePost, showPostTarget: widget.showPostsTarget, + userNamesClickable: widget.userNamesClickable, ); }