Skip to content

Commit 089c2c9

Browse files
committed
msglist: Update message layout to new design
Adjusted a test that was broken by the layout change. Fixes-partly: zulip#157
1 parent b8c89d1 commit 089c2c9

File tree

2 files changed

+44
-40
lines changed

2 files changed

+44
-40
lines changed

lib/widgets/message_list.dart

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -857,60 +857,64 @@ class MessageWithPossibleSender extends StatelessWidget {
857857

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

873897
return GestureDetector(
874898
behavior: HitTestBehavior.translucent,
875899
onLongPress: () => showMessageActionSheet(context: context, message: message),
876900
child: Padding(
877-
padding: const EdgeInsets.only(top: 2, bottom: 3, left: 8, right: 8),
901+
padding: const EdgeInsets.symmetric(vertical: 4),
878902
child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
879-
item.showSender
880-
? Padding(
881-
padding: const EdgeInsets.fromLTRB(3, 6, 11, 0),
882-
child: GestureDetector(
883-
onTap: () => Navigator.push(context,
884-
ProfilePage.buildRoute(context: context,
885-
userId: message.senderId)),
886-
child: Avatar(size: 35, borderRadius: 4,
887-
userId: message.senderId)))
888-
: const SizedBox(width: 3 + 35 + 11),
903+
const SizedBox(width: 16),
889904
Expanded(
890905
child: Column(
891906
crossAxisAlignment: CrossAxisAlignment.stretch,
892907
children: [
893-
if (item.showSender) ...[
894-
const SizedBox(height: 3),
895-
senderRow!,
908+
if (senderRow != null) ...[
909+
const SizedBox(height: 2),
910+
senderRow,
896911
const SizedBox(height: 4),
897912
],
898913
MessageContent(message: message, content: item.content),
899914
if ((message.reactions?.total ?? 0) > 0)
900915
ReactionChipsList(messageId: message.id, reactions: message.reactions!)
901916
])),
902-
Container(
903-
width: 80,
904-
padding: const EdgeInsets.only(top: 4, right: 16 - 8),
905-
alignment: Alignment.topRight,
906-
child: Text(time,
907-
style: TextStyle(
908-
color: _kMessageTimestampColor,
909-
fontFamily: 'Source Sans 3',
910-
fontSize: 16,
911-
height: (18 / 16),
912-
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
913-
).merge(weightVariableTextStyle(context)))),
917+
const SizedBox(width: 16),
914918
])));
915919
}
916920
}

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)