more cleanup and small fixes, new sound effects
This commit is contained in:
@@ -45,8 +45,9 @@ class _VocabScreenState extends State<VocabScreen>
|
||||
final _quizStates = [_QuizState(), _QuizState(), _QuizState()];
|
||||
_QuizState get _currentQuizState => _quizStates[_tabController.index];
|
||||
|
||||
bool _playAudio = true;
|
||||
bool _playIncorrectSound = true;
|
||||
bool _playCorrectSound = true;
|
||||
bool _playNarrator = true;
|
||||
bool _apiKeyMissing = false;
|
||||
|
||||
@override
|
||||
@@ -72,8 +73,9 @@ class _VocabScreenState extends State<VocabScreen>
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -222,7 +224,7 @@ class _VocabScreenState extends State<VocabScreen>
|
||||
final current = _currentQuizState.current;
|
||||
if (current == null || current.pronunciationAudios.isEmpty) return;
|
||||
|
||||
if (playOnLoad && !_playAudio) return;
|
||||
if (playOnLoad && !_playNarrator) return;
|
||||
|
||||
final maleAudios = current.pronunciationAudios.where(
|
||||
(a) => a.gender == 'male',
|
||||
@@ -263,6 +265,9 @@ class _VocabScreenState extends State<VocabScreen>
|
||||
srsItem.srsStage += 1;
|
||||
} else {
|
||||
srsItem.srsStage = max(0, srsItem.srsStage - 1);
|
||||
if (_playIncorrectSound) {
|
||||
await _audioPlayer.play(AssetSource('sfx/incorrect.wav'));
|
||||
}
|
||||
}
|
||||
srsItem.lastAsked = DateTime.now();
|
||||
current.srsItems[srsKey] = srsItem;
|
||||
@@ -294,10 +299,9 @@ class _VocabScreenState extends State<VocabScreen>
|
||||
ScaffoldMessenger.of(context).showSnackBar(snack);
|
||||
|
||||
if (isCorrect) {
|
||||
if (_playCorrectSound) {
|
||||
await _audioPlayer.play(AssetSource('sfx/confirm.mp3'));
|
||||
}
|
||||
if (_playAudio) {
|
||||
if (_playCorrectSound && !_playNarrator) {
|
||||
await _audioPlayer.play(AssetSource('sfx/correct.wav'));
|
||||
} else if (_playNarrator) {
|
||||
final maleAudios = current.pronunciationAudios.where(
|
||||
(a) => a.gender == 'male',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user