Skip to content

Commit be2bda0

Browse files
committed
msglist: Add star marker in messages
1 parent d4dbd5a commit be2bda0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/widgets/message_list.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,8 @@ class MessageWithPossibleSender extends StatelessWidget {
849849

850850
final MessageListMessageItem item;
851851

852+
static final _starColor = const HSLColor.fromAHSL(0.5, 47, 1, 0.41).toColor();
853+
852854
@override
853855
Widget build(BuildContext context) {
854856
final message = item.message;
@@ -911,7 +913,14 @@ class MessageWithPossibleSender extends StatelessWidget {
911913
if ((message.reactions?.total ?? 0) > 0)
912914
ReactionChipsList(messageId: message.id, reactions: message.reactions!)
913915
])),
914-
const SizedBox(width: 16),
916+
SizedBox(width: 16,
917+
child: message.flags.contains(MessageFlag.starred)
918+
// TODO(#157): fix how star marker aligns with message content
919+
// Design from Figma at:
920+
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=813%3A28817&mode=dev .
921+
? Padding(padding: const EdgeInsets.only(top: 4),
922+
child: Icon(ZulipIcons.star_filled, size: 16, color: _starColor))
923+
: null),
915924
]),
916925
])));
917926
}

test/widgets/message_list_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,20 @@ void main() {
455455
});
456456
});
457457

458+
group('Starred messages', () {
459+
testWidgets('unstarred message', (WidgetTester tester) async {
460+
final message = eg.streamMessage(flags: []);
461+
await setupMessageListPage(tester, messages: [message]);
462+
check(find.byIcon(ZulipIcons.star_filled).evaluate()).isEmpty();
463+
});
464+
465+
testWidgets('starred message', (WidgetTester tester) async {
466+
final message = eg.streamMessage(flags: [MessageFlag.starred]);
467+
await setupMessageListPage(tester, messages: [message]);
468+
check(find.byIcon(ZulipIcons.star_filled).evaluate()).length.equals(1);
469+
});
470+
});
471+
458472
group('_UnreadMarker animations', () {
459473
// TODO: Improve animation state testing so it is less tied to
460474
// implementation details and more focused on output, see:

0 commit comments

Comments
 (0)