mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-30 21:05:42 +00:00 
			
		
		
		
	Refactor display for StockLocation
This commit is contained in:
		| @@ -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,29 +133,52 @@ 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(), | ||||
|         ExpansionPanelList( | ||||
|           expansionCallback: (int index, bool isExpanded) { | ||||
|             setState(() { | ||||
|   Widget getSelectedWidget(int index) { | ||||
|     switch (index) { | ||||
|       case 0: | ||||
|                   InvenTreePreferences().expandLocationList = !isExpanded; | ||||
|                   break; | ||||
|         return ListView( | ||||
|           children: detailTiles(), | ||||
|         ); | ||||
|       case 1: | ||||
|                   InvenTreePreferences().expandStockList = !isExpanded; | ||||
|                   break; | ||||
|         return ListView( | ||||
|           children: actionTiles(), | ||||
|         ); | ||||
|       default: | ||||
|                   break; | ||||
|         return null; | ||||
|     } | ||||
|   } | ||||
|             }); | ||||
|  | ||||
|           }, | ||||
|           children: <ExpansionPanel> [ | ||||
|             ExpansionPanel( | ||||
|   @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"), | ||||
| @@ -170,8 +193,9 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> { | ||||
|       }, | ||||
|       body: SublocationList(_sublocations), | ||||
|       isExpanded: InvenTreePreferences().expandLocationList && _sublocations.length > 0, | ||||
|             ), | ||||
|             ExpansionPanel( | ||||
|     ); | ||||
|  | ||||
|     ExpansionPanel subitems = ExpansionPanel( | ||||
|       headerBuilder: (BuildContext context, bool isExpanded) { | ||||
|         return ListTile( | ||||
|           title: Text("Stock Items"), | ||||
| @@ -186,15 +210,66 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> { | ||||
|       }, | ||||
|       body: StockList(_items), | ||||
|       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 { | ||||
|   final List<InvenTreeStockLocation> _locations; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user