-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add language dropdown in speech modal
- Loading branch information
Showing
7 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
lib/features/speech/ui/widgets/speech_modal/language_dropdown.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:lotti/classes/journal_entities.dart'; | ||
import 'package:lotti/features/journal/state/entry_controller.dart'; | ||
import 'package:lotti/l10n/app_localizations_context.dart'; | ||
import 'package:lotti/themes/theme.dart'; | ||
|
||
class LanguageDropdown extends ConsumerWidget { | ||
const LanguageDropdown({ | ||
required this.entryId, | ||
super.key, | ||
}); | ||
|
||
final String entryId; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final provider = entryControllerProvider(id: entryId); | ||
final notifier = ref.read(provider.notifier); | ||
final entryState = ref.watch(provider).value; | ||
final item = entryState?.entry; | ||
|
||
if (item == null || item is! JournalAudio) { | ||
return const SizedBox.shrink(); | ||
} | ||
|
||
return Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Text(context.messages.speechModalSelectLanguage), | ||
const SizedBox(width: 10), | ||
DropdownButton( | ||
value: item.data.language, | ||
iconEnabledColor: context.colorScheme.outline, | ||
items: const [ | ||
DropdownMenuItem( | ||
value: '', | ||
child: Text('auto'), | ||
), | ||
DropdownMenuItem( | ||
value: 'en', | ||
child: Text('English'), | ||
), | ||
DropdownMenuItem( | ||
value: 'de', | ||
child: Text('Deutsch'), | ||
), | ||
], | ||
onChanged: (String? value) { | ||
if (value != null) { | ||
notifier.setLanguage(value); | ||
} | ||
}, | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters