Skip to content

Commit 1412260

Browse files
committed
ui [nfc]: Pull out iconDataForStream helper
1 parent 98e3527 commit 1412260

File tree

4 files changed

+54
-13
lines changed

4 files changed

+54
-13
lines changed

:q

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
diff --git lib/widgets/icons.dart lib/widgets/icons.dart
2+
index 5c3e2e501..6876325a8 100644
3+
--- lib/widgets/icons.dart
4+
+++ lib/widgets/icons.dart
5+
@@ -66,7 +66,7 @@ abstract final class ZulipIcons {
6+
// END GENERATED ICON DATA
7+
}
8+

9+
-IconData iconDataFromStream(ZulipStream stream) {
10+
+IconData iconDataForStream(ZulipStream stream) {
11+
// TODO: these icons aren't quite right yet; see:
12+
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/design.3A.20.23F117.20.22Inbox.22.20screen/near/1680637
13+
return switch(stream) {
14+
diff --git lib/widgets/inbox.dart lib/widgets/inbox.dart
15+
index fded536d9..8ca6f8c64 100644
16+
--- lib/widgets/inbox.dart
17+
+++ lib/widgets/inbox.dart
18+
@@ -385,7 +385,7 @@ class _StreamHeaderItem extends _HeaderItem {
19+
});
20+

21+
@override get title => subscription.name;
22+
- @override get icon => iconDataFromStream(subscription);
23+
+ @override get icon => iconDataForStream(subscription);
24+
@override get collapsedIconColor => subscription.colorSwatch().iconOnPlainBackground;
25+
@override get uncollapsedIconColor => subscription.colorSwatch().iconOnBarBackground;
26+
@override get uncollapsedBackgroundColor =>
27+
diff --git lib/widgets/message_list.dart lib/widgets/message_list.dart
28+
index c10f4e186..b29ff8052 100644
29+
--- lib/widgets/message_list.dart
30+
+++ lib/widgets/message_list.dart
31+
@@ -83,7 +83,7 @@ class MessageListAppBarTitle extends StatelessWidget {
32+

33+
Widget _buildStreamRow(ZulipStream? stream, String text) {
34+
// A null [Icon.icon] makes a blank space.
35+
- final icon = (stream != null) ? iconDataFromStream(stream) : null;
36+
+ final icon = (stream != null) ? iconDataForStream(stream) : null;
37+
return Row(
38+
mainAxisSize: MainAxisSize.min,
39+
// TODO(design): The vertical alignment of the stream privacy icon is a bit ad hoc.

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 iconDataForStream(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 => 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
@@ -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) ? iconDataForStream(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)