Skip to content

Commit 1d3d41d

Browse files
committed
msglist: Consolidate sender avatar, name and message time into same row
Test 'basic' in group 'fetch older messages on scroll' adjusted as layout tweaks have caused the test to fail.
1 parent 2305836 commit 1d3d41d

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

lib/widgets/message_list.dart

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -861,51 +861,47 @@ class MessageWithPossibleSender extends StatelessWidget {
861861
child: Padding(
862862
padding: const EdgeInsets.only(top: 2, bottom: 3, left: 8, right: 8),
863863
child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
864-
item.showSender
865-
? Padding(
866-
padding: const EdgeInsets.fromLTRB(3, 6, 11, 0),
867-
child: GestureDetector(
868-
onTap: () => Navigator.push(context,
869-
ProfilePage.buildRoute(context: context,
870-
userId: message.senderId)),
871-
child: Avatar(size: 35, borderRadius: 4,
872-
userId: message.senderId)))
873-
: const SizedBox(width: 3 + 35 + 11),
864+
const SizedBox(width: 3 + 35 + 11),
874865
Expanded(
875866
child: Column(
876867
crossAxisAlignment: CrossAxisAlignment.stretch,
877868
children: [
878869
if (item.showSender) ...[
879870
const SizedBox(height: 3),
880-
GestureDetector(
881-
onTap: () => Navigator.push(context,
882-
ProfilePage.buildRoute(context: context,
883-
userId: message.senderId)),
884-
child: Text(message.senderFullName, // TODO get from user data
885-
style: const TextStyle(
886-
fontFamily: 'Source Sans 3',
887-
fontSize: 18,
888-
height: (22 / 18),
889-
).merge(weightVariableTextStyle(context, wght: 600,
890-
wghtIfPlatformRequestsBold: 900)))),
871+
Row(
872+
children: [
873+
GestureDetector(
874+
onTap: () => Navigator.push(context,
875+
ProfilePage.buildRoute(context: context,
876+
userId: message.senderId)),
877+
child: Row(
878+
children: [
879+
Avatar(size: 35, borderRadius: 4,
880+
userId: message.senderId),
881+
Text(message.senderFullName, // TODO get from user data
882+
style: const TextStyle(
883+
fontFamily: 'Source Sans 3',
884+
fontSize: 18,
885+
height: (22 / 18),
886+
).merge(weightVariableTextStyle(context, wght: 600,
887+
wghtIfPlatformRequestsBold: 900))),
888+
])),
889+
Text(time,
890+
style: TextStyle(
891+
color: _kMessageTimestampColor,
892+
fontFamily: 'Source Sans 3',
893+
fontSize: 16,
894+
height: (18 / 16),
895+
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
896+
).merge(weightVariableTextStyle(context))),
897+
]),
891898
const SizedBox(height: 4),
892899
],
893900
MessageContent(message: message, content: item.content),
894901
if ((message.reactions?.total ?? 0) > 0)
895902
ReactionChipsList(messageId: message.id, reactions: message.reactions!)
896903
])),
897-
Container(
898-
width: 80,
899-
padding: const EdgeInsets.only(top: 4, right: 16 - 8),
900-
alignment: Alignment.topRight,
901-
child: Text(time,
902-
style: TextStyle(
903-
color: _kMessageTimestampColor,
904-
fontFamily: 'Source Sans 3',
905-
fontSize: 16,
906-
height: (18 / 16),
907-
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
908-
).merge(weightVariableTextStyle(context)))),
904+
const SizedBox(width: 80),
909905
])));
910906
}
911907
}

test/widgets/message_list_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ void main() {
8686

8787
testWidgets('basic', (tester) async {
8888
await setupMessageListPage(tester, foundOldest: false,
89-
messages: List.generate(200, (i) => eg.streamMessage(id: 950 + i, sender: eg.selfUser)));
90-
check(itemCount(tester)).equals(203);
89+
messages: List.generate(300, (i) => eg.streamMessage(id: 950 + i, sender: eg.selfUser)));
90+
check(itemCount(tester)).equals(303);
9191

9292
// Fling-scroll upward...
9393
await tester.fling(find.byType(MessageListPage), const Offset(0, 300), 8000);
@@ -100,7 +100,7 @@ void main() {
100100
await tester.pump(Duration.zero); // Allow a frame for the response to arrive.
101101

102102
// Now we have more messages.
103-
check(itemCount(tester)).equals(303);
103+
check(itemCount(tester)).equals(403);
104104
});
105105

106106
testWidgets('observe double-fetch glitch', (tester) async {

0 commit comments

Comments
 (0)