mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Refactor display for StockLocation
This commit is contained in:
parent
c00e367ae5
commit
3433d57f83
@ -41,6 +41,16 @@ class BarcodeHandler {
|
||||
Future<void> onBarcodeUnknown(Map<String, dynamic> data) {
|
||||
// Called when the server does not know about a barcode
|
||||
// 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) {
|
||||
|
@ -133,11 +133,87 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
}
|
||||
|
||||
@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(
|
||||
children: <Widget> [
|
||||
locationDescriptionCard(),
|
||||
Widget getSelectedWidget(int index) {
|
||||
switch (index) {
|
||||
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(
|
||||
expansionCallback: (int index, bool isExpanded) {
|
||||
setState(() {
|
||||
@ -152,49 +228,48 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
children: <ExpansionPanel> [
|
||||
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(
|
||||
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,
|
||||
subitems,
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
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 {
|
||||
final List<InvenTreeStockLocation> _locations;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user