2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-13 02:35:27 +00:00

Company list is now refreshable

This commit is contained in:
Oliver Walters
2020-04-15 12:07:36 +10:00
parent 578d54367a
commit 90a39ae3de
6 changed files with 32 additions and 43 deletions

View File

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:InvenTree/api.dart';
import 'package:InvenTree/inventree/company.dart';
import 'package:InvenTree/widget/drawer.dart';
import 'package:InvenTree/widget/refreshable_state.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
abstract class CompanyListWidget extends StatefulWidget {
@ -30,21 +31,23 @@ class CustomerListWidget extends CompanyListWidget {
}
class _CompanyListState extends State<CompanyListWidget> {
class _CompanyListState extends RefreshableState<CompanyListWidget> {
var _companies = new List<InvenTreeCompany>();
var _filteredCompanies = new List<InvenTreeCompany>();
var _title = "Companies";
String _title = "Companies";
@override
String getAppBarTitle(BuildContext context) { return _title; }
Map<String, String> _filters = Map<String, String>();
_CompanyListState(this._title, this._filters) {
_requestData();
}
_CompanyListState(this._title, this._filters) {}
void _requestData() {
@override
Future<void> request(BuildContext context) async {
InvenTreeCompany().list(context, filters: _filters).then((var companies) {
@ -94,38 +97,24 @@ class _CompanyListState extends State<CompanyListWidget> {
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("$_title"),
actions: <Widget>[
IconButton(
icon: FaIcon(FontAwesomeIcons.plus),
tooltip: 'New',
onPressed: null,
)
],
Widget getBody(BuildContext context) {
return ListView(
children: <Widget>[
TextField(
decoration: InputDecoration(
hintText: 'Filter results',
),
onChanged: (String text) {
setState(() {
_filterResults(text);
});
},
),
drawer: new InvenTreeDrawer(context),
body: ListView(
children: <Widget>[
TextField(
decoration: InputDecoration(
hintText: 'Filter results',
),
onChanged: (String text) {
setState(() {
_filterResults(text);
});
},
),
ListView.builder(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
itemBuilder: _showCompany, itemCount: _filteredCompanies.length)
],
)
ListView.builder(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
itemBuilder: _showCompany, itemCount: _filteredCompanies.length)
],
);
}
}