Skip to content

Commit 68af8a9

Browse files
committed
wip narrow: Support MentionsNarrow.
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 464bf12 commit 68af8a9

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

assets/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@
344344
"@loginErrorMissingUsername": {
345345
"description": "Error message when an empty username was provided."
346346
},
347+
"mentionsPageTitle": "Mentions",
348+
"@mentionsPageTitle": {
349+
"description": "Title for the page of @-mentions."
350+
},
347351
"topicValidationErrorTooLong": "Topic length shouldn't be greater than 60 characters.",
348352
"@topicValidationErrorTooLong": {
349353
"description": "Topic validation error when topic is too long."

lib/widgets/app.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ class HomePage extends StatelessWidget {
276276
narrow: const CombinedFeedNarrow())),
277277
child: Text(zulipLocalizations.combinedFeedPageTitle)),
278278
const SizedBox(height: 16),
279+
ElevatedButton(
280+
onPressed: () => Navigator.push(context,
281+
MessageListPage.buildRoute(context: context,
282+
narrow: const MentionsNarrow())),
283+
child: Text(zulipLocalizations.mentionsPageTitle)),
284+
const SizedBox(height: 16),
279285
ElevatedButton(
280286
onPressed: () => Navigator.push(context,
281287
InboxPage.buildRoute(context: context)),

lib/widgets/compose_box.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ class ComposeBox extends StatelessWidget {
967967
return _FixedDestinationComposeBox(key: controllerKey, narrow: narrow);
968968
} else if (narrow is DmNarrow) {
969969
return _FixedDestinationComposeBox(key: controllerKey, narrow: narrow);
970-
} else if (narrow is CombinedFeedNarrow) {
970+
} else if (narrow is CombinedFeedNarrow || narrow is MentionsNarrow) {
971971
return const SizedBox.shrink();
972972
} else {
973973
throw Exception("impossible narrow"); // TODO(dart-3): show this statically

lib/widgets/message_list.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class _MessageListPageState extends State<MessageListPage> {
6363
bool removeAppBarBottomBorder = false;
6464
switch(widget.narrow) {
6565
case CombinedFeedNarrow():
66+
case MentionsNarrow():
6667
appBarBackgroundColor = null; // i.e., inherit
6768

6869
case StreamNarrow(:final streamId):
@@ -149,6 +150,8 @@ class MessageListAppBarTitle extends StatelessWidget {
149150
switch (narrow) {
150151
case CombinedFeedNarrow():
151152
return Text(zulipLocalizations.combinedFeedPageTitle);
153+
case MentionsNarrow():
154+
return Text(zulipLocalizations.mentionsPageTitle);
152155

153156
case StreamNarrow(:var streamId):
154157
final store = PerAccountStoreWidget.of(context);
@@ -340,7 +343,7 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
340343
return _buildItem(data, i);
341344
}));
342345

343-
if (widget.narrow is CombinedFeedNarrow) {
346+
if (widget.narrow is CombinedFeedNarrow || widget.narrow is MentionsNarrow) {
344347
// TODO(#311) If we have a bottom nav, it will pad the bottom
345348
// inset, and this shouldn't be necessary
346349
sliver = SliverSafeArea(sliver: sliver);
@@ -521,7 +524,7 @@ class RecipientHeader extends StatelessWidget {
521524
final message = this.message;
522525
return switch (message) {
523526
StreamMessage() => StreamMessageRecipientHeader(message: message,
524-
showStream: narrow is CombinedFeedNarrow),
527+
showStream: narrow is CombinedFeedNarrow || narrow is MentionsNarrow),
525528
DmMessage() => DmRecipientHeader(message: message),
526529
};
527530
}
@@ -1097,6 +1100,13 @@ Future<void> _legacyMarkNarrowAsRead(BuildContext context, Narrow narrow) async
10971100
switch (narrow) {
10981101
case CombinedFeedNarrow():
10991102
await markAllAsRead(connection);
1103+
case MentionsNarrow():
1104+
final unreadMentions = store.unreads.mentions.toList();
1105+
if (unreadMentions.isEmpty) return;
1106+
await updateMessageFlags(connection,
1107+
messages: unreadMentions,
1108+
op: UpdateMessageFlagsOp.add,
1109+
flag: MessageFlag.read);
11001110
case StreamNarrow(:final streamId):
11011111
await markStreamAsRead(connection, streamId: streamId);
11021112
case TopicNarrow(:final streamId, :final topic):

0 commit comments

Comments
 (0)