diff --git a/lib/widgets/action_sheet.dart b/lib/widgets/action_sheet.dart index 92ac06acd9..d575735d8c 100644 --- a/lib/widgets/action_sheet.dart +++ b/lib/widgets/action_sheet.dart @@ -241,9 +241,7 @@ void showChannelActionSheet(BuildContext context, { final pageContext = PageRoot.contextOf(context); final store = PerAccountStoreWidget.of(pageContext); - final optionButtons = [ - TopicListButton(pageContext: pageContext, channelId: channelId), - ]; + final optionButtons = []; final unreadCount = store.unreads.countInChannelNarrow(channelId); if (unreadCount > 0) { @@ -251,14 +249,17 @@ void showChannelActionSheet(BuildContext context, { MarkChannelAsReadButton(pageContext: pageContext, channelId: channelId)); } + optionButtons.add( + TopicListButton(pageContext: pageContext, channelId: channelId)); + optionButtons.add( CopyChannelLinkButton(channelId: channelId, pageContext: pageContext)); _showActionSheet(pageContext, optionButtons: optionButtons); } -class TopicListButton extends ActionSheetMenuItemButton { - const TopicListButton({ +class MarkChannelAsReadButton extends ActionSheetMenuItemButton { + const MarkChannelAsReadButton({ super.key, required this.channelId, required super.pageContext, @@ -267,22 +268,22 @@ class TopicListButton extends ActionSheetMenuItemButton { final int channelId; @override - IconData get icon => ZulipIcons.topics; + IconData get icon => ZulipIcons.message_checked; @override String label(ZulipLocalizations zulipLocalizations) { - return zulipLocalizations.actionSheetOptionListOfTopics; + return zulipLocalizations.actionSheetOptionMarkChannelAsRead; } @override - void onPressed() { - Navigator.push(pageContext, - TopicListPage.buildRoute(context: pageContext, streamId: channelId)); + void onPressed() async { + final narrow = ChannelNarrow(channelId); + await ZulipAction.markNarrowAsRead(pageContext, narrow); } } -class MarkChannelAsReadButton extends ActionSheetMenuItemButton { - const MarkChannelAsReadButton({ +class TopicListButton extends ActionSheetMenuItemButton { + const TopicListButton({ super.key, required this.channelId, required super.pageContext, @@ -291,17 +292,17 @@ class MarkChannelAsReadButton extends ActionSheetMenuItemButton { final int channelId; @override - IconData get icon => ZulipIcons.message_checked; + IconData get icon => ZulipIcons.topics; @override String label(ZulipLocalizations zulipLocalizations) { - return zulipLocalizations.actionSheetOptionMarkChannelAsRead; + return zulipLocalizations.actionSheetOptionListOfTopics; } @override - void onPressed() async { - final narrow = ChannelNarrow(channelId); - await ZulipAction.markNarrowAsRead(pageContext, narrow); + void onPressed() { + Navigator.push(pageContext, + TopicListPage.buildRoute(context: pageContext, streamId: channelId)); } } diff --git a/test/widgets/action_sheet_test.dart b/test/widgets/action_sheet_test.dart index f673ebc0d8..f5956fdecb 100644 --- a/test/widgets/action_sheet_test.dart +++ b/test/widgets/action_sheet_test.dart @@ -247,8 +247,8 @@ void main() { group('showChannelActionSheet', () { void checkButtons() { check(actionSheetFinder).findsOne(); - checkButton('List of topics'); checkButton('Mark channel as read'); + checkButton('List of topics'); checkButton('Copy link to channel'); } @@ -291,19 +291,6 @@ void main() { }); }); - testWidgets('TopicListButton', (tester) async { - await prepare(); - await showFromAppBar(tester, - narrow: ChannelNarrow(someChannel.streamId)); - - connection.prepare(json: GetStreamTopicsResult(topics: [ - eg.getStreamTopicsEntry(name: 'some topic foo'), - ]).toJson()); - await tester.tap(findButtonForLabel('List of topics')); - await tester.pumpAndSettle(); - check(find.text('some topic foo')).findsOne(); - }); - group('MarkChannelAsReadButton', () { void checkRequest(int channelId) { check(connection.takeRequests()).single.isA() @@ -350,6 +337,19 @@ void main() { }); }); + testWidgets('TopicListButton', (tester) async { + await prepare(); + await showFromAppBar(tester, + narrow: ChannelNarrow(someChannel.streamId)); + + connection.prepare(json: GetStreamTopicsResult(topics: [ + eg.getStreamTopicsEntry(name: 'some topic foo'), + ]).toJson()); + await tester.tap(findButtonForLabel('List of topics')); + await tester.pumpAndSettle(); + check(find.text('some topic foo')).findsOne(); + }); + group('CopyChannelLinkButton', () { setUp(() async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(