From bedc3f52771d575d33a711b9c45383ac1da890a7 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 13 Mar 2021 08:26:56 +0100 Subject: [PATCH] Add user account image --- lib/ui/screens/conversation_screen.dart | 51 +++++++++++++++---------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/lib/ui/screens/conversation_screen.dart b/lib/ui/screens/conversation_screen.dart index df8fe9f..71c4c52 100644 --- a/lib/ui/screens/conversation_screen.dart +++ b/lib/ui/screens/conversation_screen.dart @@ -14,6 +14,7 @@ import 'package:comunic/ui/dialogs/pick_file_dialog.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/tiles/conversation_message_tile.dart'; import 'package:comunic/ui/tiles/server_conversation_message_tile.dart'; +import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/ui/widgets/scroll_watcher.dart'; import 'package:comunic/utils/date_utils.dart'; @@ -83,7 +84,7 @@ class _ConversationScreenState extends SafeState { // Colors definition Color get _senderColor => _conversation.color ?? - (darkTheme() ? Color(0xff2b343b) : Colors.blue.shade900); + /*(darkTheme() ? Color(0xff2b343b) :*/ Colors.blue.shade900; //); Color get _receiverColor => darkTheme() ? Color(0xff3a3d40) : Colors.grey.shade600; @@ -410,7 +411,8 @@ class _ConversationScreenState extends SafeState { final messageRadius = Radius.circular(10); return Container( - margin: EdgeInsets.only(top: previousMessage?.isOwner == true ? 0 : 12), + margin: EdgeInsets.only( + top: previousMessage?.isOwner == true ? 0 : 12, right: 5), constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.65), decoration: BoxDecoration( @@ -432,27 +434,34 @@ class _ConversationScreenState extends SafeState { ConversationMessage message, ConversationMessage previousMessage) { final messageRadius = Radius.circular(10); - return Container( - margin: EdgeInsets.only( - top: previousMessage == null || - message.userID != previousMessage.userID - ? 12 - : 0), - constraints: - BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.65), - decoration: BoxDecoration( - color: _receiverColor, - borderRadius: BorderRadius.only( - bottomRight: messageRadius, - topRight: messageRadius, - bottomLeft: messageRadius, + return Row(children: [ + SizedBox(width: 5), + AccountImageWidget( + user: _usersInfo.getUser(message.userID), + ), + SizedBox(width: 5), + Container( + margin: EdgeInsets.only( + top: previousMessage == null || + message.userID != previousMessage.userID + ? 12 + : 0), + constraints: + BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.65), + decoration: BoxDecoration( + color: _receiverColor, + borderRadius: BorderRadius.only( + bottomRight: messageRadius, + topRight: messageRadius, + bottomLeft: messageRadius, + ), + ), + child: Padding( + padding: EdgeInsets.all(10), + child: _buildMessage(message), ), ), - child: Padding( - padding: EdgeInsets.all(10), - child: _buildMessage(message), - ), - ); + ]); } Widget _buildMessage(ConversationMessage msg) => ConversationMessageTile(