Skip to content

Commit f0121b3

Browse files
subscription_list [nfc]: Add a flag to disable channel action sheet
This will be used soon to avoid unintended flows when sharing content received from other apps.
1 parent 299bd86 commit f0121b3

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

lib/widgets/subscription_list.dart

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import 'unread_count_badge.dart';
1515

1616
/// Scrollable listing of subscribed streams.
1717
class SubscriptionListPageBody extends StatefulWidget {
18-
const SubscriptionListPageBody({super.key});
18+
const SubscriptionListPageBody({
19+
super.key,
20+
this.disableChannelActionSheet = false,
21+
});
22+
23+
final bool disableChannelActionSheet;
1924

2025
@override
2126
State<SubscriptionListPageBody> createState() => _SubscriptionListPageBodyState();
@@ -106,11 +111,17 @@ class _SubscriptionListPageBodyState extends State<SubscriptionListPageBody> wit
106111
slivers: [
107112
if (pinned.isNotEmpty) ...[
108113
_SubscriptionListHeader(label: zulipLocalizations.pinnedSubscriptionsLabel),
109-
_SubscriptionList(unreadsModel: unreadsModel, subscriptions: pinned),
114+
_SubscriptionList(
115+
unreadsModel: unreadsModel,
116+
subscriptions: pinned,
117+
disableChannelActionSheet: widget.disableChannelActionSheet),
110118
],
111119
if (unpinned.isNotEmpty) ...[
112120
_SubscriptionListHeader(label: zulipLocalizations.unpinnedSubscriptionsLabel),
113-
_SubscriptionList(unreadsModel: unreadsModel, subscriptions: unpinned),
121+
_SubscriptionList(
122+
unreadsModel: unreadsModel,
123+
subscriptions: unpinned,
124+
disableChannelActionSheet: widget.disableChannelActionSheet),
114125
],
115126

116127
// TODO(#188): add button leading to "All Streams" page with ability to subscribe
@@ -160,10 +171,12 @@ class _SubscriptionList extends StatelessWidget {
160171
const _SubscriptionList({
161172
required this.unreadsModel,
162173
required this.subscriptions,
174+
required this.disableChannelActionSheet,
163175
});
164176

165177
final Unreads? unreadsModel;
166178
final List<Subscription> subscriptions;
179+
final bool disableChannelActionSheet;
167180

168181
@override
169182
Widget build(BuildContext context) {
@@ -176,7 +189,8 @@ class _SubscriptionList extends StatelessWidget {
176189
&& unreadsModel!.countInChannelNarrow(subscription.streamId) > 0;
177190
return SubscriptionItem(subscription: subscription,
178191
unreadCount: unreadCount,
179-
showMutedUnreadBadge: showMutedUnreadBadge);
192+
showMutedUnreadBadge: showMutedUnreadBadge,
193+
disableChannelActionSheet: disableChannelActionSheet);
180194
});
181195
}
182196
}
@@ -188,11 +202,13 @@ class SubscriptionItem extends StatelessWidget {
188202
required this.subscription,
189203
required this.unreadCount,
190204
required this.showMutedUnreadBadge,
205+
required this.disableChannelActionSheet,
191206
});
192207

193208
final Subscription subscription;
194209
final int unreadCount;
195210
final bool showMutedUnreadBadge;
211+
final bool disableChannelActionSheet;
196212

197213
@override
198214
Widget build(BuildContext context) {
@@ -210,7 +226,9 @@ class SubscriptionItem extends StatelessWidget {
210226
MessageListPage.buildRoute(context: context,
211227
narrow: ChannelNarrow(subscription.streamId)));
212228
},
213-
onLongPress: () => showChannelActionSheet(context, channelId: subscription.streamId),
229+
onLongPress: !disableChannelActionSheet
230+
? () => showChannelActionSheet(context, channelId: subscription.streamId)
231+
: null,
214232
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
215233
const SizedBox(width: 16),
216234
Padding(

0 commit comments

Comments
 (0)