mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-29 14:06:47 +00:00
Display for StockItem
- Empty for now
This commit is contained in:
parent
7d060acc93
commit
3a686b8b7f
@ -126,11 +126,7 @@ class SubcategoryList extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _build(BuildContext context, int index) {
|
Widget _build(BuildContext context, int index) {
|
||||||
InvenTreePartCategory cat;
|
InvenTreePartCategory cat = _categories[index];
|
||||||
|
|
||||||
if (index < _categories.length) {
|
|
||||||
cat = _categories[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
import 'package:InvenTree/inventree/stock.dart';
|
import 'package:InvenTree/inventree/stock.dart';
|
||||||
|
import 'package:InvenTree/widget/stock_display.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
class LocationDisplayWidget extends StatefulWidget {
|
class LocationDisplayWidget extends StatefulWidget {
|
||||||
|
|
||||||
@ -29,8 +31,12 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
|
|||||||
List<InvenTreeStockItem> _items = List<InvenTreeStockItem>();
|
List<InvenTreeStockItem> _items = List<InvenTreeStockItem>();
|
||||||
|
|
||||||
String get _title {
|
String get _title {
|
||||||
// TODO
|
|
||||||
|
if (location == null) {
|
||||||
return "Location:";
|
return "Location:";
|
||||||
|
} else {
|
||||||
|
return "Stock Location '${location.name}'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _requestData() {
|
void _requestData() {
|
||||||
@ -63,8 +69,6 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -82,15 +86,92 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
|
|||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
|
Expanded(child: SublocationList(_sublocations)),
|
||||||
Divider(),
|
Divider(),
|
||||||
Text(
|
Text(
|
||||||
"Stock Items - ${_items.length}",
|
"Stock Items - ${_items.length}",
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
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);
|
||||||
|
}
|
||||||
|
}
|
51
lib/widget/stock_display.dart
Normal file
51
lib/widget/stock_display.dart
Normal 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"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user