2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Display for StockItem

- Empty for now
This commit is contained in:
Oliver Walters 2020-04-03 12:23:57 +11:00
parent 7d060acc93
commit 3a686b8b7f
3 changed files with 138 additions and 10 deletions

View File

@ -126,11 +126,7 @@ class SubcategoryList extends StatelessWidget {
}
Widget _build(BuildContext context, int index) {
InvenTreePartCategory cat;
if (index < _categories.length) {
cat = _categories[index];
}
InvenTreePartCategory cat = _categories[index];
return Card(
child: InkWell(

View File

@ -1,7 +1,9 @@
import 'package:InvenTree/inventree/stock.dart';
import 'package:InvenTree/widget/stock_display.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
class LocationDisplayWidget extends StatefulWidget {
@ -29,8 +31,12 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
List<InvenTreeStockItem> _items = List<InvenTreeStockItem>();
String get _title {
// TODO
return "Location:";
if (location == null) {
return "Location:";
} else {
return "Stock Location '${location.name}'";
}
}
void _requestData() {
@ -63,8 +69,6 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
});
});
// TODO
}
@override
@ -82,15 +86,92 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
textAlign: TextAlign.left,
style: TextStyle(fontWeight: FontWeight.bold),
),
Expanded(child: SublocationList(_sublocations)),
Divider(),
Text(
"Stock Items - ${_items.length}",
textAlign: TextAlign.left,
style: TextStyle(fontWeight: FontWeight.bold),
)
),
Expanded(child: StockList(_items)),
],
)
),
);
}
}
class SublocationList extends StatelessWidget {
final List<InvenTreeStockLocation> _locations;
SublocationList(this._locations);
void _openLocation(BuildContext context, int pk) {
InvenTreeStockLocation().get(pk).then((var loc) {
if (loc is InvenTreeStockLocation) {
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
}
});
}
Widget _build(BuildContext context, int index) {
InvenTreeStockLocation loc = _locations[index];
return Card(
child: InkWell(
child: Column(
children: <Widget>[
Text('${loc.name} - ${loc.description}'),
],
),
onTap: () {
_openLocation(context, loc.pk);
},
)
);
}
@override
Widget build(BuildContext context) {
return ListView.builder(itemBuilder: _build, itemCount: _locations.length);
}
}
class StockList extends StatelessWidget {
final List<InvenTreeStockItem> _items;
StockList(this._items);
void _openItem(BuildContext context, int pk) {
InvenTreeStockItem().get(pk).then((var item) {
if (item is InvenTreeStockItem) {
Navigator.push(context, MaterialPageRoute(builder: (context) => StockItemDisplayWidget(item)));
}
});
}
Widget _build(BuildContext context, int index) {
InvenTreeStockItem item = _items[index];
return Card(
child: InkWell(
child: Column(
children: <Widget>[
Text('${item.quantity.toString()} x ${item.partName}')
]
),
onTap: () {
_openItem(context, item.pk);
},
)
);
}
@override
Widget build(BuildContext context) {
return ListView.builder(itemBuilder: _build, itemCount: _items.length);
}
}

View File

@ -0,0 +1,51 @@
import 'package:InvenTree/inventree/stock.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class StockItemDisplayWidget extends StatefulWidget {
StockItemDisplayWidget(this.item, {Key key}) : super(key: key);
final InvenTreeStockItem item;
@override
_StockItemDisplayState createState() => _StockItemDisplayState(item);
}
class _StockItemDisplayState extends State<StockItemDisplayWidget> {
_StockItemDisplayState(this.item) {
// TODO
}
final InvenTreeStockItem item;
String get _title {
if (item == null) {
return "Stock Item";
} else {
print(item.jsondata);
return "Item: x ${item.partName}";
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(_title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Stock Item: hello"),
],
)
)
);
}
}