Skip to content

Commit d95b602

Browse files
sirpengignprice
authored andcommitted
msglist: Add star marker in messages
1 parent b1d902d commit d95b602

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;
@@ -913,7 +915,14 @@ class MessageWithPossibleSender extends StatelessWidget {
913915
if ((message.reactions?.total ?? 0) > 0)
914916
ReactionChipsList(messageId: message.id, reactions: message.reactions!)
915917
])),
916-
const SizedBox(width: 16),
918+
SizedBox(width: 16,
919+
child: message.flags.contains(MessageFlag.starred)
920+
// TODO(#157): fix how star marker aligns with message content
921+
// Design from Figma at:
922+
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=813%3A28817&mode=dev .
923+
? Padding(padding: const EdgeInsets.only(top: 4),
924+
child: Icon(ZulipIcons.star_filled, size: 16, color: _starColor))
925+
: null),
917926
]),
918927
])));
919928
}

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)