@@ -84,121 +84,112 @@ class _SettingsScreenState extends State<SettingsScreen> {
8484
8585 @override
8686 Widget build (BuildContext context) {
87- final theme = EditorTheme (isDark: true );
88-
89- return Scaffold (
90- backgroundColor: theme.background,
91- appBar: AppBar (
92- backgroundColor: theme.surface,
93- title: const Text ('Settings' ),
94- leading: IconButton (
95- icon: const Icon (Icons .arrow_back),
96- onPressed: () => Navigator .pop (context),
87+ return Theme (
88+ data: EditorTheme .darkTheme,
89+ child: Scaffold (
90+ backgroundColor: EditorTheme .background,
91+ appBar: AppBar (
92+ backgroundColor: EditorTheme .surface,
93+ title: const Text ('Settings' ),
94+ leading: IconButton (
95+ icon: const Icon (Icons .arrow_back),
96+ onPressed: () => Navigator .pop (context),
97+ ),
9798 ),
99+ body: _isLoading
100+ ? const Center (child: CircularProgressIndicator ())
101+ : ListView (
102+ padding: const EdgeInsets .all (16 ),
103+ children: [
104+ _buildSectionHeader ('Editor' ),
105+ _buildSliderTile (
106+ 'Font Size' ,
107+ '${_settings .fontSize .toInt ()} px' ,
108+ _settings.fontSize,
109+ 10 ,
110+ 24 ,
111+ (value) => _updateSettings (_settings.copyWith (fontSize: value)),
112+ ),
113+ _buildDropdownTile (
114+ 'Tab Size' ,
115+ '${_settings .tabSize } spaces' ,
116+ _settings.tabSize,
117+ [2 , 4 , 6 , 8 ],
118+ (value) => _updateSettings (_settings.copyWith (tabSize: value)),
119+ ),
120+ _buildSwitchTile (
121+ 'Auto Save' ,
122+ 'Save files automatically' ,
123+ _settings.autoSave,
124+ (value) => _updateSettings (_settings.copyWith (autoSave: value)),
125+ ),
126+ _buildSwitchTile (
127+ 'Show Line Numbers' ,
128+ 'Display line numbers' ,
129+ _settings.showLineNumbers,
130+ (value) => _updateSettings (_settings.copyWith (showLineNumbers: value)),
131+ ),
132+ _buildSwitchTile (
133+ 'Highlight Current Line' ,
134+ 'Highlight the line where the cursor is' ,
135+ _settings.highlightCurrentLine,
136+ (value) => _updateSettings (_settings.copyWith (highlightCurrentLine: value)),
137+ ),
138+ const SizedBox (height: 24 ),
139+ _buildSectionHeader ('Code Editing' ),
140+ _buildSwitchTile (
141+ 'Bracket Matching' ,
142+ 'Highlight matching brackets' ,
143+ _settings.bracketMatching,
144+ (value) => _updateSettings (_settings.copyWith (bracketMatching: value)),
145+ ),
146+ _buildSwitchTile (
147+ 'Auto Closing Brackets' ,
148+ 'Automatically close brackets and quotes' ,
149+ _settings.autoClosingBrackets,
150+ (value) => _updateSettings (_settings.copyWith (autoClosingBrackets: value)),
151+ ),
152+ _buildSwitchTile (
153+ 'Code Folding' ,
154+ 'Allow folding code blocks' ,
155+ _settings.codeFolding,
156+ (value) => _updateSettings (_settings.copyWith (codeFolding: value)),
157+ ),
158+ _buildSwitchTile (
159+ 'Word Wrap' ,
160+ 'Wrap long lines' ,
161+ _settings.wordWrap,
162+ (value) => _updateSettings (_settings.copyWith (wordWrap: value)),
163+ ),
164+ const SizedBox (height: 24 ),
165+ _buildSectionHeader ('Appearance' ),
166+ _buildDropdownTile (
167+ 'Theme' ,
168+ _settings.themeMode == 'dark' ? 'Dark' : 'Light' ,
169+ _settings.themeMode,
170+ ['dark' , 'light' ],
171+ (value) => _updateSettings (_settings.copyWith (themeMode: value! )),
172+ labels: const ['Dark' , 'Light' ],
173+ ),
174+ const SizedBox (height: 24 ),
175+ _buildSectionHeader ('About' ),
176+ _buildInfoTile ('Version' , '1.0.0' ),
177+ _buildInfoTile ('Flutter' , '3.x' ),
178+ ],
179+ ),
98180 ),
99- body: _isLoading
100- ? const Center (child: CircularProgressIndicator ())
101- : ListView (
102- padding: const EdgeInsets .all (16 ),
103- children: [
104- _buildSectionHeader ('Editor' , theme),
105- _buildSliderTile (
106- 'Font Size' ,
107- '${_settings .fontSize .toInt ()} px' ,
108- _settings.fontSize,
109- 10 ,
110- 24 ,
111- (value) => _updateSettings (_settings.copyWith (fontSize: value)),
112- theme,
113- ),
114- _buildDropdownTile (
115- 'Tab Size' ,
116- '${_settings .tabSize } spaces' ,
117- _settings.tabSize,
118- [2 , 4 , 6 , 8 ],
119- (value) => _updateSettings (_settings.copyWith (tabSize: value)),
120- theme,
121- ),
122- _buildSwitchTile (
123- 'Auto Save' ,
124- 'Save files automatically' ,
125- _settings.autoSave,
126- (value) => _updateSettings (_settings.copyWith (autoSave: value)),
127- theme,
128- ),
129- _buildSwitchTile (
130- 'Show Line Numbers' ,
131- 'Display line numbers' ,
132- _settings.showLineNumbers,
133- (value) => _updateSettings (_settings.copyWith (showLineNumbers: value)),
134- theme,
135- ),
136- _buildSwitchTile (
137- 'Highlight Current Line' ,
138- 'Highlight the line where the cursor is' ,
139- _settings.highlightCurrentLine,
140- (value) => _updateSettings (_settings.copyWith (highlightCurrentLine: value)),
141- theme,
142- ),
143- const SizedBox (height: 24 ),
144- _buildSectionHeader ('Code Editing' , theme),
145- _buildSwitchTile (
146- 'Bracket Matching' ,
147- 'Highlight matching brackets' ,
148- _settings.bracketMatching,
149- (value) => _updateSettings (_settings.copyWith (bracketMatching: value)),
150- theme,
151- ),
152- _buildSwitchTile (
153- 'Auto Closing Brackets' ,
154- 'Automatically close brackets and quotes' ,
155- _settings.autoClosingBrackets,
156- (value) => _updateSettings (_settings.copyWith (autoClosingBrackets: value)),
157- theme,
158- ),
159- _buildSwitchTile (
160- 'Code Folding' ,
161- 'Allow folding code blocks' ,
162- _settings.codeFolding,
163- (value) => _updateSettings (_settings.copyWith (codeFolding: value)),
164- theme,
165- ),
166- _buildSwitchTile (
167- 'Word Wrap' ,
168- 'Wrap long lines' ,
169- _settings.wordWrap,
170- (value) => _updateSettings (_settings.copyWith (wordWrap: value)),
171- theme,
172- ),
173- const SizedBox (height: 24 ),
174- _buildSectionHeader ('Appearance' , theme),
175- _buildDropdownTile (
176- 'Theme' ,
177- _settings.themeMode == 'dark' ? 'Dark' : 'Light' ,
178- _settings.themeMode,
179- ['dark' , 'light' ],
180- (value) => _updateSettings (_settings.copyWith (themeMode: value! )),
181- theme,
182- labels: const ['Dark' , 'Light' ],
183- ),
184- const SizedBox (height: 24 ),
185- _buildSectionHeader ('About' , theme),
186- _buildInfoTile ('Version' , '1.0.0' , theme),
187- _buildInfoTile ('Flutter' , '3.x' , theme),
188- ],
189- ),
190181 );
191182 }
192183
193- Widget _buildSectionHeader (String title, EditorTheme theme ) {
184+ Widget _buildSectionHeader (String title) {
194185 return Padding (
195186 padding: const EdgeInsets .only (bottom: 12 , top: 8 ),
196187 child: Text (
197188 title.toUpperCase (),
198- style: TextStyle (
189+ style: const TextStyle (
199190 fontSize: 12 ,
200191 fontWeight: FontWeight .bold,
201- color: theme .primary,
192+ color: EditorTheme .primary,
202193 letterSpacing: 1.2 ,
203194 ),
204195 ),
@@ -210,20 +201,19 @@ class _SettingsScreenState extends State<SettingsScreen> {
210201 String subtitle,
211202 bool value,
212203 Function (bool ) onChanged,
213- EditorTheme theme,
214204 ) {
215205 return Container (
216206 margin: const EdgeInsets .only (bottom: 8 ),
217207 decoration: BoxDecoration (
218- color: theme .surface,
208+ color: EditorTheme .surface,
219209 borderRadius: BorderRadius .circular (12 ),
220210 ),
221211 child: SwitchListTile (
222- title: Text (title, style: TextStyle (color: theme .textPrimary)),
223- subtitle: Text (subtitle, style: TextStyle (color: theme .textMuted, fontSize: 12 )),
212+ title: Text (title, style: const TextStyle (color: EditorTheme .textPrimary)),
213+ subtitle: Text (subtitle, style: const TextStyle (color: EditorTheme .textMuted, fontSize: 12 )),
224214 value: value,
225215 onChanged: onChanged,
226- activeColor: theme .primary,
216+ activeColor: EditorTheme .primary,
227217 shape: RoundedRectangleBorder (borderRadius: BorderRadius .circular (12 )),
228218 ),
229219 );
@@ -236,13 +226,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
236226 double min,
237227 double max,
238228 Function (double ) onChanged,
239- EditorTheme theme,
240229 ) {
241230 return Container (
242231 margin: const EdgeInsets .only (bottom: 8 ),
243232 padding: const EdgeInsets .all (16 ),
244233 decoration: BoxDecoration (
245- color: theme .surface,
234+ color: EditorTheme .surface,
246235 borderRadius: BorderRadius .circular (12 ),
247236 ),
248237 child: Column (
@@ -251,8 +240,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
251240 Row (
252241 mainAxisAlignment: MainAxisAlignment .spaceBetween,
253242 children: [
254- Text (title, style: TextStyle (color: theme .textPrimary)),
255- Text (valueLabel, style: TextStyle (color: theme .primary, fontWeight: FontWeight .bold)),
243+ Text (title, style: const TextStyle (color: EditorTheme .textPrimary)),
244+ Text (valueLabel, style: const TextStyle (color: EditorTheme .primary, fontWeight: FontWeight .bold)),
256245 ],
257246 ),
258247 Slider (
@@ -261,7 +250,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
261250 max: max,
262251 divisions: (max - min).toInt (),
263252 onChanged: onChanged,
264- activeColor: theme .primary,
253+ activeColor: EditorTheme .primary,
265254 ),
266255 ],
267256 ),
@@ -273,21 +262,20 @@ class _SettingsScreenState extends State<SettingsScreen> {
273262 String valueLabel,
274263 T value,
275264 List <T > items,
276- Function (T ? ) onChanged,
277- EditorTheme theme, {
265+ Function (T ? ) onChanged, {
278266 List <String >? labels,
279267 }) {
280268 return Container (
281269 margin: const EdgeInsets .only (bottom: 8 ),
282270 padding: const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 ),
283271 decoration: BoxDecoration (
284- color: theme .surface,
272+ color: EditorTheme .surface,
285273 borderRadius: BorderRadius .circular (12 ),
286274 ),
287275 child: Row (
288276 mainAxisAlignment: MainAxisAlignment .spaceBetween,
289277 children: [
290- Text (title, style: TextStyle (color: theme .textPrimary)),
278+ Text (title, style: const TextStyle (color: EditorTheme .textPrimary)),
291279 DropdownButton <T >(
292280 value: value,
293281 items: items.map ((item) {
@@ -296,32 +284,32 @@ class _SettingsScreenState extends State<SettingsScreen> {
296284 value: item,
297285 child: Text (
298286 labels != null ? labels[index] : item.toString (),
299- style: TextStyle (color: theme .primary),
287+ style: const TextStyle (color: EditorTheme .primary),
300288 ),
301289 );
302290 }).toList (),
303291 onChanged: onChanged,
304- dropdownColor: theme .surface,
292+ dropdownColor: EditorTheme .surface,
305293 underline: const SizedBox (),
306294 ),
307295 ],
308296 ),
309297 );
310298 }
311299
312- Widget _buildInfoTile (String title, String value, EditorTheme theme ) {
300+ Widget _buildInfoTile (String title, String value) {
313301 return Container (
314302 margin: const EdgeInsets .only (bottom: 8 ),
315303 padding: const EdgeInsets .all (16 ),
316304 decoration: BoxDecoration (
317- color: theme .surface,
305+ color: EditorTheme .surface,
318306 borderRadius: BorderRadius .circular (12 ),
319307 ),
320308 child: Row (
321309 mainAxisAlignment: MainAxisAlignment .spaceBetween,
322310 children: [
323- Text (title, style: TextStyle (color: theme .textPrimary)),
324- Text (value, style: TextStyle (color: theme .textMuted)),
311+ Text (title, style: const TextStyle (color: EditorTheme .textPrimary)),
312+ Text (value, style: const TextStyle (color: EditorTheme .textMuted)),
325313 ],
326314 ),
327315 );
0 commit comments