From 6c52cfee269c09d79cb6d4f33806778fa496be65 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Tue, 26 Nov 2024 16:07:00 -0500 Subject: [PATCH] nav: Remove *Page widgets for page bodies that can be reached in HomePage Fixes: #1035 Signed-off-by: Zixuan James Li --- lib/widgets/inbox.dart | 18 ---------------- lib/widgets/recent_dm_conversations.dart | 21 ------------------- lib/widgets/subscription_list.dart | 18 ---------------- test/widgets/actions_test.dart | 6 ++++-- test/widgets/home_test.dart | 3 +-- test/widgets/inbox_test.dart | 4 ++-- .../widgets/recent_dm_conversations_test.dart | 11 ++++++++-- test/widgets/subscription_list_test.dart | 7 ++++++- 8 files changed, 22 insertions(+), 66 deletions(-) diff --git a/lib/widgets/inbox.dart b/lib/widgets/inbox.dart index dcbd1acdb2..27bbecbaa6 100644 --- a/lib/widgets/inbox.dart +++ b/lib/widgets/inbox.dart @@ -4,32 +4,14 @@ import '../api/model/model.dart'; import '../model/narrow.dart'; import '../model/recent_dm_conversations.dart'; import '../model/unreads.dart'; -import 'app_bar.dart'; import 'icons.dart'; import 'message_list.dart'; -import 'page.dart'; import 'sticky_header.dart'; import 'store.dart'; import 'text.dart'; import 'theme.dart'; import 'unread_count_badge.dart'; -class InboxPage extends StatelessWidget { - const InboxPage({super.key}); - - static Route buildRoute({int? accountId, BuildContext? context}) { - return MaterialAccountWidgetRoute(accountId: accountId, context: context, - page: const InboxPage()); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: ZulipAppBar(title: const Text('Inbox')), - body: const InboxPageBody()); - } -} - class InboxPageBody extends StatefulWidget { const InboxPageBody({super.key}); diff --git a/lib/widgets/recent_dm_conversations.dart b/lib/widgets/recent_dm_conversations.dart index 69245adc04..c9d3131591 100644 --- a/lib/widgets/recent_dm_conversations.dart +++ b/lib/widgets/recent_dm_conversations.dart @@ -1,36 +1,15 @@ import 'package:flutter/material.dart'; -import '../generated/l10n/zulip_localizations.dart'; import '../model/narrow.dart'; import '../model/recent_dm_conversations.dart'; import '../model/unreads.dart'; -import 'app_bar.dart'; import 'content.dart'; import 'icons.dart'; import 'message_list.dart'; -import 'page.dart'; import 'store.dart'; import 'theme.dart'; import 'unread_count_badge.dart'; -class RecentDmConversationsPage extends StatelessWidget { - const RecentDmConversationsPage({super.key}); - - static Route buildRoute({int? accountId, BuildContext? context}) { - return MaterialAccountWidgetRoute(accountId: accountId, context: context, - page: const RecentDmConversationsPage()); - } - - @override - Widget build(BuildContext context) { - final zulipLocalizations = ZulipLocalizations.of(context); - return Scaffold( - appBar: ZulipAppBar( - title: Text(zulipLocalizations.recentDmConversationsPageTitle)), - body: const RecentDmConversationsPageBody()); - } -} - class RecentDmConversationsPageBody extends StatefulWidget { const RecentDmConversationsPageBody({super.key}); diff --git a/lib/widgets/subscription_list.dart b/lib/widgets/subscription_list.dart index a7fa96de7e..d2faf03b2c 100644 --- a/lib/widgets/subscription_list.dart +++ b/lib/widgets/subscription_list.dart @@ -3,32 +3,14 @@ import 'package:flutter/material.dart'; import '../api/model/model.dart'; import '../model/narrow.dart'; import '../model/unreads.dart'; -import 'app_bar.dart'; import 'icons.dart'; import 'message_list.dart'; -import 'page.dart'; import 'store.dart'; import 'text.dart'; import 'theme.dart'; import 'unread_count_badge.dart'; /// Scrollable listing of subscribed streams. -class SubscriptionListPage extends StatelessWidget { - const SubscriptionListPage({super.key}); - - static Route buildRoute({int? accountId, BuildContext? context}) { - return MaterialAccountWidgetRoute(accountId: accountId, context: context, - page: const SubscriptionListPage()); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: ZulipAppBar(title: const Text("Channels")), - body: const SubscriptionListPageBody()); - } -} - class SubscriptionListPageBody extends StatefulWidget { const SubscriptionListPageBody({super.key}); diff --git a/test/widgets/actions_test.dart b/test/widgets/actions_test.dart index 8b4a355b3e..55b47cbe22 100644 --- a/test/widgets/actions_test.dart +++ b/test/widgets/actions_test.dart @@ -182,8 +182,10 @@ void main() { final pushedRoutes = >[]; testNavObserver.onPushed = (route, prevRoute) => pushedRoutes.add(route); - final account1Route = InboxPage.buildRoute(accountId: account1.id); - final account2Route = InboxPage.buildRoute(accountId: account2.id); + final account1Route = MaterialAccountWidgetRoute( + accountId: account1.id, page: const InboxPageBody()); + final account2Route = MaterialAccountWidgetRoute( + accountId: account2.id, page: const InboxPageBody()); unawaited(navigator.push(account1Route)); unawaited(navigator.push(account2Route)); await tester.pumpAndSettle(); diff --git a/test/widgets/home_test.dart b/test/widgets/home_test.dart index 8a40b10f26..23297ad746 100644 --- a/test/widgets/home_test.dart +++ b/test/widgets/home_test.dart @@ -41,8 +41,7 @@ void main () { id: 0, message: eg.streamMessage(stream: stream, sender: eg.otherUser))); await tester.pumpWidget(TestZulipApp( - accountId: eg.selfAccount.id, - child: const HomePage())); + accountId: eg.selfAccount.id, child: const HomePage())); await tester.pumpAndSettle(); } diff --git a/test/widgets/inbox_test.dart b/test/widgets/inbox_test.dart index 12e2c78800..ec3c233ac8 100644 --- a/test/widgets/inbox_test.dart +++ b/test/widgets/inbox_test.dart @@ -6,8 +6,8 @@ import 'package:zulip/api/model/events.dart'; import 'package:zulip/api/model/model.dart'; import 'package:zulip/model/store.dart'; import 'package:zulip/widgets/color.dart'; +import 'package:zulip/widgets/home.dart'; import 'package:zulip/widgets/icons.dart'; -import 'package:zulip/widgets/inbox.dart'; import 'package:zulip/widgets/channel_colors.dart'; import '../example_data.dart' as eg; @@ -76,7 +76,7 @@ void main() { await tester.pumpWidget(TestZulipApp( accountId: eg.selfAccount.id, navigatorObservers: [if (navigatorObserver != null) navigatorObserver], - child: const InboxPage(), + child: const HomePage(), )); await tester.pump(); diff --git a/test/widgets/recent_dm_conversations_test.dart b/test/widgets/recent_dm_conversations_test.dart index d1b46925de..0976ca1bfd 100644 --- a/test/widgets/recent_dm_conversations_test.dart +++ b/test/widgets/recent_dm_conversations_test.dart @@ -6,6 +6,7 @@ import 'package:zulip/api/model/events.dart'; import 'package:zulip/api/model/model.dart'; import 'package:zulip/model/narrow.dart'; import 'package:zulip/widgets/content.dart'; +import 'package:zulip/widgets/home.dart'; import 'package:zulip/widgets/icons.dart'; import 'package:zulip/widgets/message_list.dart'; import 'package:zulip/widgets/page.dart'; @@ -49,10 +50,16 @@ Future setupPage(WidgetTester tester, { await tester.pumpWidget(TestZulipApp( accountId: eg.selfAccount.id, navigatorObservers: navigatorObserver != null ? [navigatorObserver] : [], - child: const RecentDmConversationsPage())); + child: const HomePage())); // global store, per-account store, and page get loaded await tester.pumpAndSettle(); + + // Switch to direct messages tab. + await tester.tap(find.descendant( + of: find.byType(Center), + matching: find.byIcon(ZulipIcons.user))); + await tester.pump(); } void main() { @@ -96,7 +103,7 @@ void main() { DmNarrow.ofMessage(messages.first, selfUserId: eg.selfUser.userId)); check(tester.any(oldestConversationFinder)).isFalse(); // not onscreen - await tester.fling(find.byType(RecentDmConversationsPage), + await tester.fling(find.byType(RecentDmConversationsPageBody), const Offset(0, -200), 4000); await tester.pumpAndSettle(); check(tester.any(oldestConversationFinder)).isTrue(); // onscreen diff --git a/test/widgets/subscription_list_test.dart b/test/widgets/subscription_list_test.dart index 130b6c802a..9439bac865 100644 --- a/test/widgets/subscription_list_test.dart +++ b/test/widgets/subscription_list_test.dart @@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:zulip/api/model/initial_snapshot.dart'; import 'package:zulip/api/model/model.dart'; import 'package:zulip/widgets/color.dart'; +import 'package:zulip/widgets/home.dart'; import 'package:zulip/widgets/icons.dart'; import 'package:zulip/widgets/channel_colors.dart'; import 'package:zulip/widgets/subscription_list.dart'; @@ -34,10 +35,14 @@ void main() { await testBinding.globalStore.add(eg.selfAccount, initialSnapshot); await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id, - child: const SubscriptionListPage())); + child: const HomePage())); // global store, per-account store await tester.pumpAndSettle(); + + // Switch to channels tab. + await tester.tap(find.byIcon(ZulipIcons.hash_italic)); + await tester.pump(); } bool isPinnedHeaderInTree() {