mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 02:05:29 +00:00
User configurable home screen actions
This commit is contained in:
@ -19,9 +19,21 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
|
||||
final GlobalKey<_InvenTreeAppSettingsState> _settingsKey = GlobalKey<_InvenTreeAppSettingsState>();
|
||||
|
||||
// Home screen settings
|
||||
bool homeShowSubscribed = true;
|
||||
bool homeShowPo = true;
|
||||
bool homeShowSuppliers = true;
|
||||
bool homeShowManufacturers = true;
|
||||
bool homeShowCustomers = true;
|
||||
|
||||
// Sound settings
|
||||
bool barcodeSounds = true;
|
||||
bool serverSounds = true;
|
||||
|
||||
// Part settings
|
||||
bool partSubcategory = false;
|
||||
|
||||
// Stock settings
|
||||
bool stockSublocation = false;
|
||||
|
||||
@override
|
||||
@ -32,45 +44,21 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
}
|
||||
|
||||
Future <void> loadSettings() async {
|
||||
barcodeSounds = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool;
|
||||
serverSounds = await InvenTreeSettingsManager().getValue("serverSounds", true) as bool;
|
||||
|
||||
partSubcategory = await InvenTreeSettingsManager().getValue("partSubcategory", true) as bool;
|
||||
stockSublocation = await InvenTreeSettingsManager().getValue("stockSublocation", true) as bool;
|
||||
// Load initial settings
|
||||
|
||||
setState(() {
|
||||
});
|
||||
}
|
||||
homeShowSubscribed = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SUBSCRIBED, true) as bool;
|
||||
homeShowPo = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_PO, true) as bool;
|
||||
homeShowManufacturers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_MANUFACTURERS, true) as bool;
|
||||
homeShowCustomers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_CUSTOMERS, true) as bool;
|
||||
homeShowSuppliers = await InvenTreeSettingsManager().getValue(INV_HOME_SHOW_SUPPLIERS, true) as bool;
|
||||
|
||||
Future <void> setBarcodeSounds(bool en) async {
|
||||
barcodeSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_BARCODE, true) as bool;
|
||||
serverSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_SERVER, true) as bool;
|
||||
|
||||
await InvenTreeSettingsManager().setValue("barcodeSounds", en);
|
||||
barcodeSounds = await InvenTreeSettingsManager().getBool("barcodeSounds", true);
|
||||
partSubcategory = await InvenTreeSettingsManager().getValue(INV_PART_SUBCATEGORY, true) as bool;
|
||||
|
||||
setState(() {
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> setServerSounds(bool en) async {
|
||||
|
||||
await InvenTreeSettingsManager().setValue("serverSounds", en);
|
||||
serverSounds = await InvenTreeSettingsManager().getBool("serverSounds", true);
|
||||
|
||||
setState(() {
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> setPartSubcategory(bool en) async {
|
||||
await InvenTreeSettingsManager().setValue("partSubcategory", en);
|
||||
partSubcategory = await InvenTreeSettingsManager().getBool("partSubcategory", true);
|
||||
|
||||
setState(() {
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> setStockSublocation(bool en) async {
|
||||
await InvenTreeSettingsManager().setValue("stockSublocation", en);
|
||||
stockSublocation = await InvenTreeSettingsManager().getBool("stockSublocation", true);
|
||||
stockSublocation = await InvenTreeSettingsManager().getValue(INV_STOCK_SUBLOCATION, true) as bool;
|
||||
|
||||
setState(() {
|
||||
});
|
||||
@ -87,12 +75,90 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
/* Home Screen Settings */
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().homeScreen,
|
||||
style: TextStyle(fontWeight: FontWeight.bold)
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowSubscribed),
|
||||
subtitle: Text(L10().homeShowSubscribedDescription),
|
||||
leading: FaIcon(FontAwesomeIcons.bell),
|
||||
trailing: Switch(
|
||||
value: homeShowSubscribed,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SUBSCRIBED, value);
|
||||
setState(() {
|
||||
homeShowSubscribed = value;
|
||||
});
|
||||
},
|
||||
)
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowPo),
|
||||
subtitle: Text(L10().homeShowPoDescription),
|
||||
leading: FaIcon(FontAwesomeIcons.shoppingCart),
|
||||
trailing: Switch(
|
||||
value: homeShowPo,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_PO, value);
|
||||
setState(() {
|
||||
homeShowPo = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowSuppliers),
|
||||
subtitle: Text(L10().homeShowSuppliersDescription),
|
||||
leading: FaIcon(FontAwesomeIcons.building),
|
||||
trailing: Switch(
|
||||
value: homeShowSuppliers,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_SUPPLIERS, value);
|
||||
setState(() {
|
||||
homeShowSuppliers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowManufacturers),
|
||||
subtitle: Text(L10().homeShowManufacturersDescription),
|
||||
leading: FaIcon(FontAwesomeIcons.industry),
|
||||
trailing: Switch(
|
||||
value: homeShowManufacturers,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_MANUFACTURERS, value);
|
||||
setState(() {
|
||||
homeShowManufacturers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().homeShowCustomers),
|
||||
subtitle: Text(L10().homeShowCustomersDescription),
|
||||
leading: FaIcon(FontAwesomeIcons.userTie),
|
||||
trailing: Switch(
|
||||
value: homeShowCustomers,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_HOME_SHOW_CUSTOMERS, value);
|
||||
setState(() {
|
||||
homeShowCustomers = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
/* Part Settings */
|
||||
Divider(height: 3),
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10().parts,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: FaIcon(FontAwesomeIcons.shapes),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().includeSubcategories),
|
||||
@ -100,15 +166,20 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
leading: FaIcon(FontAwesomeIcons.sitemap),
|
||||
trailing: Switch(
|
||||
value: partSubcategory,
|
||||
onChanged: setPartSubcategory,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_PART_SUBCATEGORY, value);
|
||||
setState(() {
|
||||
partSubcategory = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
/* Stock Settings */
|
||||
Divider(height: 3),
|
||||
ListTile(
|
||||
title: Text(L10().stock,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: FaIcon(FontAwesomeIcons.boxes),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().includeSublocations),
|
||||
@ -116,9 +187,15 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
leading: FaIcon(FontAwesomeIcons.sitemap),
|
||||
trailing: Switch(
|
||||
value: stockSublocation,
|
||||
onChanged: setStockSublocation,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_STOCK_SUBLOCATION, value);
|
||||
setState(() {
|
||||
stockSublocation = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
/* Sound Settings */
|
||||
Divider(height: 3),
|
||||
ListTile(
|
||||
title: Text(
|
||||
@ -133,7 +210,12 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
leading: FaIcon(FontAwesomeIcons.server),
|
||||
trailing: Switch(
|
||||
value: serverSounds,
|
||||
onChanged: setServerSounds,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_SOUNDS_SERVER, value);
|
||||
setState(() {
|
||||
serverSounds = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
@ -142,7 +224,12 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
leading: Icon(Icons.qr_code),
|
||||
trailing: Switch(
|
||||
value: barcodeSounds,
|
||||
onChanged: setBarcodeSounds,
|
||||
onChanged: (bool value) {
|
||||
InvenTreeSettingsManager().setValue(INV_SOUNDS_BARCODE, value);
|
||||
setState(() {
|
||||
barcodeSounds = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Divider(height: 1),
|
||||
|
Reference in New Issue
Block a user