@@ -332,36 +332,9 @@ class _SettingsView extends StatelessWidget {
332
332
),
333
333
),
334
334
// Language Tab Content
335
- ListView (
336
- padding: const EdgeInsets .all (AppSpacing .lg),
337
- children: [
338
- _buildSettingSection (
339
- context,
340
- title: l10n.languageLabel,
341
- description: l10n.languageDescription,
342
- child: DropdownButton <AppLanguage >(
343
- value: userAppSettings.language,
344
- onChanged: (value) {
345
- if (value != null ) {
346
- context.read <SettingsBloc >().add (
347
- SettingsLanguageChanged (value),
348
- );
349
- }
350
- },
351
- items: _supportedLanguages
352
- .map (
353
- (lang) => DropdownMenuItem (
354
- value: lang,
355
- child: Text (
356
- _getLanguageName (lang, l10n),
357
- ),
358
- ),
359
- )
360
- .toList (),
361
- // Removed isExpanded: true
362
- ),
363
- ),
364
- ],
335
+ _LanguageSelectionList (
336
+ currentLanguage: userAppSettings.language,
337
+ l10n: l10n,
365
338
),
366
339
],
367
340
),
@@ -481,6 +454,63 @@ class _SettingsView extends StatelessWidget {
481
454
}
482
455
}
483
456
457
+ static const List <String > _supportedFontFamilies = [
458
+ 'SystemDefault' ,
459
+ 'Roboto' ,
460
+ 'OpenSans' ,
461
+ 'Lato' ,
462
+ 'Montserrat' ,
463
+ 'Merriweather' ,
464
+ ];
465
+ }
466
+
467
+ /// {@template _language_selection_list}
468
+ /// A widget that displays a list of supported languages for selection.
469
+ /// {@endtemplate}
470
+ class _LanguageSelectionList extends StatelessWidget {
471
+ /// {@macro _language_selection_list}
472
+ const _LanguageSelectionList ({
473
+ required this .currentLanguage,
474
+ required this .l10n,
475
+ });
476
+
477
+ /// The currently selected language.
478
+ final AppLanguage currentLanguage;
479
+
480
+ /// The localized strings for the application.
481
+ final AppLocalizations l10n;
482
+
483
+ @override
484
+ Widget build (BuildContext context) {
485
+ return ListView .builder (
486
+ padding: const EdgeInsets .symmetric (vertical: AppSpacing .lg),
487
+ itemCount: _supportedLanguages.length,
488
+ itemBuilder: (context, index) {
489
+ final language = _supportedLanguages[index];
490
+ final isSelected = language == currentLanguage;
491
+ return ListTile (
492
+ title: Text (
493
+ _getLanguageName (language, l10n),
494
+ style: Theme .of (context).textTheme.titleMedium,
495
+ ),
496
+ trailing: isSelected
497
+ ? Icon (
498
+ Icons .check,
499
+ color: Theme .of (context).colorScheme.primary,
500
+ )
501
+ : null ,
502
+ onTap: () {
503
+ if (! isSelected) {
504
+ context.read <SettingsBloc >().add (
505
+ SettingsLanguageChanged (language),
506
+ );
507
+ }
508
+ },
509
+ );
510
+ },
511
+ );
512
+ }
513
+
484
514
String _getLanguageName (AppLanguage language, AppLocalizations l10n) {
485
515
switch (language) {
486
516
case 'en' :
@@ -492,15 +522,6 @@ class _SettingsView extends StatelessWidget {
492
522
}
493
523
}
494
524
495
- static const List <String > _supportedFontFamilies = [
496
- 'SystemDefault' ,
497
- 'Roboto' ,
498
- 'OpenSans' ,
499
- 'Lato' ,
500
- 'Montserrat' ,
501
- 'Merriweather' ,
502
- ];
503
-
504
525
static const List <AppLanguage > _supportedLanguages = [
505
526
'en' ,
506
527
'ar' ,
0 commit comments