Skip to content

Commit 3293ac5

Browse files
committed
msglist: Update message layout to new design
Test 'basic' in group 'fetch older messages on scroll' adjusted as layout change has caused the test to fail.
1 parent 338ff61 commit 3293ac5

File tree

2 files changed

+45
-42
lines changed

2 files changed

+45
-42
lines changed

lib/widgets/message_list.dart

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -854,62 +854,65 @@ class MessageWithPossibleSender extends StatelessWidget {
854854
final message = item.message;
855855

856856
final Widget? senderRow = item.showSender
857-
? GestureDetector(
858-
onTap: () => Navigator.push(context,
859-
ProfilePage.buildRoute(context: context,
860-
userId: message.senderId)),
861-
child: Text(message.senderFullName, // TODO get from user data
862-
style: const TextStyle(
863-
fontFamily: 'Source Sans 3',
864-
fontSize: 18,
865-
height: (22 / 18),
866-
).merge(weightVariableTextStyle(context, wght: 600,
867-
wghtIfPlatformRequestsBold: 900))))
857+
? Row(
858+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
859+
crossAxisAlignment: CrossAxisAlignment.baseline,
860+
textBaseline: TextBaseline.alphabetic,
861+
children: [
862+
Flexible(
863+
child: GestureDetector(
864+
onTap: () => Navigator.push(context,
865+
ProfilePage.buildRoute(context: context,
866+
userId: message.senderId)),
867+
child: Row(
868+
children: [
869+
Avatar(size: 32, borderRadius: 3,
870+
userId: message.senderId),
871+
const SizedBox(width: 8),
872+
Flexible(
873+
child: Text(message.senderFullName, // TODO get from user data
874+
style: const TextStyle(
875+
fontFamily: 'Source Sans 3',
876+
fontSize: 18,
877+
height: (22 / 18),
878+
).merge(weightVariableTextStyle(context, wght: 600,
879+
wghtIfPlatformRequestsBold: 900)),
880+
overflow: TextOverflow.ellipsis)),
881+
]))),
882+
Text(
883+
_kMessageTimestampFormat.format(
884+
DateTime.fromMillisecondsSinceEpoch(1000 * message.timestamp)),
885+
style: TextStyle(
886+
color: _kMessageTimestampColor,
887+
fontFamily: 'Source Sans 3',
888+
fontSize: 16,
889+
height: (18 / 16),
890+
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
891+
).merge(weightVariableTextStyle(context))),
892+
])
868893
: null;
869894

870895
return GestureDetector(
871896
behavior: HitTestBehavior.translucent,
872897
onLongPress: () => showMessageActionSheet(context: context, message: message),
873898
child: Padding(
874-
padding: const EdgeInsets.only(top: 2, bottom: 3, left: 8, right: 8),
899+
padding: const EdgeInsets.symmetric(vertical: 4),
875900
child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
876-
item.showSender
877-
? Padding(
878-
padding: const EdgeInsets.fromLTRB(3, 6, 11, 0),
879-
child: GestureDetector(
880-
onTap: () => Navigator.push(context,
881-
ProfilePage.buildRoute(context: context,
882-
userId: message.senderId)),
883-
child: Avatar(size: 35, borderRadius: 4,
884-
userId: message.senderId)))
885-
: const SizedBox(width: 3 + 35 + 11),
901+
const SizedBox(width: 16),
886902
Expanded(
887903
child: Column(
888904
crossAxisAlignment: CrossAxisAlignment.stretch,
889905
children: [
890-
if (item.showSender) ...[
891-
const SizedBox(height: 3),
892-
senderRow!,
906+
if (senderRow != null) ...[
907+
const SizedBox(height: 2),
908+
senderRow,
893909
const SizedBox(height: 4),
894910
],
895911
MessageContent(message: message, content: item.content),
896912
if ((message.reactions?.total ?? 0) > 0)
897913
ReactionChipsList(messageId: message.id, reactions: message.reactions!)
898914
])),
899-
Container(
900-
width: 80,
901-
padding: const EdgeInsets.only(top: 4, right: 16 - 8),
902-
alignment: Alignment.topRight,
903-
child: Text(
904-
_kMessageTimestampFormat.format(
905-
DateTime.fromMillisecondsSinceEpoch(1000 * message.timestamp)),
906-
style: TextStyle(
907-
color: _kMessageTimestampColor,
908-
fontFamily: 'Source Sans 3',
909-
fontSize: 16,
910-
height: (18 / 16),
911-
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
912-
).merge(weightVariableTextStyle(context)))),
915+
const SizedBox(width: 16),
913916
])));
914917
}
915918
}

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)