mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-30 21:05:42 +00:00 
			
		
		
		
	Remove reliance on shared preferences
This commit is contained in:
		
							
								
								
									
										2
									
								
								lib/l10n
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								lib/l10n
									
									
									
									
									
								
							 Submodule lib/l10n updated: ed3bd59b15...6e095a0d6c
									
								
							| @@ -1,13 +1,9 @@ | |||||||
| import 'package:flutter/cupertino.dart'; |  | ||||||
| import 'package:shared_preferences/shared_preferences.dart'; |  | ||||||
| import 'api.dart'; |  | ||||||
| import 'package:path_provider/path_provider.dart'; | import 'package:path_provider/path_provider.dart'; | ||||||
| import 'package:sembast/sembast.dart'; | import 'package:sembast/sembast.dart'; | ||||||
| import 'package:sembast/sembast_io.dart'; | import 'package:sembast/sembast_io.dart'; | ||||||
| import 'package:path/path.dart'; | import 'package:path/path.dart'; | ||||||
| import 'dart:async'; | import 'dart:async'; | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Class for storing InvenTree preferences in a NoSql DB |  * Class for storing InvenTree preferences in a NoSql DB | ||||||
|  */ |  */ | ||||||
|   | |||||||
| @@ -7,7 +7,6 @@ import 'package:InvenTree/preferences.dart'; | |||||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
| import 'package:flutter/services.dart'; | import 'package:flutter/services.dart'; | ||||||
| import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | ||||||
| import 'package:shared_preferences/shared_preferences.dart'; |  | ||||||
|  |  | ||||||
| import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||||||
|  |  | ||||||
| @@ -70,8 +69,6 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> { | |||||||
|  |  | ||||||
|   void _editServerSettings() async { |   void _editServerSettings() async { | ||||||
|  |  | ||||||
|     var prefs = await SharedPreferences.getInstance(); |  | ||||||
|  |  | ||||||
|     List<UserProfile> profiles = await UserProfileDBManager().getAllProfiles(); |     List<UserProfile> profiles = await UserProfileDBManager().getAllProfiles(); | ||||||
|  |  | ||||||
|     Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget())); |     Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget())); | ||||||
|   | |||||||
| @@ -147,8 +147,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> { | |||||||
|     if (category == null) { |     if (category == null) { | ||||||
|       return Card( |       return Card( | ||||||
|         child: ListTile( |         child: ListTile( | ||||||
|           title: Text(I18N.of(context).partCategories), |           title: Text("Top level part category"), | ||||||
|           subtitle: Text("Top level part category"), |  | ||||||
|         ) |         ) | ||||||
|       ); |       ); | ||||||
|     } else { |     } else { | ||||||
| @@ -183,70 +182,84 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Widget getBody(BuildContext context) { |   Widget getBottomNavBar(BuildContext context) { | ||||||
|     return ListView( |     return BottomNavigationBar( | ||||||
|       children: <Widget>[ |       currentIndex: tabIndex, | ||||||
|         getCategoryDescriptionCard(), |       onTap: onTabSelectionChanged, | ||||||
|         ExpansionPanelList( |       items: <BottomNavigationBarItem>[ | ||||||
|           expansionCallback: (int index, bool isExpanded) { |         BottomNavigationBarItem( | ||||||
|             setState(() { |           icon: FaIcon(FontAwesomeIcons.sitemap), | ||||||
|  |           label: I18N.of(context).details, | ||||||
|               switch (index) { |         ), | ||||||
|                 case 0: |         BottomNavigationBarItem( | ||||||
|                   InvenTreePreferences().expandCategoryList = !isExpanded; |           icon: FaIcon(FontAwesomeIcons.shapes), | ||||||
|                   break; |           label: I18N.of(context).parts, | ||||||
|                 case 1: |         ), | ||||||
|                   InvenTreePreferences().expandPartList = !isExpanded; |         BottomNavigationBarItem( | ||||||
|                   break; |           icon: FaIcon(FontAwesomeIcons.wrench), | ||||||
|                 default: |           label: I18N.of(context).actions | ||||||
|                   break; |  | ||||||
|               } |  | ||||||
|             }); |  | ||||||
|           }, |  | ||||||
|           children: <ExpansionPanel> [ |  | ||||||
|             ExpansionPanel( |  | ||||||
|               headerBuilder: (BuildContext context, bool isExpanded) { |  | ||||||
|                 return ListTile( |  | ||||||
|                   title: Text(I18N.of(context).subcategories), |  | ||||||
|                   leading: FaIcon(FontAwesomeIcons.stream), |  | ||||||
|                   trailing: Text("${_subcategories.length}"), |  | ||||||
|                   onTap: () { |  | ||||||
|                     setState(() { |  | ||||||
|                       InvenTreePreferences().expandCategoryList = !InvenTreePreferences().expandCategoryList; |  | ||||||
|                     }); |  | ||||||
|                   }, |  | ||||||
|                   onLongPress: () { |  | ||||||
|                     // TODO - Context menu for e.g. creating a new PartCategory |  | ||||||
|                   }, |  | ||||||
|                 ); |  | ||||||
|               }, |  | ||||||
|               body: SubcategoryList(_subcategories), |  | ||||||
|               isExpanded: InvenTreePreferences().expandCategoryList && _subcategories.length > 0, |  | ||||||
|             ), |  | ||||||
|             ExpansionPanel( |  | ||||||
|               headerBuilder: (BuildContext context, bool isExpanded) { |  | ||||||
|                 return ListTile( |  | ||||||
|                   title: Text(I18N.of(context).parts), |  | ||||||
|                   leading: FaIcon(FontAwesomeIcons.shapes), |  | ||||||
|                   trailing: Text("${_parts.length}"), |  | ||||||
|                   onTap: () { |  | ||||||
|                     setState(() { |  | ||||||
|                       InvenTreePreferences().expandPartList = !InvenTreePreferences().expandPartList; |  | ||||||
|                     }); |  | ||||||
|                   }, |  | ||||||
|                   onLongPress: () { |  | ||||||
|                     // TODO - Context menu for e.g. creating a new Part |  | ||||||
|                   }, |  | ||||||
|                 ); |  | ||||||
|               }, |  | ||||||
|               body: PartList(_parts), |  | ||||||
|               isExpanded: InvenTreePreferences().expandPartList && _parts.length > 0, |  | ||||||
|             ) |  | ||||||
|           ], |  | ||||||
|         ), |         ), | ||||||
|       ] |       ] | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   List<Widget> detailTiles() { | ||||||
|  |     return <Widget>[ | ||||||
|  |       getCategoryDescriptionCard(), | ||||||
|  |       Divider(), | ||||||
|  |       ListTile( | ||||||
|  |         title: Text( | ||||||
|  |           I18N.of(context).subcategories, | ||||||
|  |           style: TextStyle(fontWeight: FontWeight.bold) | ||||||
|  |         ) | ||||||
|  |       ), | ||||||
|  |       SubcategoryList(_subcategories), | ||||||
|  |     ]; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   List<Widget> partTiles() { | ||||||
|  |     return <Widget>[ | ||||||
|  |       getCategoryDescriptionCard(), | ||||||
|  |       Divider(), | ||||||
|  |       ListTile( | ||||||
|  |         title: Text( | ||||||
|  |           I18N.of(context).parts, | ||||||
|  |           style: TextStyle(fontWeight: FontWeight.bold) | ||||||
|  |         ) | ||||||
|  |       ), | ||||||
|  |       PartList(_parts) | ||||||
|  |     ]; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   List<Widget> actionTiles() { | ||||||
|  |  | ||||||
|  |     List<Widget> tiles = [ | ||||||
|  |       getCategoryDescriptionCard() | ||||||
|  |     ]; | ||||||
|  |  | ||||||
|  |     // TODO - Actions! | ||||||
|  |  | ||||||
|  |     return tiles; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   @override | ||||||
|  |   Widget getBody(BuildContext context) { | ||||||
|  |  | ||||||
|  |     switch (tabIndex) { | ||||||
|  |       case 0: | ||||||
|  |         return ListView( | ||||||
|  |           children: detailTiles() | ||||||
|  |         ); | ||||||
|  |       case 1: | ||||||
|  |         return ListView( | ||||||
|  |           children: partTiles() | ||||||
|  |         ); | ||||||
|  |       case 2: | ||||||
|  |         return ListView( | ||||||
|  |           children: actionTiles() | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -149,9 +149,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> { | |||||||
|     if (location == null) { |     if (location == null) { | ||||||
|       return Card( |       return Card( | ||||||
|         child: ListTile( |         child: ListTile( | ||||||
|           title: Text(I18N.of(context).stockLocations), |           title: Text(I18N.of(context).stockTopLevel), | ||||||
|           subtitle: Text(I18N.of(context).stockTopLevel), |  | ||||||
|           leading: FaIcon(FontAwesomeIcons.levelUpAlt), |  | ||||||
|         ) |         ) | ||||||
|       ); |       ); | ||||||
|     } else { |     } else { | ||||||
| @@ -190,13 +188,17 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> { | |||||||
|         currentIndex: tabIndex, |         currentIndex: tabIndex, | ||||||
|         onTap: onTabSelectionChanged, |         onTap: onTabSelectionChanged, | ||||||
|         items: <BottomNavigationBarItem> [ |         items: <BottomNavigationBarItem> [ | ||||||
|  |           BottomNavigationBarItem( | ||||||
|  |             icon: FaIcon(FontAwesomeIcons.sitemap), | ||||||
|  |             label: I18N.of(context).details, | ||||||
|  |           ), | ||||||
|           BottomNavigationBarItem( |           BottomNavigationBarItem( | ||||||
|             icon: FaIcon(FontAwesomeIcons.boxes), |             icon: FaIcon(FontAwesomeIcons.boxes), | ||||||
|             title: Text(I18N.of(context).stock), |             label: I18N.of(context).stock, | ||||||
|           ), |           ), | ||||||
|           BottomNavigationBarItem( |           BottomNavigationBarItem( | ||||||
|             icon: FaIcon(FontAwesomeIcons.wrench), |             icon: FaIcon(FontAwesomeIcons.wrench), | ||||||
|             title: Text(I18N.of(context).actions), |             label: I18N.of(context).actions, | ||||||
|           ) |           ) | ||||||
|         ] |         ] | ||||||
|     ); |     ); | ||||||
| @@ -208,6 +210,10 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> { | |||||||
|         return ListView( |         return ListView( | ||||||
|           children: detailTiles(), |           children: detailTiles(), | ||||||
|         ); |         ); | ||||||
|  |       case 1: | ||||||
|  |         return ListView( | ||||||
|  |           children: stockTiles(), | ||||||
|  |         ); | ||||||
|       case 1: |       case 1: | ||||||
|         return ListView( |         return ListView( | ||||||
|           children: ListTile.divideTiles( |           children: ListTile.divideTiles( | ||||||
| @@ -227,73 +233,39 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> { | |||||||
|  |  | ||||||
|  |  | ||||||
| List<Widget> detailTiles() { | List<Widget> detailTiles() { | ||||||
|     List<Widget> tiles = []; |     List<Widget> tiles = [ | ||||||
|  |       locationDescriptionCard(), | ||||||
|     // Location description |       Divider(), | ||||||
|     tiles.add(locationDescriptionCard()); |       ListTile( | ||||||
|  |         title: Text( | ||||||
|     // Sublocation panel |           I18N.of(context).sublocations, | ||||||
|     ExpansionPanel sublocations = ExpansionPanel( |           style: TextStyle(fontWeight: FontWeight.bold) | ||||||
|       headerBuilder: (BuildContext context, bool isExpanded) { |         ), | ||||||
|         return ListTile( |       ), | ||||||
|           title: Text("Sublocations"), |       SublocationList(_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(() { |  | ||||||
|               switch (index) { |  | ||||||
|                 case 0: |  | ||||||
|                   InvenTreePreferences().expandLocationList = !isExpanded; |  | ||||||
|                   break; |  | ||||||
|                 case 1: |  | ||||||
|                   InvenTreePreferences().expandStockList = !isExpanded; |  | ||||||
|                   break; |  | ||||||
|                 default: |  | ||||||
|                   break; |  | ||||||
|               } |  | ||||||
|             }); |  | ||||||
|           }, |  | ||||||
|           children: <ExpansionPanel> [ |  | ||||||
|             sublocations, |  | ||||||
|             subitems, |  | ||||||
|           ] |  | ||||||
|       ) |  | ||||||
|     ); |  | ||||||
|  |  | ||||||
|     return tiles; |     return tiles; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |   List<Widget> stockTiles() { | ||||||
|  |     List<Widget> tiles = [ | ||||||
|  |       locationDescriptionCard(), | ||||||
|  |       Divider(), | ||||||
|  |       ListTile( | ||||||
|  |         title: Text( | ||||||
|  |             I18N.of(context).stockItems, | ||||||
|  |             style: TextStyle(fontWeight: FontWeight.bold) | ||||||
|  |         ) | ||||||
|  |       ), | ||||||
|  |       StockList(_items), | ||||||
|  |     ]; | ||||||
|  |  | ||||||
|  |     return tiles; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|   List<Widget> actionTiles() { |   List<Widget> actionTiles() { | ||||||
|     List<Widget> tiles = []; |     List<Widget> tiles = []; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -27,8 +27,6 @@ dependencies: | |||||||
|  |  | ||||||
|   cupertino_icons: ^0.1.3 |   cupertino_icons: ^0.1.3 | ||||||
|   http: ^0.12.1 |   http: ^0.12.1 | ||||||
|   shared_preferences: ^0.5.7 |  | ||||||
|  |  | ||||||
|   cached_network_image: ^2.5.0 |   cached_network_image: ^2.5.0 | ||||||
|   qr_code_scanner: ^0.0.13 |   qr_code_scanner: ^0.0.13 | ||||||
|   package_info: ^0.4.0                    # App information introspection |   package_info: ^0.4.0                    # App information introspection | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user