From a1f5c8a35507fbda9f997c0a2b581b2394e899ca Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Fri, 22 Mar 2024 17:16:27 +0800 Subject: [PATCH 01/13] sketch of navigation bar --- lib/widgets/app.dart | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/lib/widgets/app.dart b/lib/widgets/app.dart index 75c7fd90e2..f5b4f5bd84 100644 --- a/lib/widgets/app.dart +++ b/lib/widgets/app.dart @@ -255,6 +255,52 @@ class HomePage extends StatelessWidget { return Scaffold( appBar: AppBar(title: const Text("Home")), + bottomNavigationBar: NavigationBar( + selectedIndex: 0, + destinations: [ + const NavigationDestination( + selectedIcon: Icon(Icons.inbox), + icon: Icon(Icons.inbox_outlined), + label: 'Inbox'), + const NavigationDestination( + selectedIcon: Icon(Icons.tag), + icon: Icon(Icons.tag_outlined), + label: 'Streams'), + const NavigationDestination( + selectedIcon: Icon(Icons.group_outlined), + icon: Icon(Icons.group), + label: 'Direct Messages'), + // TODO enable this when it's available + // NavigationDestination( + // selectedIcon: Icon(Icons.account_circle), + // icon: Icon(Icons.account_circle_outlined), + // label: 'Profile'), + if (testStreamId != null) ...[ + const NavigationDestination( + selectedIcon: Icon(Icons.bug_report), + icon: Icon(Icons.bug_report_outlined), + label: 'Test Stream'), + ], + ], + onDestinationSelected: (int index) { + switch (index) { + case 0: + Navigator.push(context, InboxPage.buildRoute(context: context)); + break; + case 1: + Navigator.push(context, SubscriptionListPage.buildRoute(context: context)); + break; + case 2: + Navigator.push(context, RecentDmConversationsPage.buildRoute(context: context)); + break; + case 3: + Navigator.push(context, + MessageListPage.buildRoute(context: context, + narrow: StreamNarrow(testStreamId!))); + break; + } + }, + ), body: Center( child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ DefaultTextStyle.merge( From da590f6e54d95579622fa5736a2bee718df9c969 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Fri, 22 Mar 2024 20:30:52 +0800 Subject: [PATCH 02/13] use as bottom navigation bar of multiple pages --- lib/widgets/app.dart | 48 +---------------- lib/widgets/inbox.dart | 2 + lib/widgets/message_list.dart | 2 + lib/widgets/navigation_bar.dart | 69 ++++++++++++++++++++++++ lib/widgets/recent_dm_conversations.dart | 2 + lib/widgets/subscription_list.dart | 2 + 6 files changed, 79 insertions(+), 46 deletions(-) create mode 100644 lib/widgets/navigation_bar.dart diff --git a/lib/widgets/app.dart b/lib/widgets/app.dart index f5b4f5bd84..5c959f05c3 100644 --- a/lib/widgets/app.dart +++ b/lib/widgets/app.dart @@ -11,6 +11,7 @@ import 'about_zulip.dart'; import 'inbox.dart'; import 'login.dart'; import 'message_list.dart'; +import 'navigation_bar.dart'; import 'page.dart'; import 'recent_dm_conversations.dart'; import 'store.dart'; @@ -255,52 +256,7 @@ class HomePage extends StatelessWidget { return Scaffold( appBar: AppBar(title: const Text("Home")), - bottomNavigationBar: NavigationBar( - selectedIndex: 0, - destinations: [ - const NavigationDestination( - selectedIcon: Icon(Icons.inbox), - icon: Icon(Icons.inbox_outlined), - label: 'Inbox'), - const NavigationDestination( - selectedIcon: Icon(Icons.tag), - icon: Icon(Icons.tag_outlined), - label: 'Streams'), - const NavigationDestination( - selectedIcon: Icon(Icons.group_outlined), - icon: Icon(Icons.group), - label: 'Direct Messages'), - // TODO enable this when it's available - // NavigationDestination( - // selectedIcon: Icon(Icons.account_circle), - // icon: Icon(Icons.account_circle_outlined), - // label: 'Profile'), - if (testStreamId != null) ...[ - const NavigationDestination( - selectedIcon: Icon(Icons.bug_report), - icon: Icon(Icons.bug_report_outlined), - label: 'Test Stream'), - ], - ], - onDestinationSelected: (int index) { - switch (index) { - case 0: - Navigator.push(context, InboxPage.buildRoute(context: context)); - break; - case 1: - Navigator.push(context, SubscriptionListPage.buildRoute(context: context)); - break; - case 2: - Navigator.push(context, RecentDmConversationsPage.buildRoute(context: context)); - break; - case 3: - Navigator.push(context, - MessageListPage.buildRoute(context: context, - narrow: StreamNarrow(testStreamId!))); - break; - } - }, - ), + bottomNavigationBar: ZulipNavigationBar(selectedPage: HomePage,), body: Center( child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ DefaultTextStyle.merge( diff --git a/lib/widgets/inbox.dart b/lib/widgets/inbox.dart index 8aa5172efc..68aec486a1 100644 --- a/lib/widgets/inbox.dart +++ b/lib/widgets/inbox.dart @@ -6,6 +6,7 @@ import '../model/recent_dm_conversations.dart'; import '../model/unreads.dart'; import 'icons.dart'; import 'message_list.dart'; +import 'navigation_bar.dart'; import 'page.dart'; import 'sticky_header.dart'; import 'store.dart'; @@ -160,6 +161,7 @@ class _InboxPageState extends State with PerAccountStoreAwareStateMix return Scaffold( appBar: AppBar(title: const Text('Inbox')), + bottomNavigationBar: ZulipNavigationBar(selectedPage: InboxPage), body: SafeArea( // Don't pad the bottom here; we want the list content to do that. bottom: false, diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index d80f31bea4..7bb2316af0 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -17,6 +17,7 @@ import 'content.dart'; import 'dialog.dart'; import 'emoji_reaction.dart'; import 'icons.dart'; +import 'navigation_bar.dart'; import 'page.dart'; import 'profile.dart'; import 'sticky_header.dart'; @@ -86,6 +87,7 @@ class _MessageListPageState extends State { ? const Border() : null, // i.e., inherit ), + bottomNavigationBar: ZulipNavigationBar(selectedPage: MessageList), // TODO question for Vlad: for a stream view, should we set // [backgroundColor] based on stream color, as in this frame: // https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=132%3A9684&mode=dev diff --git a/lib/widgets/navigation_bar.dart b/lib/widgets/navigation_bar.dart new file mode 100644 index 0000000000..6c18e7a03e --- /dev/null +++ b/lib/widgets/navigation_bar.dart @@ -0,0 +1,69 @@ +import 'package:flutter/material.dart'; + +import '../model/narrow.dart'; +import 'inbox.dart'; +import 'message_list.dart'; +import 'recent_dm_conversations.dart'; +import 'subscription_list.dart'; + +class ZulipNavigationBar extends StatelessWidget { + final int testStreamId = 7; + final Type selectedPage; + final Map pageToIndex = { + InboxPage: 0, + SubscriptionListPage: 1, + RecentDmConversationsPage: 2, + }; + + ZulipNavigationBar({super.key, required this.selectedPage}); + + @override + Widget build(BuildContext context) { + return NavigationBar( + selectedIndex: pageToIndex[selectedPage] ?? 0, + destinations: [ + const NavigationDestination( + selectedIcon: Icon(Icons.inbox), + icon: Icon(Icons.inbox_outlined), + label: 'Inbox'), + const NavigationDestination( + selectedIcon: Icon(Icons.tag), + icon: Icon(Icons.tag_outlined), + label: 'Streams'), + const NavigationDestination( + selectedIcon: Icon(Icons.group_outlined), + icon: Icon(Icons.group), + label: 'Direct Messages'), + // TODO enable this when it's available + // NavigationDestination( + // selectedIcon: Icon(Icons.account_circle), + // icon: Icon(Icons.account_circle_outlined), + // label: 'Profile'), + if (testStreamId != null) ...[ + const NavigationDestination( + selectedIcon: Icon(Icons.bug_report), + icon: Icon(Icons.bug_report_outlined), + label: 'Test Stream'), + ], + ], + onDestinationSelected: (int index) { + switch (index) { + case 0: + Navigator.pushReplacement(context, InboxPage.buildRoute(context: context)); + break; + case 1: + Navigator.pushReplacement(context, SubscriptionListPage.buildRoute(context: context)); + break; + case 2: + Navigator.pushReplacement(context, RecentDmConversationsPage.buildRoute(context: context)); + break; + case 3: + Navigator.pushReplacement(context, + MessageListPage.buildRoute(context: context, + narrow: StreamNarrow(testStreamId!))); + break; + } + }, + ); + } +} \ No newline at end of file diff --git a/lib/widgets/recent_dm_conversations.dart b/lib/widgets/recent_dm_conversations.dart index 27bf2a7560..3a5e164dcf 100644 --- a/lib/widgets/recent_dm_conversations.dart +++ b/lib/widgets/recent_dm_conversations.dart @@ -7,6 +7,7 @@ import '../model/unreads.dart'; import 'content.dart'; import 'icons.dart'; import 'message_list.dart'; +import 'navigation_bar.dart'; import 'page.dart'; import 'store.dart'; import 'unread_count_badge.dart'; @@ -58,6 +59,7 @@ class _RecentDmConversationsPageState extends State w final sorted = model!.sorted; return Scaffold( appBar: AppBar(title: Text(zulipLocalizations.recentDmConversationsPageTitle)), + bottomNavigationBar: ZulipNavigationBar(selectedPage: RecentDmConversationsPage), body: SafeArea( // Don't pad the bottom here; we want the list content to do that. bottom: false, diff --git a/lib/widgets/subscription_list.dart b/lib/widgets/subscription_list.dart index 9769311543..899f942f23 100644 --- a/lib/widgets/subscription_list.dart +++ b/lib/widgets/subscription_list.dart @@ -6,6 +6,7 @@ import '../model/narrow.dart'; import '../model/unreads.dart'; import 'icons.dart'; import 'message_list.dart'; +import 'navigation_bar.dart'; import 'page.dart'; import 'store.dart'; import 'text.dart'; @@ -82,6 +83,7 @@ class _SubscriptionListPageState extends State with PerAcc return Scaffold( appBar: AppBar(title: const Text("Streams")), + bottomNavigationBar: ZulipNavigationBar(selectedPage: SubscriptionListPage), body: SafeArea( // Don't pad the bottom here; we want the list content to do that. bottom: false, From 1c52fd7747b0b3af3c52e73439cea9324ee56c6f Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Fri, 22 Mar 2024 21:26:08 +0800 Subject: [PATCH 03/13] make Inbox into a page --- lib/widgets/inbox.dart | 84 ++++++++++++++++++++++++------------ test/widgets/inbox_test.dart | 2 +- 2 files changed, 57 insertions(+), 29 deletions(-) diff --git a/lib/widgets/inbox.dart b/lib/widgets/inbox.dart index 68aec486a1..a3b80a94e1 100644 --- a/lib/widgets/inbox.dart +++ b/lib/widgets/inbox.dart @@ -13,7 +13,7 @@ import 'store.dart'; import 'text.dart'; import 'unread_count_badge.dart'; -class InboxPage extends StatefulWidget { +class InboxPage extends StatelessWidget { const InboxPage({super.key}); static Route buildRoute({int? accountId, BuildContext? context}) { @@ -22,10 +22,44 @@ class InboxPage extends StatefulWidget { } @override - State createState() => _InboxPageState(); + Widget build(BuildContext context) { + return DefaultTabController( + initialIndex: 0, + length: 2, + child: Scaffold( + appBar: AppBar( + title: const Text('Inbox'), + bottom: const TabBar( + tabs: [ + Tab( + text: 'Streams + Topics', + ), + Tab( + text: 'All Messages', + ), + ], + ), + ), + bottomNavigationBar: ZulipNavigationBar(selectedPage: InboxPage), + body: const SafeArea(child: TabBarView( + children: [ + Inbox(), + MessageList(narrow: AllMessagesNarrow()), + ], + )) , + ), + ); + } } -class _InboxPageState extends State with PerAccountStoreAwareStateMixin { +class Inbox extends StatefulWidget { + const Inbox({super.key}); + + @override + State createState() => _InboxState(); +} + +class _InboxState extends State with PerAccountStoreAwareStateMixin { Unreads? unreadsModel; RecentDmConversationsView? recentDmConversationsModel; @@ -159,28 +193,22 @@ class _InboxPageState extends State with PerAccountStoreAwareStateMix sections.add(_StreamSectionData(streamId, countInStream, streamHasMention, topicItems)); } - return Scaffold( - appBar: AppBar(title: const Text('Inbox')), - bottomNavigationBar: ZulipNavigationBar(selectedPage: InboxPage), - body: SafeArea( - // Don't pad the bottom here; we want the list content to do that. - bottom: false, - child: StickyHeaderListView.builder( - itemCount: sections.length, - itemBuilder: (context, index) { - final section = sections[index]; - switch (section) { - case _AllDmsSectionData(): - return _AllDmsSection( - data: section, - collapsed: allDmsCollapsed, - pageState: this, - ); - case _StreamSectionData(:var streamId): - final collapsed = collapsedStreamIds.contains(streamId); - return _StreamSection(data: section, collapsed: collapsed, pageState: this); - } - }))); + return StickyHeaderListView.builder( + itemCount: sections.length, + itemBuilder: (context, index) { + final section = sections[index]; + switch (section) { + case _AllDmsSectionData(): + return _AllDmsSection( + data: section, + collapsed: allDmsCollapsed, + pageState: this, + ); + case _StreamSectionData(:var streamId): + final collapsed = collapsedStreamIds.contains(streamId); + return _StreamSection(data: section, collapsed: collapsed, pageState: this); + } + }); } } @@ -207,7 +235,7 @@ class _StreamSectionData extends _InboxSectionData { abstract class _HeaderItem extends StatelessWidget { final bool collapsed; - final _InboxPageState pageState; + final _InboxState pageState; final int count; final bool hasMention; @@ -297,7 +325,7 @@ class _AllDmsSection extends StatelessWidget { final _AllDmsSectionData data; final bool collapsed; - final _InboxPageState pageState; + final _InboxState pageState; @override Widget build(BuildContext context) { @@ -418,7 +446,7 @@ class _StreamSection extends StatelessWidget { final _StreamSectionData data; final bool collapsed; - final _InboxPageState pageState; + final _InboxState pageState; @override Widget build(BuildContext context) { diff --git a/test/widgets/inbox_test.dart b/test/widgets/inbox_test.dart index b3cda6613a..f826c92749 100644 --- a/test/widgets/inbox_test.dart +++ b/test/widgets/inbox_test.dart @@ -45,7 +45,7 @@ void main() { navigatorObservers: [if (navigatorObserver != null) navigatorObserver], home: PerAccountStoreWidget( accountId: eg.selfAccount.id, - child: const InboxPage())))); + child: const Inbox())))); // global store and per-account store get loaded await tester.pumpAndSettle(); From fea894c5949c7ac04d8d41c4a283e2ac5e52eac2 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Fri, 22 Mar 2024 21:36:22 +0800 Subject: [PATCH 04/13] fixup! use as bottom navigation bar of multiple pages --- lib/widgets/navigation_bar.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/widgets/navigation_bar.dart b/lib/widgets/navigation_bar.dart index 6c18e7a03e..db1e4d70e5 100644 --- a/lib/widgets/navigation_bar.dart +++ b/lib/widgets/navigation_bar.dart @@ -31,8 +31,8 @@ class ZulipNavigationBar extends StatelessWidget { icon: Icon(Icons.tag_outlined), label: 'Streams'), const NavigationDestination( - selectedIcon: Icon(Icons.group_outlined), - icon: Icon(Icons.group), + selectedIcon: Icon(Icons.group), + icon: Icon(Icons.group_outlined), label: 'Direct Messages'), // TODO enable this when it's available // NavigationDestination( From b38a69e6f7b97ffdb7850ddcd9703297a716e98a Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Fri, 22 Mar 2024 21:36:22 +0800 Subject: [PATCH 05/13] fixup! use as bottom navigation bar of multiple pages --- lib/widgets/navigation_bar.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/navigation_bar.dart b/lib/widgets/navigation_bar.dart index db1e4d70e5..3b22fb699b 100644 --- a/lib/widgets/navigation_bar.dart +++ b/lib/widgets/navigation_bar.dart @@ -41,7 +41,7 @@ class ZulipNavigationBar extends StatelessWidget { // label: 'Profile'), if (testStreamId != null) ...[ const NavigationDestination( - selectedIcon: Icon(Icons.bug_report), + selectedIcon: Icon(Icons.bug_report_outlined), icon: Icon(Icons.bug_report_outlined), label: 'Test Stream'), ], From e895aa162f67c4a886a90dfd2229ff868ac3a39b Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Fri, 22 Mar 2024 21:43:32 +0800 Subject: [PATCH 06/13] remove navigation on messages --- lib/widgets/message_list.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index 7bb2316af0..9fc4fcd9d3 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -87,7 +87,6 @@ class _MessageListPageState extends State { ? const Border() : null, // i.e., inherit ), - bottomNavigationBar: ZulipNavigationBar(selectedPage: MessageList), // TODO question for Vlad: for a stream view, should we set // [backgroundColor] based on stream color, as in this frame: // https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=132%3A9684&mode=dev From 83852f04305b8a444a8bd88f3a079e2923667eed Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 26 Mar 2024 18:43:37 +0800 Subject: [PATCH 07/13] display test home page on last nav bar item --- lib/widgets/navigation_bar.dart | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/widgets/navigation_bar.dart b/lib/widgets/navigation_bar.dart index 3b22fb699b..4bc5827652 100644 --- a/lib/widgets/navigation_bar.dart +++ b/lib/widgets/navigation_bar.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import '../model/narrow.dart'; +import 'app.dart'; import 'inbox.dart'; -import 'message_list.dart'; import 'recent_dm_conversations.dart'; +import 'store.dart'; import 'subscription_list.dart'; class ZulipNavigationBar extends StatelessWidget { @@ -19,18 +19,19 @@ class ZulipNavigationBar extends StatelessWidget { @override Widget build(BuildContext context) { + final accountId = PerAccountStoreWidget.accountIdOf(context); return NavigationBar( selectedIndex: pageToIndex[selectedPage] ?? 0, - destinations: [ - const NavigationDestination( + destinations: const [ + NavigationDestination( selectedIcon: Icon(Icons.inbox), icon: Icon(Icons.inbox_outlined), label: 'Inbox'), - const NavigationDestination( + NavigationDestination( selectedIcon: Icon(Icons.tag), icon: Icon(Icons.tag_outlined), label: 'Streams'), - const NavigationDestination( + NavigationDestination( selectedIcon: Icon(Icons.group), icon: Icon(Icons.group_outlined), label: 'Direct Messages'), @@ -39,12 +40,10 @@ class ZulipNavigationBar extends StatelessWidget { // selectedIcon: Icon(Icons.account_circle), // icon: Icon(Icons.account_circle_outlined), // label: 'Profile'), - if (testStreamId != null) ...[ - const NavigationDestination( - selectedIcon: Icon(Icons.bug_report_outlined), - icon: Icon(Icons.bug_report_outlined), - label: 'Test Stream'), - ], + NavigationDestination( + selectedIcon: Icon(Icons.bug_report_outlined), + icon: Icon(Icons.bug_report_outlined), + label: 'Test Page'), ], onDestinationSelected: (int index) { switch (index) { @@ -59,8 +58,7 @@ class ZulipNavigationBar extends StatelessWidget { break; case 3: Navigator.pushReplacement(context, - MessageListPage.buildRoute(context: context, - narrow: StreamNarrow(testStreamId!))); + HomePage.buildRoute(accountId: accountId)); break; } }, From a2aca0e25f26a31c07314141cca80c49a00efd8f Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 26 Mar 2024 18:43:47 +0800 Subject: [PATCH 08/13] jump to inbox first --- lib/widgets/app.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/app.dart b/lib/widgets/app.dart index 5c959f05c3..436406a026 100644 --- a/lib/widgets/app.dart +++ b/lib/widgets/app.dart @@ -178,7 +178,7 @@ class ChooseAccountPage extends StatelessWidget { title: title, subtitle: subtitle, onTap: () => Navigator.push(context, - HomePage.buildRoute(accountId: accountId)))); + InboxPage.buildRoute(accountId: accountId)))); } @override From b3753e3116c711bde80cb41258426ac4eb727913 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 26 Mar 2024 18:57:49 +0800 Subject: [PATCH 09/13] fixup! use as bottom navigation bar of multiple pages --- lib/widgets/navigation_bar.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/navigation_bar.dart b/lib/widgets/navigation_bar.dart index 4bc5827652..b463adbc64 100644 --- a/lib/widgets/navigation_bar.dart +++ b/lib/widgets/navigation_bar.dart @@ -35,7 +35,7 @@ class ZulipNavigationBar extends StatelessWidget { selectedIcon: Icon(Icons.group), icon: Icon(Icons.group_outlined), label: 'Direct Messages'), - // TODO enable this when it's available + // TODO enable this when the profile page is available // NavigationDestination( // selectedIcon: Icon(Icons.account_circle), // icon: Icon(Icons.account_circle_outlined), From 00178be1fba77ac779d57c90fab1c0f10fb40ac2 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 26 Mar 2024 19:00:51 +0800 Subject: [PATCH 10/13] fixup! display test home page on last nav bar item --- lib/widgets/navigation_bar.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/widgets/navigation_bar.dart b/lib/widgets/navigation_bar.dart index b463adbc64..cb6f99da37 100644 --- a/lib/widgets/navigation_bar.dart +++ b/lib/widgets/navigation_bar.dart @@ -13,6 +13,7 @@ class ZulipNavigationBar extends StatelessWidget { InboxPage: 0, SubscriptionListPage: 1, RecentDmConversationsPage: 2, + HomePage: 3, }; ZulipNavigationBar({super.key, required this.selectedPage}); From 5aa3319a533cbe03638672de7f2366fda7474fb8 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 26 Mar 2024 19:04:32 +0800 Subject: [PATCH 11/13] don't load the same page when dest = selected --- lib/widgets/navigation_bar.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/widgets/navigation_bar.dart b/lib/widgets/navigation_bar.dart index cb6f99da37..a147765d52 100644 --- a/lib/widgets/navigation_bar.dart +++ b/lib/widgets/navigation_bar.dart @@ -21,8 +21,9 @@ class ZulipNavigationBar extends StatelessWidget { @override Widget build(BuildContext context) { final accountId = PerAccountStoreWidget.accountIdOf(context); + final selectedIndex = pageToIndex[selectedPage] ?? 0; return NavigationBar( - selectedIndex: pageToIndex[selectedPage] ?? 0, + selectedIndex: selectedIndex, destinations: const [ NavigationDestination( selectedIcon: Icon(Icons.inbox), @@ -47,6 +48,9 @@ class ZulipNavigationBar extends StatelessWidget { label: 'Test Page'), ], onDestinationSelected: (int index) { + if (selectedIndex == index) { + return; + } switch (index) { case 0: Navigator.pushReplacement(context, InboxPage.buildRoute(context: context)); From 5f48efcf1afeca6d129a4f4bb216aa97c195d1de Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 26 Mar 2024 20:24:59 +0800 Subject: [PATCH 12/13] fix test --- test/widgets/subscription_list_test.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/widgets/subscription_list_test.dart b/test/widgets/subscription_list_test.dart index 1259bca4a4..2689519786 100644 --- a/test/widgets/subscription_list_test.dart +++ b/test/widgets/subscription_list_test.dart @@ -154,7 +154,9 @@ void main() { subscription, ], unreadMsgs: unreadMsgs); check(getItemCount()).equals(1); - check(tester.widget(find.byType(Icon)).color) + final scaffoldBody = tester.widget(find.byType(Scaffold)).body; + check(tester.widget(find.descendant(of: + find.byWidget(scaffoldBody!), matching: find.byType(Icon))).color) .equals(swatch.iconOnPlainBackground); check(tester.widget(find.byType(UnreadCountBadge)).backgroundColor) .equals(swatch); From a201d5d767946cab824307f49e3c51110d7c574f Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 26 Mar 2024 21:50:08 +0800 Subject: [PATCH 13/13] fixup! use as bottom navigation bar of multiple pages --- lib/widgets/message_list.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index 9fc4fcd9d3..d80f31bea4 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -17,7 +17,6 @@ import 'content.dart'; import 'dialog.dart'; import 'emoji_reaction.dart'; import 'icons.dart'; -import 'navigation_bar.dart'; import 'page.dart'; import 'profile.dart'; import 'sticky_header.dart';