diff --git a/lib/widgets/inbox.dart b/lib/widgets/inbox.dart index f276a1b5cd..12ec8751a1 100644 --- a/lib/widgets/inbox.dart +++ b/lib/widgets/inbox.dart @@ -5,32 +5,14 @@ import '../model/narrow.dart'; import '../model/recent_dm_conversations.dart'; import '../model/unreads.dart'; import 'action_sheet.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/action_sheet_test.dart b/test/widgets/action_sheet_test.dart index 6ca5fa1fbd..f6b9fb1071 100644 --- a/test/widgets/action_sheet_test.dart +++ b/test/widgets/action_sheet_test.dart @@ -21,6 +21,7 @@ import 'package:zulip/widgets/action_sheet.dart'; import 'package:zulip/widgets/app_bar.dart'; import 'package:zulip/widgets/compose_box.dart'; import 'package:zulip/widgets/content.dart'; +import 'package:zulip/widgets/home.dart'; import 'package:zulip/widgets/icons.dart'; import 'package:zulip/widgets/inbox.dart'; import 'package:zulip/widgets/message_list.dart'; @@ -125,8 +126,9 @@ void main() { testWidgets('show from inbox', (tester) async { await prepare(); await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id, - child: const InboxPage())); + child: const HomePage())); await tester.pump(); + check(find.byType(InboxPageBody)).findsOne(); await tester.longPress(find.text(topic)); // sheet appears onscreen; default duration of bottom-sheet enter animation diff --git a/test/widgets/actions_test.dart b/test/widgets/actions_test.dart index 8b4a355b3e..4a4698a175 100644 --- a/test/widgets/actions_test.dart +++ b/test/widgets/actions_test.dart @@ -182,8 +182,12 @@ 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); + // TODO(#737): switch to a realistic setup: + // https://github.com/zulip/zulip-flutter/pull/1076#discussion_r1874124363 + 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/inbox_test.dart b/test/widgets/inbox_test.dart index b7ddbd7e23..b7af250d03 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() {