@@ -13,16 +13,21 @@ import 'text.dart';
13
13
import 'theme.dart' ;
14
14
import 'unread_count_badge.dart' ;
15
15
16
+ typedef OnChannelSelectCallback = void Function (ChannelNarrow narrow);
17
+
16
18
/// Scrollable listing of subscribed streams.
17
19
class SubscriptionListPageBody extends StatefulWidget {
18
20
const SubscriptionListPageBody ({
19
21
super .key,
20
22
this .disableChannelActionSheet = false ,
21
23
this .hideChannelsIfUserCantPost = false ,
24
+ this .onChannelSelect,
22
25
});
23
26
24
27
final bool disableChannelActionSheet;
25
28
final bool hideChannelsIfUserCantPost;
29
+ final OnChannelSelectCallback ? onChannelSelect;
30
+ // TODO(#412) add onTopicSelect
26
31
27
32
@override
28
33
State <SubscriptionListPageBody > createState () => _SubscriptionListPageBodyState ();
@@ -122,14 +127,16 @@ class _SubscriptionListPageBodyState extends State<SubscriptionListPageBody> wit
122
127
_SubscriptionList (
123
128
unreadsModel: unreadsModel,
124
129
subscriptions: pinned,
125
- disableChannelActionSheet: widget.disableChannelActionSheet),
130
+ disableChannelActionSheet: widget.disableChannelActionSheet,
131
+ onChannelSelect: widget.onChannelSelect),
126
132
],
127
133
if (unpinned.isNotEmpty) ...[
128
134
_SubscriptionListHeader (label: zulipLocalizations.unpinnedSubscriptionsLabel),
129
135
_SubscriptionList (
130
136
unreadsModel: unreadsModel,
131
137
subscriptions: unpinned,
132
- disableChannelActionSheet: widget.disableChannelActionSheet),
138
+ disableChannelActionSheet: widget.disableChannelActionSheet,
139
+ onChannelSelect: widget.onChannelSelect),
133
140
],
134
141
135
142
// TODO(#188): add button leading to "All Streams" page with ability to subscribe
@@ -180,11 +187,13 @@ class _SubscriptionList extends StatelessWidget {
180
187
required this .unreadsModel,
181
188
required this .subscriptions,
182
189
required this .disableChannelActionSheet,
190
+ this .onChannelSelect,
183
191
});
184
192
185
193
final Unreads ? unreadsModel;
186
194
final List <Subscription > subscriptions;
187
195
final bool disableChannelActionSheet;
196
+ final OnChannelSelectCallback ? onChannelSelect;
188
197
189
198
@override
190
199
Widget build (BuildContext context) {
@@ -198,7 +207,13 @@ class _SubscriptionList extends StatelessWidget {
198
207
return SubscriptionItem (subscription: subscription,
199
208
unreadCount: unreadCount,
200
209
showMutedUnreadBadge: showMutedUnreadBadge,
201
- disableChannelActionSheet: disableChannelActionSheet);
210
+ disableChannelActionSheet: disableChannelActionSheet,
211
+ onChannelSelect: onChannelSelect
212
+ ?? (narrow) {
213
+ Navigator .push (context,
214
+ MessageListPage .buildRoute (context: context,
215
+ narrow: narrow));
216
+ });
202
217
});
203
218
}
204
219
}
@@ -211,12 +226,14 @@ class SubscriptionItem extends StatelessWidget {
211
226
required this .unreadCount,
212
227
required this .showMutedUnreadBadge,
213
228
required this .disableChannelActionSheet,
229
+ required this .onChannelSelect,
214
230
});
215
231
216
232
final Subscription subscription;
217
233
final int unreadCount;
218
234
final bool showMutedUnreadBadge;
219
235
final bool disableChannelActionSheet;
236
+ final OnChannelSelectCallback onChannelSelect;
220
237
221
238
@override
222
239
Widget build (BuildContext context) {
@@ -229,11 +246,7 @@ class SubscriptionItem extends StatelessWidget {
229
246
// TODO(design) check if this is the right variable
230
247
color: designVariables.background,
231
248
child: InkWell (
232
- onTap: () {
233
- Navigator .push (context,
234
- MessageListPage .buildRoute (context: context,
235
- narrow: ChannelNarrow (subscription.streamId)));
236
- },
249
+ onTap: () => onChannelSelect (ChannelNarrow (subscription.streamId)),
237
250
onLongPress: ! disableChannelActionSheet
238
251
? () => showChannelActionSheet (context, channelId: subscription.streamId)
239
252
: null ,
0 commit comments