22using Nickvision . Desktop . Application ;
33using Nickvision . Desktop . Filesystem ;
44using Nickvision . Desktop . Globalization ;
5+ using System . Collections ;
56using System . Collections . Generic ;
67using System . Threading . Tasks ;
78
@@ -13,46 +14,35 @@ public class PreferencesViewController
1314 private readonly Configuration _configuration ;
1415
1516 public ITranslationService Translator { get ; }
17+ public IReadOnlyList < SelectionItem < string > > AvailableTranslationLanguages { get ; }
18+ public IReadOnlyList < SelectionItem < Theme > > Themes { get ; }
1619
1720 public PreferencesViewController ( IJsonFileService jsonFileService , ITranslationService translationService )
1821 {
1922 _jsonFileService = jsonFileService ;
2023 _configuration = _jsonFileService . Load < Configuration > ( Configuration . Key ) ;
2124 Translator = translationService ;
22- }
23-
24- public IReadOnlyList < SelectionItem < Theme > > Themes
25- {
26- get => new List < SelectionItem < Theme > > ( )
25+ AvailableTranslationLanguages = new List < SelectionItem < string > > ( )
26+ {
27+ new SelectionItem < string > ( string . Empty , Translator . _ ( "System" ) , string . IsNullOrEmpty ( _configuration . TranslationLanguage ) ) ,
28+ new SelectionItem < string > ( "C" , "en_US" , _configuration . TranslationLanguage == "C" )
29+ } ;
30+ foreach ( var language in Translator . AvailableLanguages )
31+ {
32+ ( AvailableTranslationLanguages as IList ) ! . Add ( new SelectionItem < string > ( language , language , _configuration . TranslationLanguage == language ) ) ;
33+ }
34+ Themes = new List < SelectionItem < Theme > > ( )
2735 {
2836 new SelectionItem < Theme > ( Models . Theme . Light , Translator . _p ( "Theme" , "Light" ) , _configuration . Theme == Models . Theme . Light ) ,
2937 new SelectionItem < Theme > ( Models . Theme . Dark , Translator . _p ( "Theme" , "Dark" ) , _configuration . Theme == Models . Theme . Dark ) ,
3038 new SelectionItem < Theme > ( Models . Theme . System , Translator . _p ( "Theme" , "System" ) , _configuration . Theme == Models . Theme . System ) ,
3139 } ;
3240 }
33-
3441 public SelectionItem < Theme > Theme
3542 {
3643 set => _configuration . Theme = value . Value ;
3744 }
3845
39- public IReadOnlyList < SelectionItem < string > > AvailableTranslationLanguages
40- {
41- get
42- {
43- var availableLanguages = new List < SelectionItem < string > > ( )
44- {
45- new SelectionItem < string > ( string . Empty , Translator . _ ( "System" ) , string . IsNullOrEmpty ( _configuration . TranslationLanguage ) ) ,
46- new SelectionItem < string > ( "C" , "en_US" , _configuration . TranslationLanguage == "C" )
47- } ;
48- foreach ( var language in Translator . AvailableLanguages )
49- {
50- availableLanguages . Add ( new SelectionItem < string > ( language , language , _configuration . TranslationLanguage == language ) ) ;
51- }
52- return availableLanguages ;
53- }
54- }
55-
5646 public SelectionItem < string > TranslationLanguage
5747 {
5848 set => _configuration . TranslationLanguage = value . Value ;
0 commit comments