1414using TextBox = System . Windows . Controls . TextBox ;
1515using UserControl = System . Windows . Controls . UserControl ;
1616
17+ #nullable enable
18+
1719namespace Flow . Launcher . Core . Plugin
1820{
1921 public class JsonRPCPluginSettings
@@ -24,12 +26,12 @@ public class JsonRPCPluginSettings
2426 public Dictionary < string , FrameworkElement > SettingControls { get ; } = new ( ) ;
2527
2628 public IReadOnlyDictionary < string , object > Inner => Settings ;
27- protected ConcurrentDictionary < string , object > Settings { get ; set ; }
29+ protected ConcurrentDictionary < string , object > Settings { get ; set ; } = null ! ;
2830 public required IPublicAPI API { get ; init ; }
2931
30- private JsonStorage < ConcurrentDictionary < string , object > > _storage ;
32+ private JsonStorage < ConcurrentDictionary < string , object > > _storage = null ! ;
3133
32- // maybe move to resource?
34+ // TODO: Move to resource
3335 private static readonly Thickness settingControlMargin = new ( 0 , 9 , 18 , 9 ) ;
3436 private static readonly Thickness settingCheckboxMargin = new ( 0 , 9 , 9 , 9 ) ;
3537 private static readonly Thickness settingPanelMargin = ( Thickness ) System . Windows . Application . Current . FindResource ( "SettingPanelMargin" ) ;
@@ -104,10 +106,10 @@ public void Save()
104106 _storage . Save ( ) ;
105107 }
106108
107- public Control CreateSettingPanel ( )
109+ public Control ? CreateSettingPanel ( )
108110 {
109111 // If there are no settings or the settings are empty, return null
110- if ( Settings == null || Settings . IsEmpty )
112+ if ( Configuration == null || Settings == null || Settings . IsEmpty )
111113 {
112114 return null ;
113115 }
@@ -124,7 +126,7 @@ public Control CreateSettingPanel()
124126 } ) ;
125127
126128 // Iterate over each setting and create one row for it
127- int rowCount = 0 ;
129+ var rowCount = 0 ;
128130 foreach ( var ( type , attributes ) in Configuration . Body )
129131 {
130132 // Skip if the setting does not have attributes or name
@@ -137,7 +139,7 @@ public Control CreateSettingPanel()
137139 mainPanel . RowDefinitions . Add ( new RowDefinition ( ) ) ;
138140
139141 // State controls for column 0 and 1
140- StackPanel panel = null ;
142+ StackPanel ? panel = null ;
141143 FrameworkElement contentControl ;
142144
143145 // If the type is textBlock or seperator, we do not need to create a panel
@@ -151,6 +153,7 @@ public Control CreateSettingPanel()
151153 } ;
152154
153155 // Create a text block for name
156+ // TODO: Move to resource
154157 var name = new TextBlock ( )
155158 {
156159 Text = attributes . Label ,
@@ -159,9 +162,10 @@ public Control CreateSettingPanel()
159162 } ;
160163
161164 // Create a text block for description
162- TextBlock desc = null ;
165+ TextBlock ? desc = null ;
163166 if ( attributes . Description != null )
164167 {
168+ // TODO: Move to resource
165169 desc = new TextBlock ( )
166170 {
167171 Text = attributes . Description ,
@@ -170,7 +174,6 @@ public Control CreateSettingPanel()
170174 Margin = new ( 0 , 2 , 0 , 0 ) , // TODO: Use resource
171175 TextWrapping = TextWrapping . WrapWithOverflow
172176 } ;
173-
174177 desc . SetResourceReference ( TextBlock . ForegroundProperty , "Color04B" ) ; // for theme change
175178 }
176179
@@ -188,7 +191,7 @@ public Control CreateSettingPanel()
188191 {
189192 contentControl = new TextBlock
190193 {
191- Text = attributes . Description . Replace ( "\\ r\\ n" , "\r \n " ) ,
194+ Text = attributes . Description ? . Replace ( "\\ r\\ n" , "\r \n " ) ?? string . Empty ,
192195 Padding = new Thickness ( 0 , 0 , 0 , 0 ) ,
193196 HorizontalAlignment = System . Windows . HorizontalAlignment . Left ,
194197 TextAlignment = TextAlignment . Left ,
@@ -250,6 +253,7 @@ public Control CreateSettingPanel()
250253 {
251254 FolderBrowserDialog folderDialog => folderDialog . SelectedPath ,
252255 OpenFileDialog fileDialog => fileDialog . FileName ,
256+ _ => string . Empty
253257 } ;
254258 textBox . Text = path ;
255259 Settings [ attributes . Name ] = path ;
@@ -341,7 +345,7 @@ Settings[attributes.Name] is bool isChecked
341345
342346 checkBox . Click += ( sender , _ ) =>
343347 {
344- Settings [ attributes . Name ] = ( ( CheckBox ) sender ) . IsChecked ;
348+ Settings [ attributes . Name ] = ( ( CheckBox ) sender ) . IsChecked ! ;
345349 } ;
346350
347351 contentControl = checkBox ;
0 commit comments