From 40df490a2136d1b9a1beae9c946a3323249a17a8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 31 Jan 2021 21:56:06 +1100 Subject: [PATCH] Add "actions" tab for Part display --- lib/widget/part_detail.dart | 62 +++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/lib/widget/part_detail.dart b/lib/widget/part_detail.dart index 5d23eacf..d1b7ba11 100644 --- a/lib/widget/part_detail.dart +++ b/lib/widget/part_detail.dart @@ -142,6 +142,16 @@ class _PartDisplayState extends RefreshableState { } + Widget headerTile() { + return Card( + child: ListTile( + title: Text("${part.fullname}"), + subtitle: Text("${part.description}"), + leading: InvenTreeAPI().getImage(part.thumbnail), + ) + ); + } + /* * Build a list of tiles to display under the part description */ @@ -151,13 +161,7 @@ class _PartDisplayState extends RefreshableState { // Image / name / description tiles.add( - Card( - child: ListTile( - title: Text("${part.fullname}"), - subtitle: Text("${part.description}"), - leading: InvenTreeAPI().getImage(part.thumbnail), - ) - ) + headerTile() ); // Category information @@ -274,7 +278,8 @@ class _PartDisplayState extends RefreshableState { ); } - if (part.isTrackable) { + // TODO - Add request tests? + if (false && part.isTrackable) { tiles.add(ListTile( title: Text("Required Tests"), leading: FaIcon(FontAwesomeIcons.tasks), @@ -300,6 +305,32 @@ class _PartDisplayState extends RefreshableState { } + List actionTiles() { + List tiles = []; + + tiles.add(headerTile()); + + tiles.add( + ListTile( + title: Text("Create Stock Item"), + leading: FaIcon(FontAwesomeIcons.box), + onTap: null, + ) + ); + + tiles.add( + ListTile( + title: Text("Scan New Stock Item"), + leading: FaIcon(FontAwesomeIcons.box), + trailing: FaIcon(FontAwesomeIcons.qrcode), + onTap: null, + ), + ); + + return tiles; + } + + Widget getSelectedWidget(int index) { switch (index) { case 0: @@ -311,12 +342,7 @@ class _PartDisplayState extends RefreshableState { case 1: return Center( child: ListView( - children: [ - ListTile( - title: Text("Stock"), - subtitle: Text("Stock info goes here!"), - ) - ], + children: actionTiles(), ) ); default: @@ -335,12 +361,8 @@ class _PartDisplayState extends RefreshableState { title: Text("Details"), ), BottomNavigationBarItem( - icon: FaIcon(FontAwesomeIcons.thList), - title: Text("BOM"), - ), - BottomNavigationBarItem( - icon: FaIcon(FontAwesomeIcons.boxes), - title: Text("Stock"), + icon: FaIcon(FontAwesomeIcons.wrench), + title: Text("Actions"), ), ] );