Skip to content

Commit 8451cb2

Browse files
committed
action_sheet: Add "Mark Topic As Read" button
fixes: #1225
1 parent 18b2811 commit 8451cb2

11 files changed

+128
-0
lines changed

assets/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
"@actionSheetOptionUnstarMessage": {
121121
"description": "Label for unstar button on action sheet."
122122
},
123+
"actionSheetOptionMarkTopicAsRead": "Mark Topic As Read",
124+
"@actionSheetOptionMarkTopicAsRead": {
125+
"description": "Option to mark a specific topic as read in the action sheet."
126+
},
123127
"errorWebAuthOperationalErrorTitle": "Something went wrong",
124128
"@errorWebAuthOperationalErrorTitle": {
125129
"description": "Error title when third-party authentication has an operational error (not necessarily caused by invalid credentials)."

lib/generated/l10n/zulip_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ abstract class ZulipLocalizations {
285285
/// **'Unstar message'**
286286
String get actionSheetOptionUnstarMessage;
287287

288+
/// Option to mark a specific topic as read in the action sheet.
289+
///
290+
/// In en, this message translates to:
291+
/// **'Mark Topic As Read'**
292+
String get actionSheetOptionMarkTopicAsRead;
293+
288294
/// Error title when third-party authentication has an operational error (not necessarily caused by invalid credentials).
289295
///
290296
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
100100
@override
101101
String get actionSheetOptionUnstarMessage => 'Unstar message';
102102

103+
@override
104+
String get actionSheetOptionMarkTopicAsRead => 'Mark Topic As Read';
105+
103106
@override
104107
String get errorWebAuthOperationalErrorTitle => 'Something went wrong';
105108

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
100100
@override
101101
String get actionSheetOptionUnstarMessage => 'Unstar message';
102102

103+
@override
104+
String get actionSheetOptionMarkTopicAsRead => 'Mark Topic As Read';
105+
103106
@override
104107
String get errorWebAuthOperationalErrorTitle => 'Something went wrong';
105108

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
100100
@override
101101
String get actionSheetOptionUnstarMessage => 'Unstar message';
102102

103+
@override
104+
String get actionSheetOptionMarkTopicAsRead => 'Mark Topic As Read';
105+
103106
@override
104107
String get errorWebAuthOperationalErrorTitle => 'Something went wrong';
105108

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
100100
@override
101101
String get actionSheetOptionUnstarMessage => 'Unstar message';
102102

103+
@override
104+
String get actionSheetOptionMarkTopicAsRead => 'Mark Topic As Read';
105+
103106
@override
104107
String get errorWebAuthOperationalErrorTitle => 'Something went wrong';
105108

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
100100
@override
101101
String get actionSheetOptionUnstarMessage => 'Odbierz gwiazdkę';
102102

103+
@override
104+
String get actionSheetOptionMarkTopicAsRead => 'Mark Topic As Read';
105+
103106
@override
104107
String get errorWebAuthOperationalErrorTitle => 'Coś poszło nie tak';
105108

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
100100
@override
101101
String get actionSheetOptionUnstarMessage => 'Снять отметку с сообщения';
102102

103+
@override
104+
String get actionSheetOptionMarkTopicAsRead => 'Mark Topic As Read';
105+
103106
@override
104107
String get errorWebAuthOperationalErrorTitle => 'Что-то пошло не так';
105108

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
100100
@override
101101
String get actionSheetOptionUnstarMessage => 'Odhviezdičkovať správu';
102102

103+
@override
104+
String get actionSheetOptionMarkTopicAsRead => 'Mark Topic As Read';
105+
103106
@override
104107
String get errorWebAuthOperationalErrorTitle => 'Niečo sa pokazilo';
105108

lib/widgets/action_sheet.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ void showTopicActionSheet(BuildContext context, {
240240
pageContext: context);
241241
}));
242242

243+
final unreadCount = store.unreads.countInTopicNarrow(channelId, topic);
244+
if (unreadCount > 0) {
245+
optionButtons.add(MarkTopicAsReadButton(
246+
channelId: channelId,
247+
topic: topic,
248+
pageContext: context));
249+
}
250+
243251
if (optionButtons.isEmpty) {
244252
// TODO(a11y): This case makes a no-op gesture handler; as a consequence,
245253
// we're presenting some UI (to people who use screen-reader software) as
@@ -372,6 +380,30 @@ class UserTopicUpdateButton extends ActionSheetMenuItemButton {
372380
}
373381
}
374382

383+
class MarkTopicAsReadButton extends ActionSheetMenuItemButton {
384+
const MarkTopicAsReadButton({
385+
super.key,
386+
required this.channelId,
387+
required this.topic,
388+
required super.pageContext,
389+
});
390+
391+
final int channelId;
392+
final TopicName topic;
393+
394+
@override IconData get icon => ZulipIcons.message_checked;
395+
396+
@override
397+
String label(ZulipLocalizations zulipLocalizations) {
398+
return zulipLocalizations.actionSheetOptionMarkTopicAsRead;
399+
}
400+
401+
@override void onPressed() async {
402+
if (!pageContext.mounted) return;
403+
await markNarrowAsRead(pageContext, TopicNarrow(channelId, topic));
404+
}
405+
}
406+
375407
/// Show a sheet of actions you can take on a message in the message list.
376408
///
377409
/// Must have a [MessageListPage] ancestor.

0 commit comments

Comments
 (0)