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