Skip to content

Commit f14cf16

Browse files
committed
chore: Reorganize settings/application
1 parent 9785032 commit f14cf16

File tree

1 file changed

+175
-145
lines changed

1 file changed

+175
-145
lines changed

lib/screens/settings/application.dart

Lines changed: 175 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ApplicationSettings extends StatelessWidget {
7070
settings.kThemeMode.value = v;
7171
},
7272
),
73-
if (isMobilePlatform) _buildImmersiveModeTile(),
73+
if (isMobilePlatform) ImmersiveModeTile(),
7474
const LanguageSection(),
7575
SubHeader(loc.dateAndTime, padding: DesktopSettings.horizontalPadding),
7676
const DateFormatSection(),
@@ -94,121 +94,14 @@ class ApplicationSettings extends StatelessWidget {
9494
),
9595
if (isDesktopPlatform) ...[
9696
const SubHeader('Window', padding: DesktopSettings.horizontalPadding),
97-
if (canLaunchAtStartup)
98-
CheckboxListTile.adaptive(
99-
value: settings.kLaunchAppOnStartup.value,
100-
onChanged: (v) {
101-
if (v != null) {
102-
settings.kLaunchAppOnStartup.value = v;
103-
}
104-
},
105-
contentPadding: DesktopSettings.horizontalPadding,
106-
secondary: CircleAvatar(
107-
backgroundColor: Colors.transparent,
108-
foregroundColor: theme.iconTheme.color,
109-
child: const Icon(Icons.launch),
110-
),
111-
title: const Text('Launch app on startup'),
112-
subtitle: const Text(
113-
'Whether to launch the app when the system starts',
114-
),
115-
),
116-
CheckboxListTile.adaptive(
117-
value: settings.kFullscreen.value,
118-
onChanged: (v) {
119-
if (v != null) settings.kFullscreen.value = v;
120-
},
121-
contentPadding: DesktopSettings.horizontalPadding,
122-
secondary: CircleAvatar(
123-
backgroundColor: Colors.transparent,
124-
foregroundColor: theme.iconTheme.color,
125-
child: const Icon(Icons.fullscreen),
126-
),
127-
title: const Text('Fullscreen Mode'),
128-
subtitle: const Text('Whether the app is in fullscreen mode or not.'),
129-
),
130-
_buildImmersiveModeTile(),
131-
if (canUseSystemTray)
132-
CheckboxListTile.adaptive(
133-
value: settings.kMinimizeToTray.value,
134-
onChanged: (v) {
135-
if (v != null) {
136-
settings.kMinimizeToTray.value = v;
137-
}
138-
},
139-
contentPadding: DesktopSettings.horizontalPadding,
140-
secondary: CircleAvatar(
141-
backgroundColor: Colors.transparent,
142-
foregroundColor: theme.iconTheme.color,
143-
child: const Icon(Icons.sensor_door),
144-
),
145-
title: const Text('Minimize to tray'),
146-
subtitle: const Text(
147-
'Whether to minimize app to the system tray when the window is '
148-
'closed. This will keep the app running in the background.',
149-
),
150-
),
97+
WindowSection(),
15198
],
15299
if (settings.kShowDebugInfo.value) ...[
153100
const SubHeader(
154101
'Acessibility',
155102
padding: DesktopSettings.horizontalPadding,
156103
),
157-
CheckboxListTile.adaptive(
158-
value: settings.kAnimationsEnabled.value,
159-
onChanged: (v) {
160-
if (v != null) {
161-
settings.kAnimationsEnabled.value = v;
162-
}
163-
},
164-
contentPadding: DesktopSettings.horizontalPadding,
165-
secondary: CircleAvatar(
166-
backgroundColor: Colors.transparent,
167-
foregroundColor: theme.iconTheme.color,
168-
child: const Icon(Icons.animation),
169-
),
170-
title: const Text('Animations'),
171-
subtitle: const Text(
172-
'Disable animations on low-end devices to improve performance. This '
173-
'will also disable some visual effects. ',
174-
),
175-
),
176-
CheckboxListTile.adaptive(
177-
value: settings.kHighContrast.value,
178-
onChanged: (v) {
179-
if (v != null) {
180-
settings.kHighContrast.value = v;
181-
}
182-
},
183-
contentPadding: DesktopSettings.horizontalPadding,
184-
secondary: CircleAvatar(
185-
backgroundColor: Colors.transparent,
186-
foregroundColor: theme.iconTheme.color,
187-
child: const Icon(Icons.filter_b_and_w),
188-
),
189-
title: const Text('High contrast mode'),
190-
subtitle: const Text(
191-
'Enable high contrast mode to make the app easier to read and use.',
192-
),
193-
),
194-
CheckboxListTile.adaptive(
195-
value: settings.kLargeFont.value,
196-
onChanged: (v) {
197-
if (v != null) {
198-
settings.kLargeFont.value = v;
199-
}
200-
},
201-
contentPadding: DesktopSettings.horizontalPadding,
202-
secondary: CircleAvatar(
203-
backgroundColor: Colors.transparent,
204-
foregroundColor: theme.iconTheme.color,
205-
child: const Icon(Icons.accessibility_new),
206-
),
207-
title: const Text('Large Font'),
208-
subtitle: const Text(
209-
'Increase the size of the text in the app to make it easier to read.',
210-
),
211-
),
104+
AcessibilitySection(),
212105
],
213106
if (isDesktopPlatform) ...[
214107
SubHeader(
@@ -249,41 +142,6 @@ class ApplicationSettings extends StatelessWidget {
249142
],
250143
]);
251144
}
252-
253-
/// Creates the Immersive Mode tile.
254-
///
255-
/// On Desktop, this is used alonside the Fullscreen mode tile. When in
256-
/// fullscreen, the immersive mode hides the top bar and only shows it when
257-
/// the user hovers over the top of the window.
258-
///
259-
/// On Mobile, this makes the app full-screen and hides the system UI.
260-
Widget _buildImmersiveModeTile() {
261-
return Builder(builder: (context) {
262-
final theme = Theme.of(context);
263-
final settings = context.watch<SettingsProvider>();
264-
265-
return CheckboxListTile.adaptive(
266-
value: settings.kImmersiveMode.value,
267-
onChanged: settings.kFullscreen.value || isMobilePlatform
268-
? (v) {
269-
if (v != null) settings.kImmersiveMode.value = v;
270-
}
271-
: null,
272-
contentPadding: DesktopSettings.horizontalPadding,
273-
secondary: CircleAvatar(
274-
backgroundColor: Colors.transparent,
275-
foregroundColor: theme.iconTheme.color,
276-
child: const Icon(Icons.web_asset),
277-
),
278-
title: const Text('Immersive Mode'),
279-
subtitle: const Text(
280-
'This will hide the title bar and window controls. '
281-
'To show the top bar, hover over the top of the window. '
282-
'This only works in fullscreen mode.',
283-
),
284-
);
285-
});
286-
}
287145
}
288146

