diff --git a/lib/widget/category_display.dart b/lib/widget/category_display.dart index 28479dd5..913bdd5b 100644 --- a/lib/widget/category_display.dart +++ b/lib/widget/category_display.dart @@ -98,7 +98,6 @@ class _CategoryDisplayState extends State { style: TextStyle(fontWeight: FontWeight.bold), ), Expanded(child: PartList(_parts)), - Spacer(), ] ) ) diff --git a/lib/widget/location_display.dart b/lib/widget/location_display.dart new file mode 100644 index 00000000..49bdba44 --- /dev/null +++ b/lib/widget/location_display.dart @@ -0,0 +1,96 @@ + +import 'package:InvenTree/inventree/stock.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class LocationDisplayWidget extends StatefulWidget { + + LocationDisplayWidget(this.location, {Key key}) : super(key: key); + + final InvenTreeStockLocation location; + + final String title = "Location"; + + @override + _LocationDisplayState createState() => _LocationDisplayState(location); +} + + +class _LocationDisplayState extends State { + + _LocationDisplayState(this.location) { + _requestData(); + } + + final InvenTreeStockLocation location; + + List _sublocations = List(); + + List _items = List(); + + String get _title { + // TODO + return "Location:"; + } + + void _requestData() { + + int pk = location?.pk ?? -1; + + // Request a list of sub-locations under this one + InvenTreeStockLocation().list(filters: {"parent": "$pk"}).then((var locs) { + _sublocations.clear(); + + for (var loc in locs) { + if (loc is InvenTreeStockLocation) { + _sublocations.add(loc); + } + } + + setState(() {}); + + // Request a list of stock-items under this one + InvenTreeStockItem().list(filters: {"location": "$pk"}).then((var items) { + _items.clear(); + + for (var item in items) { + if (item is InvenTreeStockItem) { + _items.add(item); + } + } + + setState(() {}); + }); + + }); + + // TODO + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(_title), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Sublocations - ${_sublocations.length}", + textAlign: TextAlign.left, + style: TextStyle(fontWeight: FontWeight.bold), + ), + Divider(), + Text( + "Stock Items - ${_items.length}", + textAlign: TextAlign.left, + style: TextStyle(fontWeight: FontWeight.bold), + ) + ], + ) + ), + ); + } +} \ No newline at end of file