@@ -31,6 +31,10 @@ class SubscriptionListPageBody extends StatefulWidget {
31
31
// https://github.com/zulip/zulip-flutter/pull/1774#discussion_r2249032503
32
32
final bool disableChannelActionSheet;
33
33
final bool hideChannelsIfUserCantPost;
34
+
35
+ /// Callback to invoke when the user selects a channel from the list.
36
+ ///
37
+ /// If null, the default behavior is to navigate to the channel feed.
34
38
final OnChannelSelectCallback ? onChannelSelect;
35
39
// TODO(#412) add onTopicSelect
36
40
@@ -82,6 +86,12 @@ class _SubscriptionListPageBodyState extends State<SubscriptionListPageBody> wit
82
86
});
83
87
}
84
88
89
+ void _handleChannelSelect (ChannelNarrow narrow) {
90
+ Navigator .push (context,
91
+ MessageListPage .buildRoute (context: context,
92
+ narrow: narrow));
93
+ }
94
+
85
95
@override
86
96
Widget build (BuildContext context) {
87
97
// Design referenced from:
@@ -124,6 +134,7 @@ class _SubscriptionListPageBodyState extends State<SubscriptionListPageBody> wit
124
134
message: zulipLocalizations.channelsEmptyPlaceholder);
125
135
}
126
136
137
+ final onChannelSelect = widget.onChannelSelect ?? _handleChannelSelect;
127
138
return SafeArea (
128
139
// Don't pad the bottom here; we want the list content to do that.
129
140
//
@@ -144,15 +155,15 @@ class _SubscriptionListPageBodyState extends State<SubscriptionListPageBody> wit
144
155
unreadsModel: unreadsModel,
145
156
subscriptions: pinned,
146
157
disableChannelActionSheet: widget.disableChannelActionSheet,
147
- onChannelSelect: widget. onChannelSelect),
158
+ onChannelSelect: onChannelSelect),
148
159
],
149
160
if (unpinned.isNotEmpty) ...[
150
161
_SubscriptionListHeader (label: zulipLocalizations.unpinnedSubscriptionsLabel),
151
162
_SubscriptionList (
152
163
unreadsModel: unreadsModel,
153
164
subscriptions: unpinned,
154
165
disableChannelActionSheet: widget.disableChannelActionSheet,
155
- onChannelSelect: widget. onChannelSelect),
166
+ onChannelSelect: onChannelSelect),
156
167
],
157
168
158
169
// TODO(#188): add button leading to "All Streams" page with ability to subscribe
@@ -206,13 +217,13 @@ class _SubscriptionList extends StatelessWidget {
206
217
required this .unreadsModel,
207
218
required this .subscriptions,
208
219
required this .disableChannelActionSheet,
209
- this .onChannelSelect,
220
+ required this .onChannelSelect,
210
221
});
211
222
212
223
final Unreads ? unreadsModel;
213
224
final List <Subscription > subscriptions;
214
225
final bool disableChannelActionSheet;
215
- final OnChannelSelectCallback ? onChannelSelect;
226
+ final OnChannelSelectCallback onChannelSelect;
216
227
217
228
@override
218
229
Widget build (BuildContext context) {
@@ -227,12 +238,7 @@ class _SubscriptionList extends StatelessWidget {
227
238
unreadCount: unreadCount,
228
239
showMutedUnreadBadge: showMutedUnreadBadge,
229
240
disableChannelActionSheet: disableChannelActionSheet,
230
- onChannelSelect: onChannelSelect
231
- ?? (narrow) {
232
- Navigator .push (context,
233
- MessageListPage .buildRoute (context: context,
234
- narrow: narrow));
235
- });
241
+ onChannelSelect: onChannelSelect);
236
242
});
237
243
}
238
244
}
0 commit comments