chore: add default names to course filters (#3845)
This commit is contained in:
parent
cb3f4d191c
commit
72da5beeec
3 changed files with 25 additions and 12 deletions
|
|
@ -5264,5 +5264,6 @@
|
|||
"waitNotDone": "Wait I’m not done!",
|
||||
"waitingForOthersToFinish": "Waiting for the rest to finish up...",
|
||||
"saveToCompletedActivities": "Save to completed activities",
|
||||
"generatingSummary": "Analyzing chat and generating results"
|
||||
"generatingSummary": "Analyzing chat and generating results",
|
||||
"instructionsLanguage": "Instructions language"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ class CoursePlanFilter<T> extends StatefulWidget {
|
|||
final List<T> items;
|
||||
|
||||
final void Function(T?) onChanged;
|
||||
final String Function(T?) displayname;
|
||||
final String defaultName;
|
||||
final String? shortName;
|
||||
final String Function(T) displayname;
|
||||
|
||||
final bool enableSearch;
|
||||
|
||||
|
|
@ -21,10 +23,12 @@ class CoursePlanFilter<T> extends StatefulWidget {
|
|||
required this.value,
|
||||
required this.items,
|
||||
required this.onChanged,
|
||||
required this.defaultName,
|
||||
required this.displayname,
|
||||
required this.fontSize,
|
||||
required this.iconSize,
|
||||
this.enableSearch = false,
|
||||
this.shortName,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -59,7 +63,9 @@ class CoursePlanFilterState<T> extends State<CoursePlanFilter<T>> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
widget.displayname(widget.value),
|
||||
widget.value != null
|
||||
? widget.displayname(widget.value as T)
|
||||
: widget.defaultName,
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: widget.fontSize,
|
||||
|
|
@ -79,7 +85,9 @@ class CoursePlanFilterState<T> extends State<CoursePlanFilter<T>> {
|
|||
(item) => DropdownMenuItem(
|
||||
value: item,
|
||||
child: DropdownTextButton(
|
||||
text: item == null ? "" : widget.displayname(item),
|
||||
text: item != null
|
||||
? widget.displayname(item)
|
||||
: widget.shortName ?? widget.defaultName,
|
||||
isSelected: item == widget.value,
|
||||
),
|
||||
),
|
||||
|
|
@ -110,8 +118,10 @@ class CoursePlanFilterState<T> extends State<CoursePlanFilter<T>> {
|
|||
),
|
||||
),
|
||||
searchMatchFn: (item, searchValue) {
|
||||
final displayName =
|
||||
widget.displayname(item.value).toLowerCase();
|
||||
final displayName = (item.value != null
|
||||
? widget.displayname(item.value as T)
|
||||
: widget.defaultName)
|
||||
.toLowerCase();
|
||||
|
||||
final search = searchValue.toLowerCase();
|
||||
return displayName.startsWith(search);
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ class NewCourseView extends StatelessWidget {
|
|||
value: controller.languageLevelFilter,
|
||||
onChanged: controller.setLanguageLevelFilter,
|
||||
items: LanguageLevelTypeEnum.values,
|
||||
displayname: (v) =>
|
||||
v?.string ?? L10n.of(context).cefrLevelLabel,
|
||||
displayname: (v) => v.string,
|
||||
fontSize: descFontSize,
|
||||
iconSize: iconSize,
|
||||
defaultName: L10n.of(context).cefrLevelLabel,
|
||||
),
|
||||
CoursePlanFilter<LanguageModel>(
|
||||
value: controller.instructionLanguageFilter,
|
||||
|
|
@ -70,11 +70,13 @@ class NewCourseView extends StatelessWidget {
|
|||
items: MatrixState
|
||||
.pangeaController.pLanguageStore.baseOptions,
|
||||
displayname: (v) =>
|
||||
v?.getDisplayName(context) ??
|
||||
L10n.of(context).languageOfInstructionsLabel,
|
||||
v.getDisplayName(context) ?? v.displayName,
|
||||
enableSearch: true,
|
||||
fontSize: descFontSize,
|
||||
iconSize: iconSize,
|
||||
defaultName:
|
||||
L10n.of(context).languageOfInstructionsLabel,
|
||||
shortName: L10n.of(context).instructionsLanguage,
|
||||
),
|
||||
CoursePlanFilter<LanguageModel>(
|
||||
value: controller.targetLanguageFilter,
|
||||
|
|
@ -82,11 +84,11 @@ class NewCourseView extends StatelessWidget {
|
|||
items: MatrixState
|
||||
.pangeaController.pLanguageStore.targetOptions,
|
||||
displayname: (v) =>
|
||||
v?.getDisplayName(context) ??
|
||||
L10n.of(context).targetLanguageLabel,
|
||||
v.getDisplayName(context) ?? v.displayName,
|
||||
enableSearch: true,
|
||||
fontSize: descFontSize,
|
||||
iconSize: iconSize,
|
||||
defaultName: L10n.of(context).targetLanguageLabel,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue