From 15d5bf3fb5f3182e4c73aa5131dec07f1d495e42 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 5 Apr 2020 22:06:56 +1000 Subject: [PATCH] Navigate "up" the category path to the parent category --- lib/widget/category_display.dart | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/widget/category_display.dart b/lib/widget/category_display.dart index e900a905..f22fd616 100644 --- a/lib/widget/category_display.dart +++ b/lib/widget/category_display.dart @@ -110,12 +110,18 @@ class _CategoryDisplayState extends State { title: Text("Parent Category"), subtitle: Text("${category.parentpathstring}"), onTap: () { - // TODO - Refactor this code into the InvenTreePart class - InvenTreePartCategory().get(category.parentId).then((var cat) { - if (cat is InvenTreePartCategory) { - Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat))); - } - }); + if (category.parentId < 0) { + Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null))); + } else { + // TODO - Refactor this code into the InvenTreePart class + InvenTreePartCategory().get(category.parentId).then(( + var cat) { + if (cat is InvenTreePartCategory) { + Navigator.push(context, MaterialPageRoute(builder: ( + context) => CategoryDisplayWidget(cat))); + } + }); + } }, ) ] @@ -158,6 +164,7 @@ class _CategoryDisplayState extends State { headerBuilder: (BuildContext context, bool isExpanded) { return ListTile( title: Text("Subcategories"), + leading: FaIcon(FontAwesomeIcons.stream), trailing: Text("${_subcategories.length}"), onTap: () { setState(() { @@ -173,6 +180,7 @@ class _CategoryDisplayState extends State { headerBuilder: (BuildContext context, bool isExpanded) { return ListTile( title: Text("Parts"), + leading: FaIcon(FontAwesomeIcons.shapes), trailing: Text("${_parts.length}"), onTap: () { setState(() {