Skip to content

Commit 81b7a51

Browse files
committed
ui [nfc]: Pull out iconDataFromStream helper
1 parent 98e3527 commit 81b7a51

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

lib/widgets/icons.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
import 'package:flutter/widgets.dart';
33

4+
import '../api/model/model.dart';
5+
46
// ignore_for_file: constant_identifier_names
57

68
/// Identifiers for Zulip's custom icons.
@@ -63,3 +65,13 @@ abstract final class ZulipIcons {
6365

6466
// END GENERATED ICON DATA
6567
}
68+
69+
IconData iconDataFromStream(ZulipStream stream) {
70+
// TODO: these icons aren't quite right yet; see:
71+
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/design.3A.20.23F117.20.22Inbox.22.20screen/near/1680637
72+
return switch(stream) {
73+
ZulipStream(isWebPublic: true) => ZulipIcons.globe,
74+
ZulipStream(inviteOnly: true) => ZulipIcons.lock,
75+
ZulipStream() => ZulipIcons.hash_sign,
76+
};
77+
}

lib/widgets/inbox.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,7 @@ class _StreamHeaderItem extends _HeaderItem {
385385
});
386386

387387
@override get title => subscription.name;
388-
@override get icon => switch (subscription) {
389-
// TODO these icons aren't quite right yet; see this message and the following:
390-
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/design.3A.20.23F117.20.22Inbox.22.20screen/near/1680637
391-
Subscription(isWebPublic: true) => ZulipIcons.globe,
392-
Subscription(inviteOnly: true) => ZulipIcons.lock,
393-
Subscription() => ZulipIcons.hash_sign,
394-
};
388+
@override get icon => iconDataFromStream(subscription);
395389
@override get collapsedIconColor => subscription.colorSwatch().iconOnPlainBackground;
396390
@override get uncollapsedIconColor => subscription.colorSwatch().iconOnBarBackground;
397391
@override get uncollapsedBackgroundColor =>

lib/widgets/message_list.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,8 @@ class MessageListAppBarTitle extends StatelessWidget {
8282
final Narrow narrow;
8383

8484
Widget _buildStreamRow(ZulipStream? stream, String text) {
85-
final icon = switch (stream) {
86-
ZulipStream(isWebPublic: true) => ZulipIcons.globe,
87-
ZulipStream(inviteOnly: true) => ZulipIcons.lock,
88-
ZulipStream() => ZulipIcons.hash_sign,
89-
null => null, // A null [Icon.icon] makes a blank space.
90-
};
85+
// A null [Icon.icon] makes a blank space.
86+
final icon = (stream != null) ? iconDataFromStream(stream) : null;
9187
return Row(
9288
mainAxisSize: MainAxisSize.min,
9389
// TODO(design): The vertical alignment of the stream privacy icon is a bit ad hoc.

0 commit comments

Comments
 (0)