2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-29 14:06:47 +00:00

Refactor display for StockLocation

This commit is contained in:
Oliver Walters 2021-01-29 00:52:15 +11:00
parent c00e367ae5
commit 3433d57f83
2 changed files with 124 additions and 39 deletions

View File

@ -41,6 +41,16 @@ class BarcodeHandler {
Future<void> onBarcodeUnknown(Map<String, dynamic> data) { Future<void> onBarcodeUnknown(Map<String, dynamic> data) {
// Called when the server does not know about a barcode // Called when the server does not know about a barcode
// Override this function // Override this function
showErrorDialog(
_context,
"Invalid Barcode",
"Barcode does not match any known item",
error: "Barcode Error",
icon: FontAwesomeIcons.barcode,
onDismissed: () {
_controller.resumeCamera();
}
);
} }
Future<void> onBarcodeUnhandled(Map<String, dynamic> data) { Future<void> onBarcodeUnhandled(Map<String, dynamic> data) {

View File

@ -133,11 +133,87 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
} }
@override @override
Widget getBody(BuildContext context) { Widget getBottomNavBar(BuildContext context) {
return BottomNavigationBar(
currentIndex: tabIndex,
onTap: onTabSelectionChanged,
items: const <BottomNavigationBarItem> [
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.boxes),
title: Text("Stock"),
),
BottomNavigationBarItem(
icon: FaIcon(FontAwesomeIcons.wrench),
title: Text("Actions"),
)
]
);
}
return ListView( Widget getSelectedWidget(int index) {
children: <Widget> [ switch (index) {
locationDescriptionCard(), case 0:
return ListView(
children: detailTiles(),
);
case 1:
return ListView(
children: actionTiles(),
);
default:
return null;
}
}
@override
Widget getBody(BuildContext context) {
return getSelectedWidget(tabIndex);
}
List<Widget> detailTiles() {
List<Widget> tiles = [];
// Location description
tiles.add(locationDescriptionCard());
// Sublocation panel
ExpansionPanel sublocations = ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
title: Text("Sublocations"),
leading: FaIcon(FontAwesomeIcons.mapMarkerAlt),
trailing: Text("${_sublocations.length}"),
onTap: () {
setState(() {
InvenTreePreferences().expandLocationList = !InvenTreePreferences().expandLocationList;
});
},
);
},
body: SublocationList(_sublocations),
isExpanded: InvenTreePreferences().expandLocationList && _sublocations.length > 0,
);
ExpansionPanel subitems = ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
title: Text("Stock Items"),
leading: FaIcon(FontAwesomeIcons.boxes),
trailing: Text("${_items.length}"),
onTap: () {
setState(() {
InvenTreePreferences().expandStockList = !InvenTreePreferences().expandStockList;
});
},
);
},
body: StockList(_items),
isExpanded: InvenTreePreferences().expandStockList && _items.length > 0,
);
// Sublocations and items
tiles.add(
ExpansionPanelList( ExpansionPanelList(
expansionCallback: (int index, bool isExpanded) { expansionCallback: (int index, bool isExpanded) {
setState(() { setState(() {
@ -152,49 +228,48 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
break; break;
} }
}); });
}, },
children: <ExpansionPanel> [ children: <ExpansionPanel> [
ExpansionPanel( sublocations,
headerBuilder: (BuildContext context, bool isExpanded) { subitems,
return ListTile(
title: Text("Sublocations"),
leading: FaIcon(FontAwesomeIcons.mapMarkerAlt),
trailing: Text("${_sublocations.length}"),
onTap: () {
setState(() {
InvenTreePreferences().expandLocationList = !InvenTreePreferences().expandLocationList;
});
},
);
},
body: SublocationList(_sublocations),
isExpanded: InvenTreePreferences().expandLocationList && _sublocations.length > 0,
),
ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
title: Text("Stock Items"),
leading: FaIcon(FontAwesomeIcons.boxes),
trailing: Text("${_items.length}"),
onTap: () {
setState(() {
InvenTreePreferences().expandStockList = !InvenTreePreferences().expandStockList;
});
},
);
},
body: StockList(_items),
isExpanded: InvenTreePreferences().expandStockList && _items.length > 0,
)
] ]
), )
]
); );
return tiles;
} }
List<Widget> actionTiles() {
List<Widget> tiles = [];
tiles.add(locationDescriptionCard());
// Scan items into location
tiles.add(
ListTile(
title: Text("Scan in Stock Item"),
leading: FaIcon(FontAwesomeIcons.exchangeAlt),
trailing: FaIcon(FontAwesomeIcons.qrcode),
onTap: null,
)
);
// Move location into another location
tiles.add(
ListTile(
title: Text("Move Stock Location"),
leading: FaIcon(FontAwesomeIcons.sitemap),
trailing: FaIcon(FontAwesomeIcons.qrcode),
)
);
return tiles;
}
} }
class SublocationList extends StatelessWidget { class SublocationList extends StatelessWidget {
final List<InvenTreeStockLocation> _locations; final List<InvenTreeStockLocation> _locations;