Skip to content

Commit

Permalink
nav: Remove *Page widgets for page bodies that can be reached in Home…
Browse files Browse the repository at this point in the history
…Page

Fixes: #1035

Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Dec 9, 2024
1 parent 2a54d07 commit 269d86e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 66 deletions.
18 changes: 0 additions & 18 deletions lib/widgets/inbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> 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});

Expand Down
21 changes: 0 additions & 21 deletions lib/widgets/recent_dm_conversations.dart
Original file line number Diff line number Diff line change
@@ -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<void> 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});

Expand Down
18 changes: 0 additions & 18 deletions lib/widgets/subscription_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> 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});

Expand Down
7 changes: 5 additions & 2 deletions test/widgets/actions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ void main() {

final pushedRoutes = <Route<dynamic>>[];
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
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();
Expand Down
3 changes: 1 addition & 2 deletions test/widgets/home_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions test/widgets/inbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
11 changes: 9 additions & 2 deletions test/widgets/recent_dm_conversations_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -49,10 +50,16 @@ Future<void> 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() {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion test/widgets/subscription_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 269d86e

Please sign in to comment.