-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The previous bottom navigation bottom bar was refactored, in order to be reused anywhere. Then it was added to the product page. Deleted files: * `home_page.dart` * `smooth_ui_library/smooth_bottom_navigation_bar.dart` * `smooth_ui_library/smooth_bottom_navigation_bar_item.dart` New file: * `smooth_bottom_navigation_bar.dart` Impacted files: * `continuous_scan_page.dart`: added an explicit bottom navigation bar (was implicit through `HomePage`), explicitly on the "scan" tab * `main.dart`: not using `HomePage` anymore; opens the "scan" page by default * `new_product_page.dart`: added an explicit bottom navigation bar (was not there), implicitly on the "default" tab * `product_list_page.dart`: added an explicit bottom navigation bar (was implicit through `HomePage`), explicitly on the "history" tab * `product_page.dart`: added an explicit bottom navigation bar (was not there), implicitly on the "default" tab * `smooth_ui_library.dart`: removed "UI" version of smooth bottom navigation bar * `user_preferences_page.dart`: added an explicit bottom navigation bar (was implicit through `HomePage`), explicitly on the "profile" tab
- Loading branch information
1 parent
76222ac
commit 212dd31
Showing
11 changed files
with
103 additions
and
230 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 was deleted.
Oops, something went wrong.
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
85 changes: 85 additions & 0 deletions
85
packages/smooth_app/lib/pages/smooth_bottom_navigation_bar.dart
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,85 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:smooth_app/pages/history_page.dart'; | ||
import 'package:smooth_app/pages/scan/scan_page.dart'; | ||
import 'package:smooth_app/pages/user_preferences_page.dart'; | ||
|
||
class _Page { | ||
const _Page({required this.name, required this.icon, required this.body}); | ||
final String name; | ||
final IconData icon; | ||
final Widget body; | ||
} | ||
|
||
enum SmoothBottomNavigationTab { | ||
Profile, | ||
Scan, | ||
History, | ||
} | ||
|
||
class SmoothBottomNavigationBar extends StatelessWidget { | ||
const SmoothBottomNavigationBar({ | ||
this.tab = _defaultTab, | ||
}); | ||
|
||
final SmoothBottomNavigationTab tab; | ||
|
||
static const SmoothBottomNavigationTab _defaultTab = | ||
SmoothBottomNavigationTab.Scan; | ||
|
||
static const List<SmoothBottomNavigationTab> _tabs = | ||
<SmoothBottomNavigationTab>[ | ||
SmoothBottomNavigationTab.Profile, | ||
SmoothBottomNavigationTab.Scan, | ||
SmoothBottomNavigationTab.History, | ||
]; | ||
|
||
static const Map<SmoothBottomNavigationTab, _Page> _pages = | ||
<SmoothBottomNavigationTab, _Page>{ | ||
SmoothBottomNavigationTab.Profile: _Page( | ||
name: 'Profile', // TODO(monsieurtanuki): translate | ||
icon: Icons.account_circle, | ||
body: UserPreferencesPage(), | ||
), | ||
SmoothBottomNavigationTab.Scan: _Page( | ||
name: 'Scan or Search', | ||
icon: Icons.search, | ||
body: ScanPage(), | ||
), | ||
SmoothBottomNavigationTab.History: _Page( | ||
name: 'History', | ||
icon: Icons.history, | ||
body: HistoryPage(), | ||
), | ||
}; | ||
|
||
static Widget getDefaultPage() => _getTabPage(_defaultTab); | ||
|
||
static Widget _getTabPage(final SmoothBottomNavigationTab tab) => | ||
_pages[tab]!.body; | ||
|
||
@override | ||
Widget build(BuildContext context) => BottomNavigationBar( | ||
showSelectedLabels: false, | ||
showUnselectedLabels: false, | ||
selectedItemColor: Colors.white, | ||
backgroundColor: Theme.of(context).appBarTheme.backgroundColor, | ||
currentIndex: _tabs.indexOf(tab), | ||
onTap: (final int index) async => Navigator.push<Widget>( | ||
context, | ||
MaterialPageRoute<Widget>( | ||
builder: (BuildContext context) => _getTabPage(_tabs[index]), | ||
), | ||
), | ||
items: <BottomNavigationBarItem>[ | ||
_buildItem(_pages[_tabs[0]]!), | ||
_buildItem(_pages[_tabs[1]]!), | ||
_buildItem(_pages[_tabs[2]]!), | ||
], | ||
); | ||
|
||
BottomNavigationBarItem _buildItem(final _Page page) => | ||
BottomNavigationBarItem( | ||
icon: Icon(page.icon, size: 28), | ||
label: page.name, | ||
); | ||
} |
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
9 changes: 0 additions & 9 deletions
9
packages/smooth_ui_library/lib/navigation/models/smooth_bottom_navigation_bar_item.dart
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.