Skip to content

Commit

Permalink
home: Add combined feed to bottom nav bar
Browse files Browse the repository at this point in the history
Fixes zulip#1164.
  • Loading branch information
gnprice authored and chrisbobbe committed Dec 19, 2024
1 parent 54f0538 commit bf64923
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/widgets/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,15 @@ class _HomePageState extends State<HomePage> {
// TODO(a11y): add tooltips for these buttons
final navigationBarButtons = [
button(_HomePageTab.inbox, ZulipIcons.inbox),
_NavigationBarButton( icon: ZulipIcons.message_feed,
selected: false,
onPressed: () => Navigator.push(context,
MessageListPage.buildRoute(context: context,
narrow: const CombinedFeedNarrow()))),
button(_HomePageTab.channels, ZulipIcons.hash_italic),
// TODO(#1094): Users
button(_HomePageTab.directMessages, ZulipIcons.user),
_NavigationBarButton( icon: ZulipIcons.menu,
_NavigationBarButton( icon: ZulipIcons.menu,
selected: false,
onPressed: () => _showMainMenu(context, tabNotifier: _tab)),
];
Expand Down
28 changes: 27 additions & 1 deletion test/widgets/home_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import 'package:flutter/material.dart';
import 'package:flutter_checks/flutter_checks.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:zulip/api/model/events.dart';
import 'package:zulip/model/narrow.dart';
import 'package:zulip/model/store.dart';
import 'package:zulip/widgets/app.dart';
import 'package:zulip/widgets/app_bar.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';
import 'package:zulip/widgets/page.dart';
import 'package:zulip/widgets/profile.dart';
import 'package:zulip/widgets/subscription_list.dart';
Expand All @@ -19,22 +21,29 @@ import '../example_data.dart' as eg;
import '../flutter_checks.dart';
import '../model/binding.dart';
import '../model/test_store.dart';
import '../test_navigation.dart';
import 'message_list_checks.dart';
import 'page_checks.dart';
import 'test_app.dart';

void main () {
TestZulipBinding.ensureInitialized();

late PerAccountStore store;
late FakeApiConnection connection;

Future<void> prepare(WidgetTester tester) async {
Future<void> prepare(WidgetTester tester, {
NavigatorObserver? navigatorObserver,
}) async {
addTearDown(testBinding.reset);
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
connection = store.connection as FakeApiConnection;
await store.addUser(eg.selfUser);

await tester.pumpWidget(TestZulipApp(
accountId: eg.selfAccount.id,
navigatorObservers: navigatorObserver != null ? [navigatorObserver] : [],
child: const HomePage()));
await tester.pump();
}
Expand Down Expand Up @@ -88,6 +97,23 @@ void main () {
of: find.byType(ZulipAppBar),
matching: find.text('Direct messages'))).findsOne();
});

testWidgets('combined feed', (tester) async {
final pushedRoutes = <Route<dynamic>>[];
final testNavObserver = TestNavigatorObserver()
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
await prepare(tester, navigatorObserver: testNavObserver);
pushedRoutes.clear();

connection.prepare(json: eg.newestGetMessagesResult(
foundOldest: true, messages: []).toJson());
await tester.tap(find.byIcon(ZulipIcons.message_feed));
await tester.pump();
await tester.pump(const Duration(milliseconds: 250));
check(pushedRoutes).single.isA<WidgetRoute>().page
.isA<MessageListPage>()
.initNarrow.equals(const CombinedFeedNarrow());
});
});

group('menu', () {
Expand Down

0 comments on commit bf64923

Please sign in to comment.