From 3447d08d7bbc8d075b5d25fdf1363c781a790d16 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 9 Aug 2021 07:52:09 +1000 Subject: [PATCH] Action tiles to create new category and new part --- lib/widget/category_display.dart | 55 +++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/lib/widget/category_display.dart b/lib/widget/category_display.dart index cc65829d..421b9e68 100644 --- a/lib/widget/category_display.dart +++ b/lib/widget/category_display.dart @@ -219,18 +219,57 @@ class _CategoryDisplayState extends RefreshableState { return tiles; } - List actionTiles() { + Future _newCategory(BuildContext context) async { + + int pk = category?.pk ?? -1; + + launchApiForm( + context, + L10().categoryCreate, + InvenTreePartCategory().URL, + { + "name": {}, + "description": {}, + "parent": { + } + }, + modelData: { + "parent": (pk > 0) ? pk : null, + } + ); + } + + Future _newPart() async { + + } + + List actionTiles(BuildContext context) { List tiles = [ getCategoryDescriptionCard(extra: false), - ListTile( - title: Text(L10().actions, - style: TextStyle(fontWeight: FontWeight.bold) - ) - ) ]; - // TODO - Actions! + tiles.add( + ListTile( + title: Text(L10().categoryCreate), + subtitle: Text(L10().categoryCreateDetail), + leading: FaIcon(FontAwesomeIcons.sitemap, color: COLOR_CLICK), + onTap: () async { + _newCategory(context); + }, + ) + ); + + if (category != null) { + tiles.add( + ListTile( + title: Text(L10().partCreate), + subtitle: Text(L10().partCreateDetail), + leading: FaIcon(FontAwesomeIcons.shapes, color: COLOR_CLICK), + onTap: _newPart, + ) + ); + } return tiles; } @@ -251,7 +290,7 @@ class _CategoryDisplayState extends RefreshableState { ); case 2: return ListView( - children: actionTiles() + children: actionTiles(context) ); default: return ListView();