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:
@ -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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
@ -207,184 +228,135 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
drawer: new InvenTreeDrawer(context),
|
drawer: new InvenTreeDrawer(context),
|
||||||
body: Center(
|
body: GridView.count(
|
||||||
// Center is a layout widget. It takes a single child and positions it
|
crossAxisCount: MediaQuery.of(context).orientation == Orientation.portrait ? 3 : 5,
|
||||||
// in the middle of the parent.
|
shrinkWrap: true,
|
||||||
child: Column(
|
physics: ClampingScrollPhysics(),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: (<Widget>[
|
_iconButton(
|
||||||
Spacer(),
|
L10().scanBarcode,
|
||||||
Row(
|
FontAwesomeIcons.barcode,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
callback: () {
|
||||||
children: <Widget>[
|
_scan(context);
|
||||||
Column(
|
}
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: new FaIcon(FontAwesomeIcons.barcode),
|
|
||||||
tooltip: L10().scanBarcode,
|
|
||||||
onPressed: () { _scan(context); },
|
|
||||||
),
|
|
||||||
Text(L10().scanBarcode),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Spacer(),
|
_iconButton(
|
||||||
Row(
|
L10().parts,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
FontAwesomeIcons.shapes,
|
||||||
children: <Widget>[
|
callback: () {
|
||||||
Column(
|
_parts(context);
|
||||||
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),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// TODO - Re-add starred parts link
|
|
||||||
/*
|
|
||||||
Column(
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: FaIcon(FontAwesomeIcons.solidStar),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => StarredPartWidget()));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Text("Starred Parts"),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
*/
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Spacer(),
|
_iconButton(
|
||||||
Row(
|
L10().searchParts,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
FontAwesomeIcons.search,
|
||||||
|
callback: () {
|
||||||
|
_searchParts();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
// TODO - Re-add starred parts link
|
||||||
|
/*
|
||||||
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Column(
|
IconButton(
|
||||||
children: <Widget>[
|
icon: FaIcon(FontAwesomeIcons.solidStar),
|
||||||
IconButton(
|
onPressed: () {
|
||||||
icon: new FaIcon(FontAwesomeIcons.boxes),
|
Navigator.push(context, MaterialPageRoute(builder: (context) => StarredPartWidget()));
|
||||||
tooltip: L10().stock,
|
},
|
||||||
onPressed: () { _stock(context); },
|
|
||||||
),
|
|
||||||
Text(L10().stock),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: new FaIcon(FontAwesomeIcons.search),
|
|
||||||
tooltip: L10().searchStock,
|
|
||||||
onPressed: _searchStock,
|
|
||||||
),
|
|
||||||
Text(L10().searchStock),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
Text("Starred Parts"),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
Spacer(),
|
*/
|
||||||
// TODO - Re-add these when the features actually do something..
|
_iconButton(
|
||||||
|
L10().stock,
|
||||||
|
FontAwesomeIcons.boxes,
|
||||||
|
callback: () {
|
||||||
|
_stock(context);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
_iconButton(
|
||||||
|
L10().searchStock,
|
||||||
|
FontAwesomeIcons.search,
|
||||||
|
callback: () {
|
||||||
|
_searchStock();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
_iconButton(
|
||||||
|
L10().purchaseOrders,
|
||||||
|
FontAwesomeIcons.shoppingCart,
|
||||||
|
callback: () {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
),
|
||||||
|
_iconButton(
|
||||||
|
L10().suppliers,
|
||||||
|
FontAwesomeIcons.building,
|
||||||
|
callback: () {
|
||||||
|
_suppliers();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
_iconButton(
|
||||||
|
L10().manufacturers,
|
||||||
|
FontAwesomeIcons.industry,
|
||||||
|
callback: () {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
),
|
||||||
/*
|
/*
|
||||||
Row(
|
Spacer(),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: <Widget>[
|
||||||
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Column(
|
IconButton(
|
||||||
children: <Widget>[
|
icon: new FaIcon(FontAwesomeIcons.tools),
|
||||||
IconButton(
|
tooltip: "Build",
|
||||||
icon: new FaIcon(FontAwesomeIcons.building),
|
onPressed: _unsupported,
|
||||||
tooltip: "Suppliers",
|
|
||||||
onPressed: _suppliers,
|
|
||||||
),
|
|
||||||
Text("Suppliers"),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Column(
|
Text("Build"),
|
||||||
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(),
|
Column(
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Column(
|
IconButton(
|
||||||
children: <Widget>[
|
icon: new FaIcon(FontAwesomeIcons.shoppingCart),
|
||||||
IconButton(
|
tooltip: "Order",
|
||||||
icon: new FaIcon(FontAwesomeIcons.tools),
|
onPressed: _unsupported,
|
||||||
tooltip: "Build",
|
|
||||||
onPressed: _unsupported,
|
|
||||||
),
|
|
||||||
Text("Build"),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Column(
|
Text("Order"),
|
||||||
children: <Widget>[
|
]
|
||||||
IconButton(
|
|
||||||
icon: new FaIcon(FontAwesomeIcons.shoppingCart),
|
|
||||||
tooltip: "Order",
|
|
||||||
onPressed: _unsupported,
|
|
||||||
),
|
|
||||||
Text("Order"),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: new FaIcon(FontAwesomeIcons.truck),
|
|
||||||
tooltip: "Ship",
|
|
||||||
onPressed: _unsupported,
|
|
||||||
),
|
|
||||||
Text("Ship"),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Spacer(),
|
Column(
|
||||||
*/
|
|
||||||
Spacer(),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
IconButton(
|
||||||
child: _serverTile(),
|
icon: new FaIcon(FontAwesomeIcons.truck),
|
||||||
|
tooltip: "Ship",
|
||||||
|
onPressed: _unsupported,
|
||||||
),
|
),
|
||||||
],
|
Text("Ship"),
|
||||||
),
|
]
|
||||||
]),
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
Spacer(),
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
Spacer(),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: _serverTile(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
*/
|
||||||
|
],
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user