@@ -162,6 +162,67 @@ class ActionSheetCancelButton extends StatelessWidget {
162162 }
163163}
164164
165+ /// Show a sheet of actions you can take on a channel.
166+ void showChannelActionSheet (BuildContext context, {
167+ required int streamId,
168+ }) {
169+ final store = PerAccountStoreWidget .of (context);
170+
171+ final optionButtons = < ActionSheetMenuItemButton > [];
172+ final unreadCount = store.unreads.countInChannelNarrow (streamId);
173+ if (unreadCount > 0 ){
174+ optionButtons.add (
175+ MarkChannelAsReadButton (
176+ streamId: streamId,
177+ pageContext: context,
178+ )
179+ );
180+ }
181+ if (optionButtons.isEmpty) {
182+ // TODO(a11y): This case makes a no-op gesture handler; as a consequence,
183+ // we're presenting some UI (to people who use screen-reader software) as
184+ // though it offers a gesture interaction that it doesn't meaningfully
185+ // offer, which is confusing. The solution here is probably to remove this
186+ // is-empty case by having at least one button that's always present,
187+ // such as "copy link to topic".
188+ return ;
189+ }
190+ _showActionSheet (context, optionButtons: optionButtons);
191+ }
192+
193+ class MarkChannelAsReadButton extends ActionSheetMenuItemButton {
194+ const MarkChannelAsReadButton ({
195+ super .key,
196+ required this .streamId,
197+ required super .pageContext
198+ });
199+ final int streamId;
200+
201+ @override
202+ IconData get icon => ZulipIcons .message_checked;
203+
204+ @override
205+ String label (ZulipLocalizations zulipLocalizations) {
206+ return zulipLocalizations.actionSheetOptionMarkChannelAsRead;
207+ }
208+
209+ @override
210+ void onPressed () async {
211+ try {
212+ final narrow = ChannelNarrow (streamId);
213+ await markNarrowAsRead (pageContext, narrow);
214+ } catch (e) {
215+ if (! pageContext.mounted) return ;
216+
217+ showErrorDialog (
218+ context: pageContext,
219+ title: "Failed to mark channel as read" ,
220+ message: e.toString (),
221+ );
222+ }
223+ }
224+ }
225+
165226/// Show a sheet of actions you can take on a topic.
166227void showTopicActionSheet (BuildContext context, {
167228 required int channelId,
0 commit comments