Skip to content

Commit 245d9d9

Browse files
chrisbobbegnprice
authored andcommitted
msglist: Colorize channel icon in the app bar, following Figma
The Figma: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6089-28394&m=dev And while we're adding a test for it, also check that the chosen channel icon is the intended one.
1 parent d6a4959 commit 245d9d9

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

lib/widgets/message_list.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,26 @@ class MessageListAppBarTitle extends StatelessWidget {
329329
Widget _buildStreamRow(BuildContext context, {
330330
ZulipStream? stream,
331331
}) {
332+
final store = PerAccountStoreWidget.of(context);
332333
final zulipLocalizations = ZulipLocalizations.of(context);
334+
333335
// A null [Icon.icon] makes a blank space.
334-
final icon = stream != null ? iconDataForStream(stream) : null;
336+
IconData? icon;
337+
Color? iconColor;
338+
if (stream != null) {
339+
icon = iconDataForStream(stream);
340+
iconColor = colorSwatchFor(context, store.subscriptions[stream.streamId])
341+
.iconOnBarBackground;
342+
}
343+
335344
return Row(
336345
mainAxisSize: MainAxisSize.min,
337346
// TODO(design): The vertical alignment of the stream privacy icon is a bit ad hoc.
338347
// For screenshots of some experiments, see:
339348
// https://github.com/zulip/zulip-flutter/pull/219#discussion_r1281024746
340349
crossAxisAlignment: CrossAxisAlignment.center,
341350
children: [
342-
Icon(size: 16, icon),
351+
Icon(size: 16, color: iconColor, icon),
343352
const SizedBox(width: 4),
344353
Flexible(child: Text(
345354
stream?.name ?? zulipLocalizations.unknownChannelName)),

test/widgets/message_list_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import 'package:zulip/model/message_list.dart';
1919
import 'package:zulip/model/narrow.dart';
2020
import 'package:zulip/model/store.dart';
2121
import 'package:zulip/model/typing_status.dart';
22+
import 'package:zulip/widgets/app_bar.dart';
2223
import 'package:zulip/widgets/autocomplete.dart';
2324
import 'package:zulip/widgets/color.dart';
2425
import 'package:zulip/widgets/compose_box.dart';
@@ -211,6 +212,36 @@ void main() {
211212
channel.name, eg.defaultRealmEmptyTopicDisplayName);
212213
});
213214

215+
void testChannelIconInChannelRow(IconData expectedIcon, {
216+
required bool isWebPublic,
217+
required bool inviteOnly,
218+
}) {
219+
final description = 'channel icon in channel row; '
220+
'web-public: $isWebPublic, invite-only: $inviteOnly';
221+
testWidgets(description, (tester) async {
222+
final color = 0xff95a5fd;
223+
224+
final channel = eg.stream(isWebPublic: isWebPublic, inviteOnly: inviteOnly);
225+
final subscription = eg.subscription(channel, color: color);
226+
227+
await setupMessageListPage(tester,
228+
narrow: ChannelNarrow(channel.streamId),
229+
streams: [channel],
230+
subscriptions: [subscription],
231+
messages: [eg.streamMessage(stream: channel)]);
232+
233+
final iconElement = tester.element(find.descendant(
234+
of: find.byType(ZulipAppBar),
235+
matching: find.byIcon(expectedIcon)));
236+
237+
check(Theme.brightnessOf(iconElement)).equals(Brightness.light);
238+
check(iconElement.widget as Icon).color.equals(Color(0xff5972fc));
239+
});
240+
}
241+
testChannelIconInChannelRow(ZulipIcons.globe, isWebPublic: true, inviteOnly: false);
242+
testChannelIconInChannelRow(ZulipIcons.lock, isWebPublic: false, inviteOnly: true);
243+
testChannelIconInChannelRow(ZulipIcons.hash_sign, isWebPublic: false, inviteOnly: false);
244+
214245
testWidgets('has channel-feed action for topic narrows', (tester) async {
215246
final pushedRoutes = <Route<void>>[];
216247
final navObserver = TestNavigatorObserver()

0 commit comments

Comments
 (0)