Skip to content

Commit 6bafd23

Browse files
committed
msglist: Add channel-feed action from topic narrows
Fixes: #1040
1 parent 2501b75 commit 6bafd23

File tree

7 files changed

+59
-0
lines changed

7 files changed

+59
-0
lines changed

assets/l10n/app_en.arb

+4
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,10 @@
545545
"@starredMessagesPageTitle": {
546546
"description": "Title for the page of starred messages."
547547
},
548+
"channelFeedButtonTooltip": "Channel feed",
549+
"@channelFeedButtonTooltip": {
550+
"description": "Tooltip for button to navigate to a given channel's feed"
551+
},
548552
"notifGroupDmConversationLabel": "{senderFullName} to you and {numOthers, plural, =1{1 other} other{{numOthers} others}}",
549553
"@notifGroupDmConversationLabel": {
550554
"description": "Label for a group DM conversation notification.",

lib/generated/l10n/zulip_localizations.dart

+6
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,12 @@ abstract class ZulipLocalizations {
823823
/// **'Starred messages'**
824824
String get starredMessagesPageTitle;
825825

826+
/// Tooltip for button to navigate to a given channel's feed
827+
///
828+
/// In en, this message translates to:
829+
/// **'Channel feed'**
830+
String get channelFeedButtonTooltip;
831+
826832
/// Label for a group DM conversation notification.
827833
///
828834
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

+3
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
431431
@override
432432
String get starredMessagesPageTitle => 'Starred messages';
433433

434+
@override
435+
String get channelFeedButtonTooltip => 'Channel feed';
436+
434437
@override
435438
String notifGroupDmConversationLabel(String senderFullName, int numOthers) {
436439
String _temp0 = intl.Intl.pluralLogic(

lib/generated/l10n/zulip_localizations_en.dart

+3
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
431431
@override
432432
String get starredMessagesPageTitle => 'Starred messages';
433433

434+
@override
435+
String get channelFeedButtonTooltip => 'Channel feed';
436+
434437
@override
435438
String notifGroupDmConversationLabel(String senderFullName, int numOthers) {
436439
String _temp0 = intl.Intl.pluralLogic(

lib/generated/l10n/zulip_localizations_ja.dart

+3
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
431431
@override
432432
String get starredMessagesPageTitle => 'Starred messages';
433433

434+
@override
435+
String get channelFeedButtonTooltip => 'Channel feed';
436+
434437
@override
435438
String notifGroupDmConversationLabel(String senderFullName, int numOthers) {
436439
String _temp0 = intl.Intl.pluralLogic(

lib/widgets/message_list.dart

+12
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
233233
Widget build(BuildContext context) {
234234
final store = PerAccountStoreWidget.of(context);
235235
final messageListTheme = MessageListTheme.of(context);
236+
final zulipLocalizations = ZulipLocalizations.of(context);
236237

237238
final Color? appBarBackgroundColor;
238239
bool removeAppBarBottomBorder = false;
@@ -259,9 +260,20 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
259260
removeAppBarBottomBorder = true;
260261
}
261262

263+
List<Widget>? actions;
264+
if (narrow case TopicNarrow(:final streamId)) {
265+
(actions ??= []).add(IconButton(
266+
icon: const Icon(ZulipIcons.message_feed),
267+
tooltip: zulipLocalizations.channelFeedButtonTooltip,
268+
onPressed: () => Navigator.push(context,
269+
MessageListPage.buildRoute(context: context,
270+
narrow: ChannelNarrow(streamId)))));
271+
}
272+
262273
return Scaffold(
263274
appBar: ZulipAppBar(
264275
title: MessageListAppBarTitle(narrow: narrow),
276+
actions: actions,
265277
backgroundColor: appBarBackgroundColor,
266278
shape: removeAppBarBottomBorder
267279
? const Border()

test/widgets/message_list_test.dart

+28
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import 'package:zulip/widgets/color.dart';
2121
import 'package:zulip/widgets/content.dart';
2222
import 'package:zulip/widgets/icons.dart';
2323
import 'package:zulip/widgets/message_list.dart';
24+
import 'package:zulip/widgets/page.dart';
2425
import 'package:zulip/widgets/store.dart';
2526
import 'package:zulip/widgets/channel_colors.dart';
2627

@@ -32,8 +33,11 @@ import '../model/test_store.dart';
3233
import '../flutter_checks.dart';
3334
import '../stdlib_checks.dart';
3435
import '../test_images.dart';
36+
import '../test_navigation.dart';
3537
import 'content_checks.dart';
3638
import 'dialog_checks.dart';
39+
import 'message_list_checks.dart';
40+
import 'page_checks.dart';
3741
import 'test_app.dart';
3842

3943
void main() {
@@ -51,6 +55,7 @@ void main() {
5155
List<User>? users,
5256
List<Subscription>? subscriptions,
5357
UnreadMessagesSnapshot? unreadMsgs,
58+
List<NavigatorObserver> navObservers = const [],
5459
}) async {
5560
TypingNotifier.debugEnable = false;
5661
addTearDown(TypingNotifier.debugReset);
@@ -72,6 +77,7 @@ void main() {
7277
eg.newestGetMessagesResult(foundOldest: foundOldest, messages: messages).toJson());
7378

7479
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
80+
navigatorObservers: navObservers,
7581
child: MessageListPage(initNarrow: narrow)));
7682

7783
// global store, per-account store, and message list get loaded
@@ -126,6 +132,28 @@ void main() {
126132
});
127133
});
128134

135+
group('app bar', () {
136+
testWidgets('has channel-feed action for topic narrows', (tester) async {
137+
final pushedRoutes = <Route<void>>[];
138+
final navObserver = TestNavigatorObserver()
139+
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
140+
final channel = eg.stream();
141+
await setupMessageListPage(tester, narrow: TopicNarrow(channel.streamId, 'hi'),
142+
navObservers: [navObserver],
143+
streams: [channel], messageCount: 1);
144+
145+
// Clear out initial route.
146+
assert(pushedRoutes.length == 1);
147+
pushedRoutes.clear();
148+
149+
// Tap button; it works.
150+
await tester.tap(find.byIcon(ZulipIcons.message_feed));
151+
check(pushedRoutes).single.isA<WidgetRoute>()
152+
.page.isA<MessageListPage>().initNarrow
153+
.equals(ChannelNarrow(channel.streamId));
154+
});
155+
});
156+
129157
group('presents message content appropriately', () {
130158
testWidgets('content not asked to consume insets (including bottom), even without compose box', (tester) async {
131159
// Regression test for: https://github.com/zulip/zulip-flutter/issues/736

0 commit comments

Comments
 (0)