mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Add display for part information
- Very sparse currently
This commit is contained in:
parent
d3415e5ebe
commit
718f89b339
@ -75,7 +75,13 @@ class InvenTreeModel {
|
|||||||
// TODO - Add "timeout"
|
// TODO - Add "timeout"
|
||||||
// TODO - Add error catching
|
// TODO - Add error catching
|
||||||
|
|
||||||
var response = await InvenTreeAPI().get(path.join(URL, pk.toString()));
|
var addr = path.join(URL, pk.toString());
|
||||||
|
|
||||||
|
if (!addr.endsWith("/")) {
|
||||||
|
addr += "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = await InvenTreeAPI().get(addr);
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
if (response.statusCode != 200) {
|
||||||
print("Error retrieving data");
|
print("Error retrieving data");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import 'package:InvenTree/inventree/part.dart';
|
import 'package:InvenTree/inventree/part.dart';
|
||||||
|
import 'package:InvenTree/widget/part_display.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -87,10 +88,15 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
"Subcategories - ${_subcategories.length}",
|
"Subcategories - ${_subcategories.length}",
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
Expanded(child: SubcategoryList(_subcategories)),
|
Expanded(child: SubcategoryList(_subcategories)),
|
||||||
Divider(),
|
Divider(),
|
||||||
Text("Parts - ${_parts.length}"),
|
Text("Parts - ${_parts.length}",
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
Expanded(child: PartList(_parts)),
|
Expanded(child: PartList(_parts)),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
]
|
]
|
||||||
@ -114,7 +120,6 @@ class SubcategoryList extends StatelessWidget {
|
|||||||
// Attempt to load the sub-category.
|
// Attempt to load the sub-category.
|
||||||
InvenTreePartCategory().get(pk).then((var cat) {
|
InvenTreePartCategory().get(pk).then((var cat) {
|
||||||
if (cat is InvenTreePartCategory) {
|
if (cat is InvenTreePartCategory) {
|
||||||
print("Found cat: <${cat.pk}> : ${cat.name} - ${cat.description}");
|
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
||||||
}
|
}
|
||||||
@ -157,6 +162,16 @@ class PartList extends StatelessWidget {
|
|||||||
|
|
||||||
PartList(this._parts);
|
PartList(this._parts);
|
||||||
|
|
||||||
|
void _openPart(BuildContext context, int pk) {
|
||||||
|
// Attempt to load the part information
|
||||||
|
InvenTreePart().get(pk).then((var part) {
|
||||||
|
if (part is InvenTreePart) {
|
||||||
|
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDisplayWidget(part)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Widget _build(BuildContext context, int index) {
|
Widget _build(BuildContext context, int index) {
|
||||||
InvenTreePart part;
|
InvenTreePart part;
|
||||||
|
|
||||||
@ -165,10 +180,15 @@ class PartList extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
child: Column(
|
child: InkWell(
|
||||||
children: <Widget> [
|
child: Column(
|
||||||
Text('${part.name} - ${part.description}'),
|
children: <Widget> [
|
||||||
]
|
Text('${part.name} - ${part.description}'),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
_openPart(context, part.pk);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
51
lib/widget/part_display.dart
Normal file
51
lib/widget/part_display.dart
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
import 'package:InvenTree/inventree/part.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class PartDisplayWidget extends StatefulWidget {
|
||||||
|
|
||||||
|
PartDisplayWidget(this.part, {Key key}) : super(key: key);
|
||||||
|
|
||||||
|
final InvenTreePart part;
|
||||||
|
|
||||||
|
@override
|
||||||
|
_PartDisplayState createState() => _PartDisplayState(part);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class _PartDisplayState extends State<PartDisplayWidget> {
|
||||||
|
|
||||||
|
_PartDisplayState(this.part) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
final InvenTreePart part;
|
||||||
|
|
||||||
|
String get _title {
|
||||||
|
if (part == null) {
|
||||||
|
return "Part";
|
||||||
|
} else {
|
||||||
|
return "Part '${part.name}'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(_title),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Text("Description: ${part.description}"),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user