From 79c5b562cbf0a8dcc77cbf613b28084d160f53e2 Mon Sep 17 00:00:00 2001 From: Rafael <1024481@stud.hs-mannheim.de> Date: Sun, 16 Jun 2024 01:41:42 +0200 Subject: [PATCH] Added ProfilePicture to ChatPage --- lib/pages/chat_page.dart | 16 +++++++++++++++- lib/pages/conversations_page.dart | 3 ++- lib/pages/liked_users_page.dart | 1 + lib/pages/user_matching_page.dart | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/pages/chat_page.dart b/lib/pages/chat_page.dart index d9996eb..ea8bc2a 100644 --- a/lib/pages/chat_page.dart +++ b/lib/pages/chat_page.dart @@ -11,12 +11,14 @@ class ChatPage extends StatefulWidget { final String receiverEmail; final String receiverID; final String chatTitle; + final String? profileImageUrl; const ChatPage({ super.key, required this.receiverEmail, required this.receiverID, required this.chatTitle, + this.profileImageUrl, }); @override @@ -90,8 +92,20 @@ class _ChatPageState extends State { @override Widget build(BuildContext context) { + Widget chatHeader = Text(widget.chatTitle); + Widget? userPic; + if (widget.profileImageUrl != null && widget.profileImageUrl!.isNotEmpty) { + userPic = + CircleAvatar(backgroundImage: NetworkImage(widget.profileImageUrl!)); + } + if (userPic != null) { + chatHeader = Row( + children: [userPic, const SizedBox(width: 7), Text(widget.chatTitle)], + ); + } + return Scaffold( - appBar: AppBar(title: Text(widget.chatTitle)), + appBar: AppBar(title: chatHeader), body: Column( children: [ // display all messages diff --git a/lib/pages/conversations_page.dart b/lib/pages/conversations_page.dart index de84733..ec33660 100644 --- a/lib/pages/conversations_page.dart +++ b/lib/pages/conversations_page.dart @@ -15,7 +15,7 @@ class ConversationsPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text('My Chat Contacts'), + title: const Text('My Chat Connections'), ), body: _buildUserMatchesList(), ); @@ -78,6 +78,7 @@ class ConversationsPage extends StatelessWidget { receiverEmail: userData[Constants.dbFieldUsersEmail], receiverID: userData[Constants.dbFieldUsersID], chatTitle: userData[Constants.dbFieldUsersName], + profileImageUrl: userData[Constants.dbFieldUsersProfilePic], ), ), ); diff --git a/lib/pages/liked_users_page.dart b/lib/pages/liked_users_page.dart index 6bb180e..1581975 100644 --- a/lib/pages/liked_users_page.dart +++ b/lib/pages/liked_users_page.dart @@ -340,6 +340,7 @@ class LikedUsersPageState extends State { receiverEmail: user[Constants.dbFieldUsersEmail], receiverID: user[Constants.dbFieldUsersID], chatTitle: user[Constants.dbFieldUsersName], + profileImageUrl: user[Constants.dbFieldUsersProfilePic], ), ), ); diff --git a/lib/pages/user_matching_page.dart b/lib/pages/user_matching_page.dart index 2701ed4..65abe67 100644 --- a/lib/pages/user_matching_page.dart +++ b/lib/pages/user_matching_page.dart @@ -261,6 +261,7 @@ class UserMatchingPageState extends State { receiverEmail: swipedUser.email, receiverID: swipedUser.uid, chatTitle: swipedUser.name, + profileImageUrl: swipedUser.profilePictureUrl, ), ), );