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