mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
The "search" window is now a tab on the main screen
This commit is contained in:
parent
102b4e021b
commit
3fa68ec6da
@ -230,6 +230,9 @@ class InvenTreeAPI {
|
||||
|
||||
int get apiVersion => _apiVersion;
|
||||
|
||||
// Notification support requires API v25 or newer
|
||||
bool get supportsNotifications => isConnected() && apiVersion >= 25;
|
||||
|
||||
// Are plugins enabled on the server?
|
||||
bool _pluginsEnabled = false;
|
||||
|
||||
|
@ -308,6 +308,9 @@
|
||||
"description": "history"
|
||||
},
|
||||
|
||||
"home": "Home",
|
||||
"@homeScreen": {},
|
||||
|
||||
"homeScreen": "Home Screen",
|
||||
"@homeScreen": {},
|
||||
|
||||
@ -461,6 +464,9 @@
|
||||
"description": "Notes"
|
||||
},
|
||||
|
||||
"notifications": "Notifications",
|
||||
"@notifications": {},
|
||||
|
||||
"noResponse": "No Response from Server",
|
||||
"@noResponse": {},
|
||||
|
||||
|
@ -174,7 +174,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
||||
icon: FaIcon(FontAwesomeIcons.shapes),
|
||||
label: L10().parts,
|
||||
),
|
||||
// TODO - Add the "actions" item back in
|
||||
BottomNavigationBarItem(
|
||||
icon: FaIcon(FontAwesomeIcons.wrench),
|
||||
label: L10().actions
|
||||
|
@ -41,6 +41,9 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
|
||||
}
|
||||
|
||||
// Index of bottom navigation bar
|
||||
int _tabIndex = 0;
|
||||
|
||||
bool homeShowPo = false;
|
||||
bool homeShowSubscribed = false;
|
||||
bool homeShowManufacturers = false;
|
||||
@ -52,17 +55,6 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
// Selected user profile
|
||||
UserProfile? _profile;
|
||||
|
||||
void _search(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection(context)) return;
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SearchWidget()
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
void _scan(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection(context)) return;
|
||||
@ -224,16 +216,6 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
}
|
||||
));
|
||||
|
||||
// Search widget
|
||||
tiles.add(_listTile(
|
||||
context,
|
||||
L10().search,
|
||||
FontAwesomeIcons.search,
|
||||
callback: () {
|
||||
_search(context);
|
||||
}
|
||||
));
|
||||
|
||||
// Parts
|
||||
tiles.add(_listTile(
|
||||
context,
|
||||
@ -327,6 +309,52 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
return tiles;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the main body widget for display.
|
||||
* This depends on the current value of _tabIndex
|
||||
*/
|
||||
Widget getBody(BuildContext context) {
|
||||
switch (_tabIndex) {
|
||||
case 1: // Search widget
|
||||
return SearchWidget();
|
||||
case 2: // Notification widget
|
||||
case 0: // Home widget
|
||||
default:
|
||||
return ListView(
|
||||
scrollDirection: Axis.vertical,
|
||||
children: getListTiles(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct the bottom navigation bar
|
||||
*/
|
||||
List<BottomNavigationBarItem> getNavBarItems(BuildContext context) {
|
||||
|
||||
List<BottomNavigationBarItem> items = <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: FaIcon(FontAwesomeIcons.home),
|
||||
label: L10().home,
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: FaIcon(FontAwesomeIcons.search),
|
||||
label: L10().search,
|
||||
),
|
||||
];
|
||||
|
||||
if (InvenTreeAPI().supportsNotifications) {
|
||||
items.add(
|
||||
BottomNavigationBarItem(
|
||||
icon: FaIcon(FontAwesomeIcons.bell),
|
||||
label: L10().notifications,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@ -345,10 +373,16 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
],
|
||||
),
|
||||
drawer: InvenTreeDrawer(context),
|
||||
body: ListView(
|
||||
scrollDirection: Axis.vertical,
|
||||
children: getListTiles(context),
|
||||
)
|
||||
body: getBody(context),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _tabIndex,
|
||||
onTap: (int index) {
|
||||
setState(() {
|
||||
_tabIndex = index;
|
||||
});
|
||||
},
|
||||
items: getNavBarItems(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class SearchWidget extends StatefulWidget {
|
||||
|
||||
}
|
||||
|
||||
class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
class _SearchDisplayState extends State<SearchWidget> {
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().search;
|
||||
@ -333,7 +333,7 @@ class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: ListView(
|
||||
children: ListTile.divideTiles(
|
||||
|
Loading…
x
Reference in New Issue
Block a user