Skip to content

Commit e745ebf

Browse files
committed
msglist: Colorize channel icon in the app bar, following Figma
Following 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 4effb82 commit e745ebf

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-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: 32 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';
@@ -27,6 +28,7 @@ import 'package:zulip/widgets/message_list.dart';
2728
import 'package:zulip/widgets/page.dart';
2829
import 'package:zulip/widgets/store.dart';
2930
import 'package:zulip/widgets/channel_colors.dart';
31+
import 'package:zulip/widgets/theme.dart';
3032

3133
import '../api/fake_api.dart';
3234
import '../example_data.dart' as eg;
@@ -208,6 +210,36 @@ void main() {
208210
channel.name, eg.defaultRealmEmptyTopicDisplayName);
209211
});
210212

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

0 commit comments

Comments
 (0)