Skip to content

Commit ef9d184

Browse files
committed
ui [nfc]: Pull out iconDataForStream helper
1 parent a1da95a commit ef9d184

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

lib/widgets/icons.dart

Lines changed: 13 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,14 @@ abstract final class ZulipIcons {
6365

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

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 => iconDataForStream(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
@@ -88,12 +88,8 @@ class MessageListAppBarTitle extends StatelessWidget {
8888
final Narrow narrow;
8989

9090
Widget _buildStreamRow(ZulipStream? stream, String text) {
91-
final icon = switch (stream) {
92-
ZulipStream(isWebPublic: true) => ZulipIcons.globe,
93-
ZulipStream(inviteOnly: true) => ZulipIcons.lock,
94-
ZulipStream() => ZulipIcons.hash_sign,
95-
null => null, // A null [Icon.icon] makes a blank space.
96-
};
91+
// A null [Icon.icon] makes a blank space.
92+
final icon = (stream != null) ? iconDataForStream(stream) : null;
9793
return Row(
9894
mainAxisSize: MainAxisSize.min,
9995
// TODO(design): The vertical alignment of the stream privacy icon is a bit ad hoc.

0 commit comments

Comments
 (0)