Skip to content

Commit d94b011

Browse files
committed
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 63f712a commit d94b011

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
@@ -297,17 +297,26 @@ class MessageListAppBarTitle extends StatelessWidget {
297297
Widget _buildStreamRow(BuildContext context, {
298298
ZulipStream? stream,
299299
}) {
300+
final store = PerAccountStoreWidget.of(context);
300301
final zulipLocalizations = ZulipLocalizations.of(context);
302+
301303
// A null [Icon.icon] makes a blank space.
302-
final icon = stream != null ? iconDataForStream(stream) : null;
304+
IconData? icon;
305+
Color? iconColor;
306+
if (stream != null) {
307+
icon = iconDataForStream(stream);
308+
iconColor = colorSwatchFor(context, store.subscriptions[stream.streamId])
309+
.iconOnBarBackground;
310+
}
311+
303312
return Row(
304313
mainAxisSize: MainAxisSize.min,
305314
// TODO(design): The vertical alignment of the stream privacy icon is a bit ad hoc.
306315
// For screenshots of some experiments, see:
307316
// https://github.com/zulip/zulip-flutter/pull/219#discussion_r1281024746
308317
crossAxisAlignment: CrossAxisAlignment.center,
309318
children: [
310-
Icon(size: 16, icon),
319+
Icon(size: 16, color: iconColor, icon),
311320
const SizedBox(width: 4),
312321
Flexible(child: Text(
313322
stream?.name ?? zulipLocalizations.unknownChannelName)),

test/widgets/message_list_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:zulip/model/message_list.dart';
1818
import 'package:zulip/model/narrow.dart';
1919
import 'package:zulip/model/store.dart';
2020
import 'package:zulip/model/typing_status.dart';
21+
import 'package:zulip/widgets/app_bar.dart';
2122
import 'package:zulip/widgets/autocomplete.dart';
2223
import 'package:zulip/widgets/color.dart';
2324
import 'package:zulip/widgets/compose_box.dart';
@@ -208,6 +209,36 @@ void main() {
208209
channel.name, eg.defaultRealmEmptyTopicDisplayName);
209210
});
210211

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

0 commit comments

Comments
 (0)