289147
class LanguageSection extends StatelessWidget {
@@ -412,6 +270,178 @@ class TimeFormatSection extends StatelessWidget {
412270
}
413271
}
414272

273+
class WindowSection extends StatelessWidget {
274+
const WindowSection({super.key});
275+
276+
@override
277+
Widget build(BuildContext context) {
278+
final theme = Theme.of(context);
279+
final settings = context.watch<SettingsProvider>();
280+
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
281+
if (canLaunchAtStartup)
282+
CheckboxListTile.adaptive(
283+
value: settings.kLaunchAppOnStartup.value,
284+
onChanged: (v) {
285+
if (v != null) {
286+
settings.kLaunchAppOnStartup.value = v;
287+
}
288+
},
289+
contentPadding: DesktopSettings.horizontalPadding,
290+
secondary: CircleAvatar(
291+
backgroundColor: Colors.transparent,
292+
foregroundColor: theme.iconTheme.color,
293+
child: const Icon(Icons.launch),
294+
),
295+
title: const Text('Launch app on startup'),
296+
subtitle: const Text(
297+
'Whether to launch the app when the system starts',
298+
),
299+
),
300+
CheckboxListTile.adaptive(
301+
value: settings.kFullscreen.value,
302+
onChanged: (v) {
303+
if (v != null) settings.kFullscreen.value = v;
304+
},
305+
contentPadding: DesktopSettings.horizontalPadding,
306+
secondary: CircleAvatar(
307+
backgroundColor: Colors.transparent,
308+
foregroundColor: theme.iconTheme.color,
309+
child: const Icon(Icons.fullscreen),
310+
),
311+
title: const Text('Fullscreen Mode'),
312+
subtitle: const Text('Whether the app is in fullscreen mode or not.'),
313+
),
314+
ImmersiveModeTile(),
315+
if (canUseSystemTray)
316+
CheckboxListTile.adaptive(
317+
value: settings.kMinimizeToTray.value,
318+
onChanged: (v) {
319+
if (v != null) {
320+
settings.kMinimizeToTray.value = v;
321+
}
322+
},
323+
contentPadding: DesktopSettings.horizontalPadding,
324+
secondary: CircleAvatar(
325+
backgroundColor: Colors.transparent,
326+
foregroundColor: theme.iconTheme.color,
327+
child: const Icon(Icons.sensor_door),
328+
),
329+
title: const Text('Minimize to tray'),
330+
subtitle: const Text(
331+
'Whether to minimize app to the system tray when the window is '
332+
'closed. This will keep the app running in the background.',
333+
),
334+
),
335+
]);
336+
}
337+
}
338+
339+
/// Creates the Immersive Mode tile.
340+
///
341+
/// On Desktop, this is used alonside the Fullscreen mode tile. When in
342+
/// fullscreen, the immersive mode hides the top bar and only shows it when
343+
/// the user hovers over the top of the window.
344+
///
345+
/// On Mobile, this makes the app full-screen and hides the system UI.
346+
class ImmersiveModeTile extends StatelessWidget {
347+
const ImmersiveModeTile({super.key});
348+
349+
@override
350+
Widget build(BuildContext context) {
351+
final theme = Theme.of(context);
352+
final settings = context.watch<SettingsProvider>();
353+
354+
return CheckboxListTile.adaptive(
355+
value: settings.kImmersiveMode.value,
356+
onChanged: settings.kFullscreen.value || isMobilePlatform
357+
? (v) {
358+
if (v != null) settings.kImmersiveMode.value = v;
359+
}
360+
: null,
361+
contentPadding: DesktopSettings.horizontalPadding,
362+
secondary: CircleAvatar(
363+
backgroundColor: Colors.transparent,
364+
foregroundColor: theme.iconTheme.color,
365+
child: const Icon(Icons.web_asset),
366+
),
367+
title: const Text('Immersive Mode'),
368+
subtitle: const Text(
369+
'This will hide the title bar and window controls. '
370+
'To show the top bar, hover over the top of the window. '
371+
'This only works in fullscreen mode.',
372+
),
373+
);
374+
}
375+
}
376+
377+
class AcessibilitySection extends StatelessWidget {
378+
const AcessibilitySection({super.key});
379+
380+
@override
381+
Widget build(BuildContext context) {
382+
final theme = Theme.of(context);
383+
final settings = context.watch<SettingsProvider>();
384+
385+
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
386+
CheckboxListTile.adaptive(
387+
value: settings.kAnimationsEnabled.value,
388+
onChanged: (v) {
389+
if (v != null) {
390+
settings.kAnimationsEnabled.value = v;
391+
}
392+
},
393+
contentPadding: DesktopSettings.horizontalPadding,
394+
secondary: CircleAvatar(
395+
backgroundColor: Colors.transparent,
396+
foregroundColor: theme.iconTheme.color,
397+
child: const Icon(Icons.animation),
398+
),
399+
title: const Text('Animations'),
400+
subtitle: const Text(
401+
'Disable animations on low-end devices to improve performance. This '
402+
'will also disable some visual effects. ',
403+
),
404+
),
405+
CheckboxListTile.adaptive(
406+
value: settings.kHighContrast.value,
407+
onChanged: (v) {
408+
if (v != null) {
409+
settings.kHighContrast.value = v;
410+
}
411+
},
412+
contentPadding: DesktopSettings.horizontalPadding,
413+
secondary: CircleAvatar(
414+
backgroundColor: Colors.transparent,
415+
foregroundColor: theme.iconTheme.color,
416+
child: const Icon(Icons.filter_b_and_w),
417+
),
418+
title: const Text('High contrast mode'),
419+
subtitle: const Text(
420+
'Enable high contrast mode to make the app easier to read and use.',
421+
),
422+
),
423+
CheckboxListTile.adaptive(
424+
value: settings.kLargeFont.value,
425+
onChanged: (v) {
426+
if (v != null) {
427+
settings.kLargeFont.value = v;
428+
}
429+
},
430+
contentPadding: DesktopSettings.horizontalPadding,
431+
secondary: CircleAvatar(
432+
backgroundColor: Colors.transparent,
433+
foregroundColor: theme.iconTheme.color,
434+
child: const Icon(Icons.accessibility_new),
435+
),
436+
title: const Text('Large Font'),
437+
subtitle: const Text(
438+
'Increase the size of the text in the app to make it easier to read.',
439+
),
440+
),
441+
]);
442+
}
443+
}
444+
415445
class KeyboardSection extends StatelessWidget {
416446
const KeyboardSection({super.key});
417447

0 commit comments

Comments
 (0)