From 88217202f8694ab0bb6e6bb980942ec05690860f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 25 Apr 2021 16:03:40 +0200 Subject: [PATCH] Can show group logo as group conversations logo --- lib/ui/tiles/conversation_tile.dart | 7 +++++- lib/ui/widgets/conversation_image_widget.dart | 22 ++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/ui/tiles/conversation_tile.dart b/lib/ui/tiles/conversation_tile.dart index a070dde..b70f376 100644 --- a/lib/ui/tiles/conversation_tile.dart +++ b/lib/ui/tiles/conversation_tile.dart @@ -80,7 +80,12 @@ class ConversationTile extends StatelessWidget { // Leading icon leading: ConversationImageWidget( - conversation: conversation, users: usersList), + conversation: conversation, + users: usersList, + group: conversation.isGroupConversation + ? groupsList.getGroup(conversation.groupID) + : null, + ), // Conversation information isThreeLine: true, diff --git a/lib/ui/widgets/conversation_image_widget.dart b/lib/ui/widgets/conversation_image_widget.dart index 5e97de0..7cfd984 100644 --- a/lib/ui/widgets/conversation_image_widget.dart +++ b/lib/ui/widgets/conversation_image_widget.dart @@ -1,6 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:comunic/lists/users_list.dart'; import 'package:comunic/models/conversation.dart'; +import 'package:comunic/models/group.dart'; import 'package:comunic/models/user.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:flutter/material.dart'; @@ -13,13 +14,15 @@ class ConversationImageWidget extends StatelessWidget { final Conversation conversation; final UsersList users; final double size; + final Group group; - const ConversationImageWidget( - {Key key, - @required this.conversation, - @required this.users, - this.size = 30}) - : assert(conversation != null), + const ConversationImageWidget({ + Key key, + @required this.conversation, + @required this.users, + this.group, + this.size = 30, + }) : assert(conversation != null), assert(users != null), assert(size > 0), super(key: key); @@ -40,6 +43,13 @@ class ConversationImageWidget extends StatelessWidget { width: size, ); + if (group != null) { + return CachedNetworkImage( + imageUrl: group.iconURL, + width: size, + ); + } + if (conversation.members.length < 2) return Icon( Icons.lock,