mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 05:15:42 +00:00 
			
		
		
		
	Abstract CompanyList class
- Now support SupplierList class - Now support CustomerList class
This commit is contained in:
		| @@ -216,7 +216,7 @@ class _MyHomePageState extends State<MyHomePage> { | |||||||
|   void _suppliers() { |   void _suppliers() { | ||||||
|     if (!InvenTreeAPI().checkConnection(context)) return; |     if (!InvenTreeAPI().checkConnection(context)) return; | ||||||
|  |  | ||||||
|     Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget())); |     Navigator.push(context, MaterialPageRoute(builder: (context) => SupplierListWidget())); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void _unsupported() { |   void _unsupported() { | ||||||
| @@ -249,7 +249,7 @@ class _MyHomePageState extends State<MyHomePage> { | |||||||
|         title: Text(widget.title), |         title: Text(widget.title), | ||||||
|         actions: <Widget>[ |         actions: <Widget>[ | ||||||
|           IconButton( |           IconButton( | ||||||
|             icon: Icon(Icons.search), |             icon: FaIcon(FontAwesomeIcons.search), | ||||||
|             tooltip: 'Search', |             tooltip: 'Search', | ||||||
|             onPressed: null, |             onPressed: null, | ||||||
|           ), |           ), | ||||||
|   | |||||||
| @@ -5,14 +5,29 @@ import 'package:flutter/material.dart'; | |||||||
| import 'package:InvenTree/api.dart'; | import 'package:InvenTree/api.dart'; | ||||||
| import 'package:InvenTree/inventree/company.dart'; | import 'package:InvenTree/inventree/company.dart'; | ||||||
| import 'package:InvenTree/widget/drawer.dart'; | import 'package:InvenTree/widget/drawer.dart'; | ||||||
|  | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | ||||||
|  |  | ||||||
| class CompanyListWidget extends StatefulWidget { | abstract class CompanyListWidget extends StatefulWidget { | ||||||
|  |  | ||||||
|  |   String title; | ||||||
|  |   Map<String, String> filters; | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   _CompanyListState createState() => _CompanyListState(); |   _CompanyListState createState() => _CompanyListState(title, filters); | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | class SupplierListWidget extends CompanyListWidget { | ||||||
|  |   @override | ||||||
|  |   _CompanyListState createState() => _CompanyListState("Suppliers", {"is_supplier": "true"}); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class CustomerListWidget extends CompanyListWidget { | ||||||
|  |   @override | ||||||
|  |   _CompanyListState createState() => _CompanyListState("Customers", {"is_customer": "true"}); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| class _CompanyListState extends State<CompanyListWidget> { | class _CompanyListState extends State<CompanyListWidget> { | ||||||
|  |  | ||||||
| @@ -22,13 +37,15 @@ class _CompanyListState extends State<CompanyListWidget> { | |||||||
|  |  | ||||||
|   var _title = "Companies"; |   var _title = "Companies"; | ||||||
|  |  | ||||||
|   _CompanyListState() { |   Map<String, String> _filters = Map<String, String>(); | ||||||
|  |  | ||||||
|  |   _CompanyListState(this._title, this._filters) { | ||||||
|     _requestData(); |     _requestData(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void _requestData() { |   void _requestData() { | ||||||
|  |  | ||||||
|     InvenTreeCompany().list().then((var companies) { |     InvenTreeCompany().list(filters: _filters).then((var companies) { | ||||||
|  |  | ||||||
|       _companies.clear(); |       _companies.clear(); | ||||||
|  |  | ||||||
| @@ -80,6 +97,13 @@ class _CompanyListState extends State<CompanyListWidget> { | |||||||
|     return Scaffold( |     return Scaffold( | ||||||
|         appBar: AppBar( |         appBar: AppBar( | ||||||
|           title: Text("$_title"), |           title: Text("$_title"), | ||||||
|  |           actions: <Widget>[ | ||||||
|  |             IconButton( | ||||||
|  |               icon: FaIcon(FontAwesomeIcons.plus), | ||||||
|  |               tooltip: 'New', | ||||||
|  |               onPressed: null, | ||||||
|  |             ) | ||||||
|  |           ], | ||||||
|         ), |         ), | ||||||
|         drawer: new InvenTreeDrawer(context), |         drawer: new InvenTreeDrawer(context), | ||||||
|         body: ListView( |         body: ListView( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user