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:
parent
c00e367ae5
commit
3433d57f83
@ -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) {
|
||||||
|
@ -133,29 +133,52 @@ 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> [
|
|
||||||
locationDescriptionCard(),
|
|
||||||
ExpansionPanelList(
|
|
||||||
expansionCallback: (int index, bool isExpanded) {
|
|
||||||
setState(() {
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
InvenTreePreferences().expandLocationList = !isExpanded;
|
return ListView(
|
||||||
break;
|
children: detailTiles(),
|
||||||
|
);
|
||||||
case 1:
|
case 1:
|
||||||
InvenTreePreferences().expandStockList = !isExpanded;
|
return ListView(
|
||||||
break;
|
children: actionTiles(),
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
break;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
},
|
@override
|
||||||
children: <ExpansionPanel> [
|
Widget getBody(BuildContext context) {
|
||||||
ExpansionPanel(
|
return getSelectedWidget(tabIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<Widget> detailTiles() {
|
||||||
|
List<Widget> tiles = [];
|
||||||
|
|
||||||
|
// Location description
|
||||||
|
tiles.add(locationDescriptionCard());
|
||||||
|
|
||||||
|
// Sublocation panel
|
||||||
|
ExpansionPanel sublocations = ExpansionPanel(
|
||||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("Sublocations"),
|
title: Text("Sublocations"),
|
||||||
@ -170,8 +193,9 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
},
|
},
|
||||||
body: SublocationList(_sublocations),
|
body: SublocationList(_sublocations),
|
||||||
isExpanded: InvenTreePreferences().expandLocationList && _sublocations.length > 0,
|
isExpanded: InvenTreePreferences().expandLocationList && _sublocations.length > 0,
|
||||||
),
|
);
|
||||||
ExpansionPanel(
|
|
||||||
|
ExpansionPanel subitems = ExpansionPanel(
|
||||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("Stock Items"),
|
title: Text("Stock Items"),
|
||||||
@ -186,14 +210,65 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
},
|
},
|
||||||
body: StockList(_items),
|
body: StockList(_items),
|
||||||
isExpanded: InvenTreePreferences().expandStockList && _items.length > 0,
|
isExpanded: InvenTreePreferences().expandStockList && _items.length > 0,
|
||||||
)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Sublocations and items
|
||||||
|
tiles.add(
|
||||||
|
ExpansionPanelList(
|
||||||
|
expansionCallback: (int index, bool isExpanded) {
|
||||||
|
setState(() {
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
InvenTreePreferences().expandLocationList = !isExpanded;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
InvenTreePreferences().expandStockList = !isExpanded;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
children: <ExpansionPanel> [
|
||||||
|
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 {
|
class SublocationList extends StatelessWidget {
|
||||||
final List<InvenTreeStockLocation> _locations;
|
final List<InvenTreeStockLocation> _locations;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user