Skip to content

Commit

Permalink
msglist: Add stream icon to recipient headers
Browse files Browse the repository at this point in the history
Fixes: zulip#220
  • Loading branch information
sirpengi committed Nov 24, 2023
1 parent c012b7a commit d44c6a8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,12 @@ class StreamMessageRecipientHeader extends StatelessWidget {
MessageListPage.buildRoute(context: context,
narrow: StreamNarrow(message.streamId))),
child: Row(children: [
const SizedBox(width: 16),
// TODO globe/lock icons for web-public and private streams
Padding(
// Figma shows 5px spacing but 6px here matches better visually.
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 11),
child: Icon(size: 18, color: swatch.iconOnBarBackground,
// A null [Icon.icon] makes a blank space.
(stream != null) ? iconDataForStream(stream) : null)),
Padding(
padding: const EdgeInsets.symmetric(vertical: 11),
child: Text(stream?.name ?? message.displayRecipient, // TODO(log) if missing
Expand Down
45 changes: 45 additions & 0 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:zulip/model/localizations.dart';
import 'package:zulip/model/narrow.dart';
import 'package:zulip/model/store.dart';
import 'package:zulip/widgets/content.dart';
import 'package:zulip/widgets/icons.dart';
import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/sticky_header.dart';
import 'package:zulip/widgets/store.dart';
Expand Down Expand Up @@ -247,6 +248,50 @@ void main() {
matching: find.byType(ColoredBox),
))).color.equals(swatch.barBackground);
});

testWidgets('color of stream icon', (tester) async {
final stream = eg.stream(isWebPublic: true);
final subscription = eg.subscription(stream, color: Colors.red.value);
final swatch = subscription.colorSwatch();
await setupMessageListPage(tester,
messages: [message], subscriptions: [subscription]);
await tester.pump();
check(tester.widget<Icon>(find.byIcon(ZulipIcons.globe)))
.color.equals(swatch.iconOnBarBackground);
});

testWidgets('normal streams show hash icon', (tester) async {
final stream = eg.stream(isWebPublic: false, inviteOnly: false);
await setupMessageListPage(tester,
messages: [message], streams: [stream]);
await tester.pump();
check(find.descendant(
of: find.byType(StreamMessageRecipientHeader),
matching: find.byIcon(ZulipIcons.hash_sign),
).evaluate()).length.equals(1);
});

testWidgets('public streams show globe icon', (tester) async {
final stream = eg.stream(isWebPublic: true);
await setupMessageListPage(tester,
messages: [message], streams: [stream]);
await tester.pump();
check(find.descendant(
of: find.byType(StreamMessageRecipientHeader),
matching: find.byIcon(ZulipIcons.globe),
).evaluate()).length.equals(1);
});

testWidgets('private streams show lock icon', (tester) async {
final stream = eg.stream(inviteOnly: true);
await setupMessageListPage(tester,
messages: [message], streams: [stream]);
await tester.pump();
check(find.descendant(
of: find.byType(StreamMessageRecipientHeader),
matching: find.byIcon(ZulipIcons.lock),
).evaluate()).length.equals(1);
});
});

testWidgets('show stream name from message when stream unknown', (tester) async {
Expand Down

0 comments on commit d44c6a8

Please sign in to comment.