mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 18:25:26 +00:00
Add settings to control sounds
This commit is contained in:
@ -5,6 +5,8 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
import 'package:InvenTree/app_settings.dart';
|
||||
|
||||
class InvenTreeAppSettingsWidget extends StatefulWidget {
|
||||
@override
|
||||
_InvenTreeAppSettingsState createState() => _InvenTreeAppSettingsState();
|
||||
@ -15,10 +17,43 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
final GlobalKey<_InvenTreeAppSettingsState> _settingsKey = GlobalKey<_InvenTreeAppSettingsState>();
|
||||
|
||||
_InvenTreeAppSettingsState() {
|
||||
|
||||
}
|
||||
|
||||
bool a = false;
|
||||
bool barcodeSounds = true;
|
||||
bool serverSounds = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
void loadSettings() async {
|
||||
barcodeSounds = await InvenTreeSettingsManager().getValue("barcodeSounds", true) as bool;
|
||||
serverSounds = await InvenTreeSettingsManager().getValue("serverSounds", true) as bool;
|
||||
|
||||
setState(() {
|
||||
});
|
||||
}
|
||||
|
||||
void setBarcodeSounds(bool en) async {
|
||||
|
||||
await InvenTreeSettingsManager().setValue("barcodeSounds", en);
|
||||
barcodeSounds = await InvenTreeSettingsManager().getValue("barcodeSounds", true);
|
||||
|
||||
setState(() {
|
||||
});
|
||||
}
|
||||
|
||||
void setServerSounds(bool en) async {
|
||||
|
||||
await InvenTreeSettingsManager().setValue("serverSounds", en);
|
||||
serverSounds = await InvenTreeSettingsManager().getValue("serverSounds", true);
|
||||
|
||||
setState(() {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -33,35 +68,27 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
"Sounds",
|
||||
I18N.of(context).sounds,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: FaIcon(FontAwesomeIcons.volumeUp),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Server Error"),
|
||||
title: Text(I18N.of(context).serverError),
|
||||
subtitle: Text("Play audible tone on server error"),
|
||||
leading: FaIcon(FontAwesomeIcons.server),
|
||||
trailing: Switch(
|
||||
value: false,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
// TODO
|
||||
});
|
||||
},
|
||||
value: serverSounds,
|
||||
onChanged: setServerSounds,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Barcode Tones"),
|
||||
title: Text(I18N.of(context).barcodeTones),
|
||||
subtitle: Text("Play audible tones for barcode actions"),
|
||||
leading: FaIcon(FontAwesomeIcons.qrcode),
|
||||
trailing: Switch(
|
||||
value: a,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
a = value;
|
||||
});
|
||||
},
|
||||
value: barcodeSounds,
|
||||
onChanged: setBarcodeSounds,
|
||||
),
|
||||
),
|
||||
Divider(height: 1),
|
||||
|
Reference in New Issue
Block a user