Skip to content

Commit

Permalink
lightbox: Add user's avatar on the lightbox app bar
Browse files Browse the repository at this point in the history
This change updates the lightbox to display the message author's avatar
alongside their name and the date in the app bar. The avatar is
positioned in the "start" direction (left for LTR layouts, right for
RTL layouts) to align with the behavior in the React Native app.

Fixes: #41
  • Loading branch information
shivanshsharma13 authored and gnprice committed Jan 7, 2025
1 parent 7d64e2f commit 0b90e42
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
33 changes: 18 additions & 15 deletions lib/widgets/lightbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,24 @@ class _LightboxPageLayoutState extends State<_LightboxPageLayout> {
backgroundColor: appBarBackgroundColor,
shape: const Border(), // Remove bottom border from [AppBarTheme]
elevation: appBarElevation,

// TODO(#41): Show message author's avatar
title: RichText(
text: TextSpan(children: [
TextSpan(
text: '${widget.message.senderFullName}\n',

// Restate default
style: themeData.textTheme.titleLarge!.copyWith(color: appBarForegroundColor)),
TextSpan(
text: timestampText,

// Make smaller, like a subtitle
style: themeData.textTheme.titleSmall!.copyWith(color: appBarForegroundColor)),
])),
title: Row(children: [
Avatar(size: 36, borderRadius: 36 / 8, userId: widget.message.senderId),
const SizedBox(width: 8),
Expanded(
child: RichText(
text: TextSpan(children: [
TextSpan(
text: '${widget.message.senderFullName}\n',

// Restate default
style: themeData.textTheme.titleLarge!.copyWith(color: appBarForegroundColor)),
TextSpan(
text: timestampText,

// Make smaller, like a subtitle
style: themeData.textTheme.titleSmall!.copyWith(color: appBarForegroundColor)),
]))),
]),
bottom: widget.buildAppBarBottom(context));
}

Expand Down
11 changes: 11 additions & 0 deletions test/widgets/lightbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ void main() {
debugNetworkImageHttpClientProvider = null;
});

testWidgets('app bar shows sender avatar', (tester) async {
prepareBoringImageHttpClient();
final message = eg.streamMessage(sender: eg.otherUser);
await setupPage(tester, message: message, thumbnailUrl: null);

final avatar = tester.widget<Avatar>(find.byType(Avatar));
check(avatar.userId).equals(message.senderId);

debugNetworkImageHttpClientProvider = null;
});

testWidgets('header and footer hidden and shown by tapping image', (tester) async {
prepareBoringImageHttpClient();
final message = eg.streamMessage(sender: eg.otherUser);
Expand Down

0 comments on commit 0b90e42

Please sign in to comment.