mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Allow search widget to be constructed with or without an app bar
This commit is contained in:
parent
b6a5af08d8
commit
a3597c5d61
@ -41,7 +41,7 @@ class InvenTreeDrawer extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SearchWidget()
|
||||
builder: (context) => SearchWidget(true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
// Selected user profile
|
||||
UserProfile? _profile;
|
||||
|
||||
|
||||
void _scan(BuildContext context) {
|
||||
if (!InvenTreeAPI().checkConnection(context)) return;
|
||||
|
||||
@ -316,7 +315,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
Widget getBody(BuildContext context) {
|
||||
switch (_tabIndex) {
|
||||
case 1: // Search widget
|
||||
return SearchWidget();
|
||||
return SearchWidget(false);
|
||||
case 2: // Notification widget
|
||||
case 0: // Home widget
|
||||
default:
|
||||
|
@ -80,6 +80,14 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
AppBar? buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
title: Text(getAppBarTitle(context)),
|
||||
actions: getAppBarActions(context),
|
||||
leading: backButton(context, refreshableKey),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@ -88,11 +96,7 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
||||
|
||||
return Scaffold(
|
||||
key: refreshableKey,
|
||||
appBar: AppBar(
|
||||
title: Text(getAppBarTitle(context)),
|
||||
actions: getAppBarActions(context),
|
||||
leading: backButton(context, refreshableKey),
|
||||
),
|
||||
appBar: buildAppBar(context),
|
||||
drawer: getDrawer(context),
|
||||
floatingActionButton: getFab(context),
|
||||
body: Builder(
|
||||
|
@ -21,16 +21,33 @@ import "package:inventree/widget/location_list.dart";
|
||||
// Widget for performing database-wide search
|
||||
class SearchWidget extends StatefulWidget {
|
||||
|
||||
SearchWidget(this.hasAppbar);
|
||||
|
||||
final bool hasAppbar;
|
||||
|
||||
@override
|
||||
_SearchDisplayState createState() => _SearchDisplayState();
|
||||
_SearchDisplayState createState() => _SearchDisplayState(hasAppbar);
|
||||
|
||||
}
|
||||
|
||||
class _SearchDisplayState extends State<SearchWidget> {
|
||||
class _SearchDisplayState extends RefreshableState<SearchWidget> {
|
||||
|
||||
_SearchDisplayState(this.hasAppBar) : super();
|
||||
|
||||
final bool hasAppBar;
|
||||
|
||||
@override
|
||||
String getAppBarTitle(BuildContext context) => L10().search;
|
||||
|
||||
@override
|
||||
AppBar? buildAppBar(BuildContext context) {
|
||||
if (hasAppBar) {
|
||||
return super.buildAppBar(context);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
Timer? debounceTimer;
|
||||
@ -333,7 +350,7 @@ class _SearchDisplayState extends State<SearchWidget> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget getBody(BuildContext context) {
|
||||
return Center(
|
||||
child: ListView(
|
||||
children: ListTile.divideTiles(
|
||||
|
Loading…
x
Reference in New Issue
Block a user