more cleanup and small fixes, new sound effects

This commit is contained in:
Rene Kievits
2025-11-01 07:50:21 +01:00
parent d5ff5eb12f
commit e9f115a32a
9 changed files with 140 additions and 41 deletions

View File

@@ -15,8 +15,9 @@ class SettingsScreen extends StatefulWidget {
class _SettingsScreenState extends State<SettingsScreen> {
final TextEditingController _apiKeyController = TextEditingController();
bool _playAudio = true;
bool _playIncorrectSound = true;
bool _playCorrectSound = true;
bool _playNarrator = true;
@override
void dispose() {
@@ -39,8 +40,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
Future<void> _loadSettings() async {
final prefs = await SharedPreferences.getInstance();
setState(() {
_playAudio = prefs.getBool('playAudio') ?? true;
_playIncorrectSound = prefs.getBool('playIncorrectSound') ?? true;
_playCorrectSound = prefs.getBool('playCorrectSound') ?? true;
_playNarrator = prefs.getBool('playNarrator') ?? true;
});
}
@@ -108,17 +110,17 @@ class _SettingsScreenState extends State<SettingsScreen> {
const SizedBox(height: 24),
SwitchListTile(
title: Text(
'Play audio for vocabulary',
'Play incorrect sound',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
value: _playAudio,
value: _playIncorrectSound,
onChanged: (value) async {
final prefs = await SharedPreferences.getInstance();
prefs.setBool('playAudio', value);
prefs.setBool('playIncorrectSound', value);
setState(() {
_playAudio = value;
_playIncorrectSound = value;
});
},
activeThumbColor: Theme.of(context).colorScheme.primary,
@@ -133,7 +135,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
const SizedBox(height: 12),
SwitchListTile(
title: Text(
'Play sound on correct answer',
'Play correct sound',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
@@ -156,6 +158,31 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
),
const SizedBox(height: 12),
SwitchListTile(
title: Text(
'Play narrator (TTS)',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
value: _playNarrator,
onChanged: (value) async {
final prefs = await SharedPreferences.getInstance();
prefs.setBool('playNarrator', value);
setState(() {
_playNarrator = value;
});
},
activeThumbColor: Theme.of(context).colorScheme.primary,
inactiveThumbColor: Theme.of(
context,
).colorScheme.onSurfaceVariant,
tileColor: Theme.of(context).colorScheme.surfaceContainer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
),
const SizedBox(height: 12),
ListTile(
title: Text(
'Theme',