2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

Add "pull to refresh" for location_display widget

This commit is contained in:
Oliver Walters 2020-04-15 11:04:27 +10:00
parent 3fead77f6d
commit 5cc80ee3f4

View File

@ -28,7 +28,6 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
BuildContext context;
_LocationDisplayState(this.location) {
}
void initState() {
@ -62,6 +61,10 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
}
}
Future<void> _refresh() async {
await _requestData(context);
}
/*
* Request data from the server.
* It will be displayed once loaded
@ -69,9 +72,7 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
* - List of sublocations under this one
* - List of stock items at this location
*/
void _requestData(BuildContext context) {
print("Requesting data!");
Future<void> _requestData(BuildContext context) async {
int pk = location?.pk ?? -1;
@ -150,14 +151,14 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
// Save the context
this.context = context;
print("Saved context!");
return Scaffold(
appBar: AppBar(
title: Text(_title),
),
drawer: new InvenTreeDrawer(context),
body: ListView(
body: new RefreshIndicator(
onRefresh: _refresh,
child: ListView(
children: <Widget> [
locationDescriptionCard(),
ExpansionPanelList(
@ -213,6 +214,7 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
),
]
)
)
);
}
}