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