mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Better layout mechanic for Part display
- Now works well even if it overflows the available screen space
This commit is contained in:
parent
5652926a38
commit
fb1fb799d2
@ -29,50 +29,35 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
|||||||
|
|
||||||
InvenTreePart part;
|
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<Widget> partDetails() {
|
|
||||||
List<Widget> 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
|
* Build a list of tiles to display under the part description
|
||||||
*/
|
*/
|
||||||
List<Widget> partTiles() {
|
List<Widget> partTiles() {
|
||||||
|
|
||||||
List<Widget> tiles = [
|
List<Widget> 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
|
// Category information
|
||||||
if (part.categoryName.isNotEmpty) {
|
if (part.categoryName.isNotEmpty) {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
Card(
|
ListTile(
|
||||||
child: ListTile(
|
|
||||||
title: Text("Part Category"),
|
title: Text("Part Category"),
|
||||||
subtitle: Text("${part.categoryName}"),
|
subtitle: Text("${part.categoryName}"),
|
||||||
leading: FaIcon(FontAwesomeIcons.stream),
|
leading: FaIcon(FontAwesomeIcons.stream),
|
||||||
@ -82,105 +67,86 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// External link?
|
// External link?
|
||||||
if (part.link.isNotEmpty) {
|
if (part.link.isNotEmpty) {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
Card(
|
ListTile(
|
||||||
child: ListTile(
|
|
||||||
title: Text("${part.link}"),
|
title: Text("${part.link}"),
|
||||||
leading: FaIcon(FontAwesomeIcons.link),
|
leading: FaIcon(FontAwesomeIcons.link),
|
||||||
trailing: Text(""),
|
trailing: Text(""),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stock information
|
// Stock information
|
||||||
tiles.add(
|
tiles.add(
|
||||||
Card(
|
ListTile(
|
||||||
child: ListTile(
|
|
||||||
title: Text("Stock"),
|
title: Text("Stock"),
|
||||||
leading: FaIcon(FontAwesomeIcons.boxes),
|
leading: FaIcon(FontAwesomeIcons.boxes),
|
||||||
trailing: Text("${part.inStock}"),
|
trailing: Text("${part.inStock}"),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
),
|
),
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Parts on order
|
// Parts on order
|
||||||
if (part.isPurchaseable) {
|
if (part.isPurchaseable) {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
Card(
|
ListTile(
|
||||||
child: ListTile(
|
|
||||||
title: Text("On Order"),
|
title: Text("On Order"),
|
||||||
leading: FaIcon(FontAwesomeIcons.shoppingCart),
|
leading: FaIcon(FontAwesomeIcons.shoppingCart),
|
||||||
trailing: Text("${part.onOrder}"),
|
trailing: Text("${part.onOrder}"),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parts being built
|
// Parts being built
|
||||||
if (part.isAssembly) {
|
if (part.isAssembly) {
|
||||||
|
|
||||||
tiles.add(
|
tiles.add(ListTile(
|
||||||
Card(
|
|
||||||
child: ListTile(
|
|
||||||
title: Text("Bill of Materials"),
|
title: Text("Bill of Materials"),
|
||||||
leading: FaIcon(FontAwesomeIcons.thList),
|
leading: FaIcon(FontAwesomeIcons.thList),
|
||||||
trailing: Text("${part.bomItemCount}"),
|
trailing: Text("${part.bomItemCount}"),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
tiles.add(
|
tiles.add(
|
||||||
Card(
|
ListTile(
|
||||||
child: ListTile(
|
|
||||||
title: Text("Building"),
|
title: Text("Building"),
|
||||||
leading: FaIcon(FontAwesomeIcons.tools),
|
leading: FaIcon(FontAwesomeIcons.tools),
|
||||||
trailing: Text("${part.building}"),
|
trailing: Text("${part.building}"),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part.isComponent) {
|
if (part.isComponent) {
|
||||||
tiles.add(
|
tiles.add(ListTile(
|
||||||
Card(
|
|
||||||
child: ListTile(
|
|
||||||
title: Text("Used In"),
|
title: Text("Used In"),
|
||||||
leading: FaIcon(FontAwesomeIcons.sitemap),
|
leading: FaIcon(FontAwesomeIcons.sitemap),
|
||||||
trailing: Text("${part.usedInCount}"),
|
trailing: Text("${part.usedInCount}"),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notes field?
|
// Notes field?
|
||||||
if (part.notes.isNotEmpty) {
|
if (part.notes.isNotEmpty) {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
Card(
|
ListTile(
|
||||||
child: ListTile(
|
|
||||||
title: Text("Notes"),
|
title: Text("Notes"),
|
||||||
leading: FaIcon(FontAwesomeIcons.stickyNote),
|
leading: FaIcon(FontAwesomeIcons.stickyNote),
|
||||||
trailing: Text(""),
|
trailing: Text(""),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles.add(Spacer());
|
|
||||||
|
|
||||||
return tiles;
|
return tiles;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -193,9 +159,7 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
|||||||
),
|
),
|
||||||
drawer: new InvenTreeDrawer(context),
|
drawer: new InvenTreeDrawer(context),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: ListView(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: partTiles(),
|
children: partTiles(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user