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

@@ -868,8 +868,9 @@ class _BrowseScreenState extends State<BrowseScreen>
class _VocabDetailsDialog extends StatefulWidget {
final VocabularyItem vocab;
final ThemeData theme;
const _VocabDetailsDialog({required this.vocab});
const _VocabDetailsDialog({required this.vocab, required this.theme});
@override
State<_VocabDetailsDialog> createState() => _VocabDetailsDialogState();
@@ -881,10 +882,10 @@ class _VocabDetailsDialogState extends State<_VocabDetailsDialog> {
@override
void initState() {
super.initState();
_fetchExampleSentences(context);
_fetchExampleSentences();
}
Future<void> _fetchExampleSentences(BuildContext context) async {
Future<void> _fetchExampleSentences() async {
try {
final uri = Uri.parse(
'https://jisho.org/api/v1/search/words?keyword=${Uri.encodeComponent(widget.vocab.characters)}',
@@ -911,11 +912,11 @@ class _VocabDetailsDialogState extends State<_VocabDetailsDialog> {
children: [
Text(
japaneseWord,
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
style: TextStyle(color: widget.theme.colorScheme.onSurface),
),
Text(
englishDefinition,
style: TextStyle(color: Theme.of(context).colorScheme.onSurfaceVariant),
style: TextStyle(color: widget.theme.colorScheme.onSurfaceVariant),
),
const SizedBox(height: 8),
],
@@ -929,7 +930,7 @@ class _VocabDetailsDialogState extends State<_VocabDetailsDialog> {
sentences.add(
Text(
'No example sentences found.',
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
style: TextStyle(color: widget.theme.colorScheme.onSurface),
),
);
}
@@ -944,7 +945,7 @@ class _VocabDetailsDialogState extends State<_VocabDetailsDialog> {
_exampleSentences = [
Text(
'Failed to load example sentences.',
style: TextStyle(color: Theme.of(context).colorScheme.error),
style: TextStyle(color: widget.theme.colorScheme.error),
),
];
});
@@ -956,7 +957,7 @@ class _VocabDetailsDialogState extends State<_VocabDetailsDialog> {
_exampleSentences = [
Text(
'Error loading example sentences.',
style: TextStyle(color: Theme.of(context).colorScheme.error),
style: TextStyle(color: widget.theme.colorScheme.error),
),
];
});
@@ -992,39 +993,39 @@ class _VocabDetailsDialogState extends State<_VocabDetailsDialog> {
children: [
Text(
'Level: ${widget.vocab.level}',
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
style: TextStyle(color: widget.theme.colorScheme.onSurface),
),
const SizedBox(height: 16),
if (widget.vocab.meanings.isNotEmpty)
Text(
'Meanings: ${widget.vocab.meanings.join(', ')}',
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
style: TextStyle(color: widget.theme.colorScheme.onSurface),
),
const SizedBox(height: 16),
if (widget.vocab.readings.isNotEmpty)
Text(
'Readings: ${widget.vocab.readings.join(', ')}',
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
style: TextStyle(color: widget.theme.colorScheme.onSurface),
),
const SizedBox(height: 16),
Divider(color: Theme.of(context).colorScheme.onSurfaceVariant),
Divider(color: widget.theme.colorScheme.onSurfaceVariant),
const SizedBox(height: 16),
Text(
'SRS Scores:',
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold),
style: TextStyle(color: widget.theme.colorScheme.onSurface, fontWeight: FontWeight.bold),
),
...srsScores.entries.map(
(entry) => Text(
' ${entry.key}: ${entry.value}',
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
style: TextStyle(color: widget.theme.colorScheme.onSurface),
),
),
const SizedBox(height: 16),
Divider(color: Theme.of(context).colorScheme.onSurfaceVariant),
Divider(color: widget.theme.colorScheme.onSurfaceVariant),
const SizedBox(height: 16),
Text(
'Example Sentences:',
style: TextStyle(color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold),
style: TextStyle(color: widget.theme.colorScheme.onSurface, fontWeight: FontWeight.bold),
),
..._exampleSentences,
],
@@ -1034,22 +1035,23 @@ class _VocabDetailsDialogState extends State<_VocabDetailsDialog> {
}
void _showVocabDetailsDialog(BuildContext context, VocabularyItem vocab) {
final currentTheme = Theme.of(context);
showDialog(
context: context,
builder: (dialogContext) {
return AlertDialog(
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
backgroundColor: currentTheme.colorScheme.surfaceContainer,
title: Text(
'Details for ${vocab.characters}',
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
style: TextStyle(color: currentTheme.colorScheme.onSurface),
),
content: _VocabDetailsDialog(vocab: vocab),
content: _VocabDetailsDialog(vocab: vocab, theme: currentTheme),
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(),
child: Text(
'Close',
style: TextStyle(color: Theme.of(context).colorScheme.primary),
style: TextStyle(color: currentTheme.colorScheme.primary),
),
),
],