From 08c77340a0badcfda00d1b7c6540adc2f65787b1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 10 Mar 2021 18:12:56 +0100 Subject: [PATCH] Add support for conversation image --- lib/ui/tiles/conversation_tile.dart | 21 +++++++++++++++------ lib/ui/widgets/custom_list_tile.dart | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/ui/tiles/conversation_tile.dart b/lib/ui/tiles/conversation_tile.dart index 3f2a105..03e09d4 100644 --- a/lib/ui/tiles/conversation_tile.dart +++ b/lib/ui/tiles/conversation_tile.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/lists/users_list.dart'; import 'package:comunic/models/conversation.dart'; @@ -66,13 +67,21 @@ class ConversationTile extends StatelessWidget { ), ), + // Tile color + tileColor: conversation.sawLastMessage + ? null + : (conversation.color ?? Colors.blue).withOpacity(0.2), + // Leading icon - leading: Icon( - conversation.sawLastMessage ? Icons.check_circle : Icons.lens, - color: conversation.sawLastMessage - ? (darkTheme() ? darkAccentColor : null) - : conversation.color ?? Colors.blue, - ), + leading: conversation.logoURL == null + ? Icon( + conversation.sawLastMessage ? Icons.check_circle : Icons.lens, + color: (darkTheme() ? darkAccentColor : null), + ) + : CachedNetworkImage( + imageUrl: conversation.logoURL, + width: 30, + ), // Conversation information isThreeLine: true, diff --git a/lib/ui/widgets/custom_list_tile.dart b/lib/ui/widgets/custom_list_tile.dart index f37e72e..087da54 100644 --- a/lib/ui/widgets/custom_list_tile.dart +++ b/lib/ui/widgets/custom_list_tile.dart @@ -17,6 +17,7 @@ class CustomListTile extends StatelessWidget { final GestureTapCallback onTap; final GestureLongPressCallback onLongPress; final bool selected; + final Color tileColor; /// Custom onLongPress function final Function(Size, Offset) onLongPressWithInfo; @@ -39,6 +40,7 @@ class CustomListTile extends StatelessWidget { this.selected = false, this.onLongPressWithInfo, this.onLongPressOpenMenu, + this.tileColor, }) : assert(isThreeLine != null), assert(enabled != null), assert(selected != null), @@ -48,6 +50,7 @@ class CustomListTile extends StatelessWidget { @override Widget build(BuildContext context) { return ListTile( + tileColor: tileColor, leading: leading, title: title, subtitle: subtitle,