Skip to content

Commit 0abdd74

Browse files
subscription_list [nfc]: Allow disabling topic list button in channel action sheet
This will be used soon to avoid unintended flows when sharing content received from other apps.
1 parent 299bd86 commit 0abdd74

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

lib/widgets/action_sheet.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ enum BottomSheetDismissButtonStyle {
241241
/// Needs a [PageRoot] ancestor.
242242
void showChannelActionSheet(BuildContext context, {
243243
required int channelId,
244+
bool showTopicListButton = true,
244245
}) {
245246
final pageContext = PageRoot.contextOf(context);
246247
final store = PerAccountStoreWidget.of(pageContext);
@@ -254,7 +255,8 @@ void showChannelActionSheet(BuildContext context, {
254255
[
255256
if (unreadCount > 0)
256257
MarkChannelAsReadButton(pageContext: pageContext, channelId: channelId),
257-
TopicListButton(pageContext: pageContext, channelId: channelId),
258+
if (showTopicListButton)
259+
TopicListButton(pageContext: pageContext, channelId: channelId),
258260
CopyChannelLinkButton(channelId: channelId, pageContext: pageContext)
259261
],
260262
if (isSubscribed)

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.showTopicListButtonInActionSheet = true,
21+
});
22+
23+
final bool showTopicListButtonInActionSheet;
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+
showTopicListButtonInActionSheet: widget.showTopicListButtonInActionSheet),
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+
showTopicListButtonInActionSheet: widget.showTopicListButtonInActionSheet),
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.showTopicListButtonInActionSheet,
163175
});
164176

165177
final Unreads? unreadsModel;
166178
final List<Subscription> subscriptions;
179+
final bool showTopicListButtonInActionSheet;
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+
showTopicListButtonInActionSheet: showTopicListButtonInActionSheet);
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.showTopicListButtonInActionSheet,
191206
});
192207

193208
final Subscription subscription;
194209
final int unreadCount;
195210
final bool showMutedUnreadBadge;
211+
final bool showTopicListButtonInActionSheet;
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: () => showChannelActionSheet(context,
230+
channelId: subscription.streamId,
231+
showTopicListButton: showTopicListButtonInActionSheet),
214232
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
215233
const SizedBox(width: 16),
216234
Padding(

0 commit comments

Comments
 (0)