Skip to content

Commit

Permalink
wiplink msglist: Add channel-feed action from topic narrows
Browse files Browse the repository at this point in the history
Fixes: 1040
  • Loading branch information
gnprice committed Nov 22, 2024
1 parent f47848c commit 4f9fa43
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,10 @@
"@starredMessagesPageTitle": {
"description": "Title for the page of starred messages."
},
"channelFeedButtonTooltip": "Channel feed",
"@channelFeedButtonTooltip": {
"description": "Tooltip for button to navigate to a given channel's feed"
},
"notifGroupDmConversationLabel": "{senderFullName} to you and {numOthers, plural, =1{1 other} other{{numOthers} others}}",
"@notifGroupDmConversationLabel": {
"description": "Label for a group DM conversation notification.",
Expand Down
6 changes: 6 additions & 0 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,12 @@ abstract class ZulipLocalizations {
/// **'Starred messages'**
String get starredMessagesPageTitle;

/// Tooltip for button to navigate to a given channel's feed
///
/// In en, this message translates to:
/// **'Channel feed'**
String get channelFeedButtonTooltip;

/// Label for a group DM conversation notification.
///
/// In en, this message translates to:
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
@override
String get starredMessagesPageTitle => 'Starred messages';

@override
String get channelFeedButtonTooltip => 'Channel feed';

@override
String notifGroupDmConversationLabel(String senderFullName, int numOthers) {
String _temp0 = intl.Intl.pluralLogic(
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
@override
String get starredMessagesPageTitle => 'Starred messages';

@override
String get channelFeedButtonTooltip => 'Channel feed';

@override
String notifGroupDmConversationLabel(String senderFullName, int numOthers) {
String _temp0 = intl.Intl.pluralLogic(
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
@override
String get starredMessagesPageTitle => 'Starred messages';

@override
String get channelFeedButtonTooltip => 'Channel feed';

@override
String notifGroupDmConversationLabel(String senderFullName, int numOthers) {
String _temp0 = intl.Intl.pluralLogic(
Expand Down
12 changes: 12 additions & 0 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final messageListTheme = MessageListTheme.of(context);
final zulipLocalizations = ZulipLocalizations.of(context);

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

List<Widget>? actions;
if (narrow case TopicNarrow(:final streamId)) {
(actions ??= []).add(IconButton(
icon: const Icon(ZulipIcons.message_feed),
tooltip: zulipLocalizations.channelFeedButtonTooltip,
onPressed: () => Navigator.push(context,
MessageListPage.buildRoute(context: context,
narrow: ChannelNarrow(streamId)))));
}

return Scaffold(
appBar: ZulipAppBar(
title: MessageListAppBarTitle(narrow: narrow),
actions: actions,
backgroundColor: appBarBackgroundColor,
shape: removeAppBarBottomBorder
? const Border()
Expand Down
28 changes: 28 additions & 0 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:zulip/widgets/color.dart';
import 'package:zulip/widgets/content.dart';
import 'package:zulip/widgets/icons.dart';
import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/page.dart';
import 'package:zulip/widgets/store.dart';
import 'package:zulip/widgets/channel_colors.dart';

Expand All @@ -32,8 +33,11 @@ import '../model/test_store.dart';
import '../flutter_checks.dart';
import '../stdlib_checks.dart';
import '../test_images.dart';
import '../test_navigation.dart';
import 'content_checks.dart';
import 'dialog_checks.dart';
import 'message_list_checks.dart';
import 'page_checks.dart';
import 'test_app.dart';

void main() {
Expand All @@ -51,6 +55,7 @@ void main() {
List<User>? users,
List<Subscription>? subscriptions,
UnreadMessagesSnapshot? unreadMsgs,
List<NavigatorObserver> navObservers = const [],
}) async {
TypingNotifier.debugEnable = false;
addTearDown(TypingNotifier.debugReset);
Expand All @@ -72,6 +77,7 @@ void main() {
eg.newestGetMessagesResult(foundOldest: foundOldest, messages: messages).toJson());

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

// global store, per-account store, and message list get loaded
Expand Down Expand Up @@ -126,6 +132,28 @@ void main() {
});
});

group('app bar', () {
testWidgets('has channel-feed action for topic narrows', (tester) async {
final pushedRoutes = <Route<void>>[];
final navObserver = TestNavigatorObserver()
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
final channel = eg.stream();
await setupMessageListPage(tester, narrow: TopicNarrow(channel.streamId, 'hi'),
navObservers: [navObserver],
streams: [channel], messageCount: 1);

// Clear out initial route.
assert(pushedRoutes.length == 1);
pushedRoutes.clear();

// Tap button; it works.
await tester.tap(find.byIcon(ZulipIcons.message_feed));
check(pushedRoutes).single.isA<WidgetRoute>()
.page.isA<MessageListPage>().initNarrow
.equals(ChannelNarrow(channel.streamId));
});
});

group('presents message content appropriately', () {
testWidgets('content not asked to consume insets (including bottom), even without compose box', (tester) async {
// Regression test for: https://github.com/zulip/zulip-flutter/issues/736
Expand Down

0 comments on commit 4f9fa43

Please sign in to comment.