From fb1fb799d2219948d8a16da9d9140826e2aa8185 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 12:09:27 +1000 Subject: [PATCH] Better layout mechanic for Part display - Now works well even if it overflows the available screen space --- lib/widget/part_display.dart | 88 +++++++++++------------------------- 1 file changed, 26 insertions(+), 62 deletions(-) diff --git a/lib/widget/part_display.dart b/lib/widget/part_display.dart index 712069e6..88e47b54 100644 --- a/lib/widget/part_display.dart +++ b/lib/widget/part_display.dart @@ -29,50 +29,35 @@ class _PartDisplayState extends State { InvenTreePart part; - /* - * Construct a list of detail elements about this part. - * Not all elements are set for each part, so only add the ones that are important. - */ - List partDetails() { - List widgets = [ - - // Image / name / description - ListTile( - title: Text("${part.fullname}"), - subtitle: Text("${part.description}"), - leading: Image( - image: InvenTreeAPI().getImage(part.image) - ), - trailing: IconButton( - icon: FaIcon(FontAwesomeIcons.edit), - onPressed: null, - ), - ) - ]; - - return widgets; - } - /* * Build a list of tiles to display under the part description */ List partTiles() { List tiles = [ - Card( - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: partDetails(), - ) - ), ]; + // Image / name / description + tiles.add( + Card( + child: ListTile( + title: Text("${part.fullname}"), + subtitle: Text("${part.description}"), + leading: Image( + image: InvenTreeAPI().getImage(part.image) + ), + trailing: IconButton( + icon: FaIcon(FontAwesomeIcons.edit), + onPressed: null, + ), + ) + ) + ); + // Category information if (part.categoryName.isNotEmpty) { tiles.add( - Card( - child: ListTile( + ListTile( title: Text("Part Category"), subtitle: Text("${part.categoryName}"), leading: FaIcon(FontAwesomeIcons.stream), @@ -82,105 +67,86 @@ class _PartDisplayState extends State { }); }, ) - ) ); } // External link? if (part.link.isNotEmpty) { tiles.add( - Card( - child: ListTile( + ListTile( title: Text("${part.link}"), leading: FaIcon(FontAwesomeIcons.link), trailing: Text(""), onTap: null, ) - ) ); } // Stock information tiles.add( - Card( - child: ListTile( + ListTile( title: Text("Stock"), leading: FaIcon(FontAwesomeIcons.boxes), trailing: Text("${part.inStock}"), onTap: null, ), - ) ); // Parts on order if (part.isPurchaseable) { tiles.add( - Card( - child: ListTile( + ListTile( title: Text("On Order"), leading: FaIcon(FontAwesomeIcons.shoppingCart), trailing: Text("${part.onOrder}"), onTap: null, ) - ) ); } // Parts being built if (part.isAssembly) { - tiles.add( - Card( - child: ListTile( + tiles.add(ListTile( title: Text("Bill of Materials"), leading: FaIcon(FontAwesomeIcons.thList), trailing: Text("${part.bomItemCount}"), onTap: null, ) - ) ); tiles.add( - Card( - child: ListTile( + ListTile( title: Text("Building"), leading: FaIcon(FontAwesomeIcons.tools), trailing: Text("${part.building}"), onTap: null, ) - ) ); } if (part.isComponent) { - tiles.add( - Card( - child: ListTile( + tiles.add(ListTile( title: Text("Used In"), leading: FaIcon(FontAwesomeIcons.sitemap), trailing: Text("${part.usedInCount}"), onTap: null, ) - ) ); } // Notes field? if (part.notes.isNotEmpty) { tiles.add( - Card( - child: ListTile( + ListTile( title: Text("Notes"), leading: FaIcon(FontAwesomeIcons.stickyNote), trailing: Text(""), onTap: null, ) - ) ); } - tiles.add(Spacer()); - return tiles; } @@ -193,9 +159,7 @@ class _PartDisplayState extends State { ), drawer: new InvenTreeDrawer(context), body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, + child: ListView( children: partTiles(), ), )