mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-30 21:05:42 +00:00 
			
		
		
		
	Part detail view is now refreshabel
- lso add a progress dialog when reloading a model object
This commit is contained in:
		| @@ -89,9 +89,30 @@ class InvenTreeModel { | |||||||
|   /* |   /* | ||||||
|    * Reload this object, by requesting data from the server |    * Reload this object, by requesting data from the server | ||||||
|    */ |    */ | ||||||
|   Future<bool> reload() async { |   Future<bool> reload(BuildContext context) async { | ||||||
|  |  | ||||||
|     var response = await api.get(url, params: defaultGetFilters()); |     showProgressDialog(context, "Refreshing data", "Refreshing data for ${NAME}"); | ||||||
|  |  | ||||||
|  |     var response = await api.get(url, params: defaultGetFilters()) | ||||||
|  |       .timeout(Duration(seconds: 10)) | ||||||
|  |       .catchError((e) { | ||||||
|  |  | ||||||
|  |           hideProgressDialog(context); | ||||||
|  |  | ||||||
|  |           if (e is TimeoutException) { | ||||||
|  |             showErrorDialog(context, "Timeout", "No response from server"); | ||||||
|  |           } else { | ||||||
|  |             showErrorDialog(context, "Error", e.toString()); | ||||||
|  |           } | ||||||
|  |  | ||||||
|  |           return null; | ||||||
|  |     }); | ||||||
|  |      | ||||||
|  |     if (response == null) { | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     hideProgressDialog(context); | ||||||
|  |  | ||||||
|     if (response.statusCode != 200) { |     if (response.statusCode != 200) { | ||||||
|       print("Error retrieving data"); |       print("Error retrieving data"); | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart'; | |||||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
|  |  | ||||||
| import 'package:InvenTree/api.dart'; | import 'package:InvenTree/api.dart'; | ||||||
|  | import 'package:InvenTree/widget/refreshable_state.dart'; | ||||||
| import 'package:InvenTree/widget/drawer.dart'; | import 'package:InvenTree/widget/drawer.dart'; | ||||||
| import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | ||||||
|  |  | ||||||
| @@ -21,7 +22,10 @@ class PartDetailWidget extends StatefulWidget { | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| class _PartDisplayState extends State<PartDetailWidget> { | class _PartDisplayState extends RefreshableState<PartDetailWidget> { | ||||||
|  |  | ||||||
|  |   @override | ||||||
|  |   String app_bar_title = "Part"; | ||||||
|  |  | ||||||
|   _PartDisplayState(this.part) { |   _PartDisplayState(this.part) { | ||||||
|     // TODO |     // TODO | ||||||
| @@ -29,6 +33,11 @@ class _PartDisplayState extends State<PartDetailWidget> { | |||||||
|  |  | ||||||
|   InvenTreePart part; |   InvenTreePart part; | ||||||
|  |  | ||||||
|  |   @override | ||||||
|  |   Future<void> request(BuildContext context) async { | ||||||
|  |     await part.reload(context); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|    * Build a list of tiles to display under the part description |    * Build a list of tiles to display under the part description | ||||||
|    */ |    */ | ||||||
| @@ -154,22 +163,11 @@ class _PartDisplayState extends State<PartDetailWidget> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Widget build(BuildContext context) { |   Widget getBody(BuildContext context) { | ||||||
|     return Scaffold( |     return Center( | ||||||
|       appBar: AppBar( |       child: ListView( | ||||||
|         title: Text("Part Details"), |         children: partTiles(), | ||||||
|       ), |       ), | ||||||
|       drawer: new InvenTreeDrawer(context), |  | ||||||
|       floatingActionButton: FloatingActionButton( |  | ||||||
|         child: FaIcon(FontAwesomeIcons.ellipsisH), |  | ||||||
|         // TODO - Add pop-up icons |  | ||||||
|         // Ref: https://stackoverflow.com/questions/46480221/flutter-floating-action-button-with-speed-dial#46480722 |  | ||||||
|       ), |  | ||||||
|       body: Center( |  | ||||||
|         child: ListView( |  | ||||||
|           children: partTiles(), |  | ||||||
|         ), |  | ||||||
|       ) |  | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @@ -50,7 +50,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> { | |||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Future<void> request(BuildContext context) async { |   Future<void> request(BuildContext context) async { | ||||||
|     await item.reload(); |     await item.reload(context); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void _editStockItem() { |   void _editStockItem() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user