-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use as bottom navigation bar of multiple pages
- Loading branch information
Showing
6 changed files
with
79 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Type, int> 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; | ||
} | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters