2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-30 06:26:52 +00:00

Simplify grid layout

This commit is contained in:
Oliver 2021-09-27 23:15:33 +10:00
parent 7d80b4f151
commit d28392bae3

View File

@ -64,31 +64,42 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
scanQrCode(context); scanQrCode(context);
} }
void _parts(BuildContext context) { void _showParts(BuildContext context) {
if (!InvenTreeAPI().checkConnection(context)) return; if (!InvenTreeAPI().checkConnection(context)) return;
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null))); Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
} }
void _stock(BuildContext context) { void _showStarredParts(BuildContext context) {
if (!InvenTreeAPI().checkConnection(context)) return;
// TODO
// Navigator.push(context, MaterialPageRoute(builder: (context) => StarredPartWidget()));
}
void _showStock(BuildContext context) {
if (!InvenTreeAPI().checkConnection(context)) return; if (!InvenTreeAPI().checkConnection(context)) return;
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null))); Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
} }
void _suppliers() { void _showPurchaseOrders(BuildContext context) {
if (!InvenTreeAPI().checkConnection(context)) return;
}
void _showSuppliers(BuildContext context) {
if (!InvenTreeAPI().checkConnection(context)) return; if (!InvenTreeAPI().checkConnection(context)) return;
Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget(L10().suppliers, {"is_supplier": "true"}))); Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget(L10().suppliers, {"is_supplier": "true"})));
} }
void _manufacturers() { void _showManufacturers(BuildContext context) {
if (!InvenTreeAPI().checkConnection(context)) return; if (!InvenTreeAPI().checkConnection(context)) return;
Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget(L10().manufacturers, {"is_manufacturer": "true"}))); Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget(L10().manufacturers, {"is_manufacturer": "true"})));
} }
void _customers() { void _showCustomers(BuildContext context) {
if (!InvenTreeAPI().checkConnection(context)) return; if (!InvenTreeAPI().checkConnection(context)) return;
Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget(L10().customers, {"is_customer": "true"}))); Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyListWidget(L10().customers, {"is_customer": "true"})));
@ -183,6 +194,36 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
} }
} }
Widget _header(String label) {
return Card(
margin: EdgeInsets.symmetric(
vertical: 1,
horizontal: 10,
),
child: ListTile(
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 1
),
title: Text(
label,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
);
}
Widget _grid(List<Widget> children) {
return GridView.extent(
maxCrossAxisExtent: 140,
shrinkWrap: true,
physics: ClampingScrollPhysics(),
children: children,
);
}
Widget _iconButton(String label, IconData icon, {Function()? callback}) { Widget _iconButton(String label, IconData icon, {Function()? callback}) {
return GestureDetector( return GestureDetector(
@ -194,8 +235,16 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
FaIcon(icon), FaIcon(
Text(label), icon,
color: COLOR_CLICK,
),
Divider(
height: 10,
),
Text(
label,
),
] ]
) )
), ),
@ -218,21 +267,21 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
appBar: AppBar( appBar: AppBar(
title: Text(L10().appTitle), title: Text(L10().appTitle),
actions: <Widget>[ actions: <Widget>[
/* // IconButton(
IconButton( // icon: FaIcon(FontAwesomeIcons.barcode),
icon: FaIcon(FontAwesomeIcons.search), // tooltip: L10().scanBarcode,
tooltip: L10().search, // onPressed: () {
onPressed: _searchParts, // _scan(context);
), // },
*/ // ),
], ],
), ),
drawer: new InvenTreeDrawer(context), drawer: new InvenTreeDrawer(context),
body: GridView.extent( body: ListView(
maxCrossAxisExtent: 150,
shrinkWrap: true,
physics: ClampingScrollPhysics(), physics: ClampingScrollPhysics(),
shrinkWrap: true,
children: [ children: [
_grid([
_iconButton( _iconButton(
L10().scanBarcode, L10().scanBarcode,
FontAwesomeIcons.barcode, FontAwesomeIcons.barcode,
@ -241,19 +290,20 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
} }
), ),
_iconButton( _iconButton(
L10().parts, L10().search,
FontAwesomeIcons.shapes, FontAwesomeIcons.search,
callback: () { callback: () {
_parts(context); // TODO: Launch "generic" search widget
} }
), ),
_iconButton( _iconButton(
L10().searchParts, L10().parts,
FontAwesomeIcons.search, FontAwesomeIcons.shapes,
callback: () { callback: () {
_searchParts(); _showParts(context);
} }
), ),
// TODO - Re-add starred parts link // TODO - Re-add starred parts link
/* /*
Column( Column(
@ -261,46 +311,40 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
IconButton( IconButton(
icon: FaIcon(FontAwesomeIcons.solidStar), icon: FaIcon(FontAwesomeIcons.solidStar),
onPressed: () { onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => StarredPartWidget()));
}, },
), ),
Text("Starred Parts"), Text("Starred Parts"),
] ]
), ),
*/ */
_iconButton( _iconButton(
L10().stock, L10().stock,
FontAwesomeIcons.boxes, FontAwesomeIcons.boxes,
callback: () { callback: () {
_stock(context); _showStock(context);
}
),
_iconButton(
L10().searchStock,
FontAwesomeIcons.search,
callback: () {
_searchStock();
} }
), ),
_iconButton( _iconButton(
L10().purchaseOrders, L10().purchaseOrders,
FontAwesomeIcons.shoppingCart, FontAwesomeIcons.shoppingCart,
callback: () { callback: () {
// TODO _showPurchaseOrders(context);
} }
), ),
_iconButton( _iconButton(
L10().suppliers, L10().suppliers,
FontAwesomeIcons.building, FontAwesomeIcons.building,
callback: () { callback: () {
_suppliers(); _showSuppliers(context);
} }
), ),
_iconButton( _iconButton(
L10().manufacturers, L10().manufacturers,
FontAwesomeIcons.industry, FontAwesomeIcons.industry,
callback: () { callback: () {
// TODO _showManufacturers(context);
} }
), ),
/* /*
@ -357,6 +401,8 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
*/ */
], ],
) )
]
),
); );
} }
} }