Skip to content

Commit

Permalink
Update message_list.dart
Browse files Browse the repository at this point in the history
Add avatars to DM recipient headers.

Display user avatars alongside names in DM recipient headers, making conversations more visually identifiable. This matches the RN app's behavior

The changes:

- Add Avatar widgets in DM recipient headers
- Maintain consistent sizing and spacing (35px size, 8px right padding)
- Handle overflow gracefully for both avatars and names

Fixes #41
  • Loading branch information
shivanshsharma13 committed Dec 1, 2024
1 parent 347e19e commit a1e4aff
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,40 @@ class MessageListAppBarTitle extends StatelessWidget {

case DmNarrow(:var otherRecipientIds):
final store = PerAccountStoreWidget.of(context);
if (otherRecipientIds.isEmpty) {
return const Text("DMs with yourself");
} else {
final names = otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)');
return Text("DMs with ${names.join(", ")}"); // TODO show avatars
}
return Row(
children: [
if (otherRecipientIds.isEmpty)
Padding(
padding: const EdgeInsets.only(right: 8),
child: Avatar(
size: 35,
borderRadius: 32 / 8,
userId: store.selfUserId,
),
)
else
...otherRecipientIds.map(
(id) => Padding(
padding: const EdgeInsets.only(right: 8),
child: Avatar(
size: 35,
borderRadius: 32 / 8,
userId: id,
),
),
),
Expanded(
child: Text(
otherRecipientIds.isEmpty
? store.users[store.selfUserId]?.fullName ?? '(unknown user)'
: otherRecipientIds
.map((id) => store.users[id]?.fullName ?? '(unknown user)')
.join(", "),
overflow: TextOverflow.ellipsis,
),
),
],
);
}
}
}
Expand Down

0 comments on commit a1e4aff

Please sign in to comment.