2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-13 02:35:27 +00:00

Refactor the "home" page

- Use a grid view instead of hard-coded columns
- Aware of the screen orientation
This commit is contained in:
Oliver
2021-09-27 22:34:55 +10:00
parent f9b688cdab
commit 11c8a55677

View File

@ -183,6 +183,27 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
}
}
Widget _iconButton(String label, IconData icon, {Function()? callback}) {
return GestureDetector(
child: Card(
margin: EdgeInsets.symmetric(
vertical: 10,
horizontal: 10
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FaIcon(icon),
Text(label),
]
)
),
onTap: callback,
);
}
@override
Widget build(BuildContext context) {
@ -207,52 +228,31 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
],
),
drawer: new InvenTreeDrawer(context),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: (<Widget>[
Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.barcode),
tooltip: L10().scanBarcode,
onPressed: () { _scan(context); },
body: GridView.count(
crossAxisCount: MediaQuery.of(context).orientation == Orientation.portrait ? 3 : 5,
shrinkWrap: true,
physics: ClampingScrollPhysics(),
children: [
_iconButton(
L10().scanBarcode,
FontAwesomeIcons.barcode,
callback: () {
_scan(context);
}
),
Text(L10().scanBarcode),
],
_iconButton(
L10().parts,
FontAwesomeIcons.shapes,
callback: () {
_parts(context);
}
),
],
),
Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.shapes),
tooltip: L10().parts,
onPressed: () { _parts(context); },
),
Text(L10().parts),
],
),
Column(
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.search),
tooltip: L10().searchParts,
onPressed: _searchParts,
),
Text(L10().searchParts),
],
_iconButton(
L10().searchParts,
FontAwesomeIcons.search,
callback: () {
_searchParts();
}
),
// TODO - Re-add starred parts link
/*
@ -268,72 +268,42 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
]
),
*/
],
_iconButton(
L10().stock,
FontAwesomeIcons.boxes,
callback: () {
_stock(context);
}
),
Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.boxes),
tooltip: L10().stock,
onPressed: () { _stock(context); },
_iconButton(
L10().searchStock,
FontAwesomeIcons.search,
callback: () {
_searchStock();
}
),
Text(L10().stock),
],
_iconButton(
L10().purchaseOrders,
FontAwesomeIcons.shoppingCart,
callback: () {
// TODO
}
),
Column(
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.search),
tooltip: L10().searchStock,
onPressed: _searchStock,
_iconButton(
L10().suppliers,
FontAwesomeIcons.building,
callback: () {
_suppliers();
}
),
Text(L10().searchStock),
],
_iconButton(
L10().manufacturers,
FontAwesomeIcons.industry,
callback: () {
// TODO
}
),
]
),
Spacer(),
// TODO - Re-add these when the features actually do something..
/*
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
IconButton(
icon: new FaIcon(FontAwesomeIcons.building),
tooltip: "Suppliers",
onPressed: _suppliers,
),
Text("Suppliers"),
],
),
Column(
children: <Widget>[
IconButton(
icon: FaIcon(FontAwesomeIcons.industry),
tooltip: "Manufacturers",
onPressed: _manufacturers,
),
Text("Manufacturers")
],
),
Column(
children: <Widget>[
IconButton(
icon: FaIcon(FontAwesomeIcons.userTie),
tooltip: "Customers",
onPressed: _customers,
),
Text("Customers"),
]
)
],
),
Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -372,6 +342,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
),
Spacer(),
*/
/*
Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.center,
@ -383,8 +354,9 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
],
),
]),
),
),
*/
],
)
);
}
}