Skip to content

Commit fd10604

Browse files
lightbox: Added user's avatar in 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 347e19e commit fd10604

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

lib/widgets/lightbox.dart

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +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-
])),
189-
bottom: widget.buildAppBarBottom(context));
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(
180+
children: [
181+
TextSpan(
182+
text: '${widget.message.senderFullName}\n',
183+
// Restate default
184+
style: themeData.textTheme.titleLarge!.copyWith(color: appBarForegroundColor)),
185+
TextSpan(
186+
text: timestampText,
187+
// Make smaller, like a subtitle
188+
style: themeData.textTheme.titleSmall!.copyWith(color: appBarForegroundColor)),
189+
]))),
190+
]),
191+
bottom: widget.buildAppBarBottom(context));
190192
}
191193

192194
Widget? bottomAppBar;

test/widgets/lightbox_test.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,16 @@ void main() {
236236
debugNetworkImageHttpClientProvider = null;
237237
});
238238

239-
testWidgets('app bar shows sender name and date', (tester) async {
239+
testWidgets('app bar shows sender avatar, name and date', (tester) async {
240240
prepareBoringImageHttpClient();
241241
final timestamp = DateTime.parse("2024-07-23 23:12:24").millisecondsSinceEpoch ~/ 1000;
242242
final message = eg.streamMessage(sender: eg.otherUser, timestamp: timestamp);
243243
await setupPage(tester, message: message, thumbnailUrl: null);
244244

245+
// Check Avatar properties
246+
final avatar = tester.widget<Avatar>(find.byType(Avatar));
247+
check(avatar.userId).equals(message.senderId);
248+
245249
// We're looking for a RichText, in the app bar, with both the
246250
// sender's name and the timestamp.
247251
final labelTextWidget = tester.widget<RichText>(

0 commit comments

Comments
 (0)