Skip to content

Commit

Permalink
Tap avatar to display user info in the chat list
Browse files Browse the repository at this point in the history
  • Loading branch information
gnowoel committed Jan 20, 2025
1 parent 2734d85 commit 5186ff9
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/widgets/chat_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../services/fireauth.dart';
import '../services/firedata.dart';
import '../services/messaging.dart';
import 'tag.dart';
import 'user_info_loader.dart';

class ChatItem extends StatefulWidget {
final Chat chat;
Expand Down Expand Up @@ -66,6 +67,20 @@ class _ChatItemState extends State<ChatItem> {
}
}

void _showUserInfo(BuildContext context) {
final userId = fireauth.instance.currentUser!.uid;
final otherId = widget.chat.id.replaceFirst(userId, '');

showDialog(
context: context,
builder: (context) => UserInfoLoader(
userId: otherId,
photoURL: widget.chat.partner.photoURL ?? '',
displayName: widget.chat.partner.displayName ?? '',
),
);
}

@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
Expand Down Expand Up @@ -99,9 +114,12 @@ class _ChatItemState extends State<ChatItem> {
child: GestureDetector(
onTap: _enterChat,
child: ListTile(
leading: Text(
widget.chat.partner.photoURL!,
style: TextStyle(fontSize: 36, color: textColor),
leading: GestureDetector(
onTap: () => _showUserInfo(context),
child: Text(
widget.chat.partner.photoURL!,
style: TextStyle(fontSize: 36, color: textColor),
),
),
title: Text(
widget.chat.partner.displayName!,
Expand Down

0 comments on commit 5186ff9

Please sign in to comment.