From 480d6a8e270dd6b39eb6e77663425c9e4e5fe1fe Mon Sep 17 00:00:00 2001 From: Strycher Date: Sat, 18 Jul 2026 02:09:30 -0400 Subject: [PATCH] refactor(#274): move app debug logging toggle into the Debug category The App Settings pane carried a Debug card holding only the app-debug-logging switch, while the Debug category already owned the log viewers. Moved the switch next to the App debug log viewer it controls and dropped the now-empty Debug card from App Settings. Co-Authored-By: Claude Opus 4.8 --- lib/screens/settings/app_settings_view.dart | 58 ++------------------- lib/screens/settings_screen.dart | 34 ++++++++++++ 2 files changed, 37 insertions(+), 55 deletions(-) diff --git a/lib/screens/settings/app_settings_view.dart b/lib/screens/settings/app_settings_view.dart index a2a57e4..08e61b7 100644 --- a/lib/screens/settings/app_settings_view.dart +++ b/lib/screens/settings/app_settings_view.dart @@ -15,8 +15,9 @@ import '../map_cache_screen.dart'; /// Embeddable view (no Scaffold) for the App Settings shell pane. /// -/// Renders appearance, translation, battery, map, Cyr2Lat, and debug cards. -/// Notifications and message-handling settings live in [MessageSettingsView]. +/// Renders appearance, translation, battery, map, and Cyr2Lat cards. +/// Notifications and message-handling settings live in [MessageSettingsView]; +/// app debug logging lives in the Debug category on the settings screen. class AppSettingsView extends StatelessWidget { const AppSettingsView({super.key}); @@ -43,8 +44,6 @@ class AppSettingsView extends StatelessWidget { _buildMapSettingsCard(context, settingsService), const SizedBox(height: 16), _buildCyr2LatCard(context, settingsService), - const SizedBox(height: 16), - _buildDebugCard(context, settingsService), ], ); }, @@ -1355,57 +1354,6 @@ class AppSettingsView extends StatelessWidget { ), ); } - - Widget _buildDebugCard( - BuildContext context, - AppSettingsService settingsService, - ) { - return Card( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(16, 16, 16, 8), - child: Text( - context.l10n.appSettings_debugCard, - style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold), - ), - ), - SwitchListTile( - secondary: const Icon(Icons.bug_report_outlined), - title: Text(context.l10n.appSettings_appDebugLogging), - subtitle: Text(context.l10n.appSettings_appDebugLoggingSubtitle), - value: settingsService.settings.appDebugLogEnabled, - onChanged: (value) async { - try { - await settingsService.setAppDebugLogEnabled(value); - } catch (_) { - if (context.mounted) { - showDismissibleSnackBar( - context, - content: const Text( - 'Could not change debug logging. Please try again.', - ), - ); - } - return; - } - if (!context.mounted) return; - showDismissibleSnackBar( - context, - content: Text( - value - ? context.l10n.appSettings_appDebugLoggingEnabled - : context.l10n.appSettings_appDebugLoggingDisabled, - ), - duration: const Duration(seconds: 2), - ); - }, - ), - ], - ), - ); - } } /// Owns the [TextEditingController] for the manual model URL field so it diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 39cbf86..890766b 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -12,6 +12,7 @@ import '../l10n/l10n.dart'; import '../models/offband_gps_status.dart'; import '../models/radio_settings.dart'; import '../services/app_debug_log_service.dart'; +import '../services/app_settings_service.dart'; import '../connector/observer_config_client.dart'; import '../helpers/snack_bar_builder.dart'; import 'settings/settings_shell.dart'; @@ -571,6 +572,7 @@ class _SettingsScreenState extends State { Widget _buildDebugCard(BuildContext context) { final l10n = context.l10n; + final settingsService = context.watch(); return Card( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -597,6 +599,38 @@ class _SettingsScreenState extends State { }, ), const Divider(height: 1), + SwitchListTile( + secondary: const Icon(Icons.bug_report_outlined), + title: Text(l10n.appSettings_appDebugLogging), + subtitle: Text(l10n.appSettings_appDebugLoggingSubtitle), + value: settingsService.settings.appDebugLogEnabled, + onChanged: (value) async { + try { + await settingsService.setAppDebugLogEnabled(value); + } catch (_) { + if (context.mounted) { + showDismissibleSnackBar( + context, + content: const Text( + 'Could not change debug logging. Please try again.', + ), + ); + } + return; + } + if (!context.mounted) return; + showDismissibleSnackBar( + context, + content: Text( + value + ? l10n.appSettings_appDebugLoggingEnabled + : l10n.appSettings_appDebugLoggingDisabled, + ), + duration: const Duration(seconds: 2), + ); + }, + ), + const Divider(height: 1), ListTile( leading: const Icon(Icons.code_outlined), title: Text(l10n.settings_appDebugLog),