Skip to content

Commit 0b90e42

Browse files
shivanshsharma13gnprice
authored andcommitted
lightbox: Add user's avatar on the lightbox app bar
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
1 parent 7d64e2f commit 0b90e42

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

lib/widgets/lightbox.dart

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,24 @@ class _LightboxPageLayoutState extends State<_LightboxPageLayout> {
171171
backgroundColor: appBarBackgroundColor,
172172
shape: const Border(), // Remove bottom border from [AppBarTheme]
173173
elevation: appBarElevation,
174-
175-
// TODO(#41): Show message author's avatar
176-
title: RichText(
177-
text: TextSpan(children: [
178-
TextSpan(
179-
text: '${widget.message.senderFullName}\n',
180-
181-
// Restate default
182-
style: themeData.textTheme.titleLarge!.copyWith(color: appBarForegroundColor)),
183-
TextSpan(
184-
text: timestampText,
185-
186-
// Make smaller, like a subtitle
187-
style: themeData.textTheme.titleSmall!.copyWith(color: appBarForegroundColor)),
188-
])),
174+
title: Row(children: [
175+
Avatar(size: 36, borderRadius: 36 / 8, userId: widget.message.senderId),
176+
const SizedBox(width: 8),
177+
Expanded(
178+
child: RichText(
179+
text: TextSpan(children: [
180+
TextSpan(
181+
text: '${widget.message.senderFullName}\n',
182+
183+
// Restate default
184+
style: themeData.textTheme.titleLarge!.copyWith(color: appBarForegroundColor)),
185+
TextSpan(
186+
text: timestampText,
187+
188+
// Make smaller, like a subtitle
189+
style: themeData.textTheme.titleSmall!.copyWith(color: appBarForegroundColor)),
190+
]))),
191+
]),
189192
bottom: widget.buildAppBarBottom(context));
190193
}
191194

test/widgets/lightbox_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ void main() {
254254
debugNetworkImageHttpClientProvider = null;
255255
});
256256

257+
testWidgets('app bar shows sender avatar', (tester) async {
258+
prepareBoringImageHttpClient();
259+
final message = eg.streamMessage(sender: eg.otherUser);
260+
await setupPage(tester, message: message, thumbnailUrl: null);
261+
262+
final avatar = tester.widget<Avatar>(find.byType(Avatar));
263+
check(avatar.userId).equals(message.senderId);
264+
265+
debugNetworkImageHttpClientProvider = null;
266+
});
267+
257268
testWidgets('header and footer hidden and shown by tapping image', (tester) async {
258269
prepareBoringImageHttpClient();
259270
final message = eg.streamMessage(sender: eg.otherUser);

0 commit comments

Comments
 (0)