From e0b2a6a19c4218c4c2a4f08ac78e8cf9029b6bea Mon Sep 17 00:00:00 2001 From: Ryan Brown Date: Sat, 9 May 2026 22:34:04 +0000 Subject: [PATCH] Update and confirm english localizations. --- lib/localizations/en.json | 7 +++- .../sections/keep_screen_awake_section.dart | 39 +++++++++++++++---- lib/widgets/map_view.dart | 2 +- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/lib/localizations/en.json b/lib/localizations/en.json index b8d9ce6..423a52c 100644 --- a/lib/localizations/en.json +++ b/lib/localizations/en.json @@ -111,7 +111,12 @@ "advancedSettings": "Advanced Settings", "advancedSettingsSubtitle": "Performance, alerts, and tile provider settings", "proximityAlerts": "Proximity Alerts", - "networkStatusIndicator": "Network Status Indicator" + "networkStatusIndicator": "Network Status Indicator", + "keepScreenAwake": "Keep Screen Awake" + }, + "keepScreenAwake": { + "title": "Keep screen awake while using app", + "subtitle": "Prevents the screen from turning off automatically while using the app" }, "proximityAlerts": { "getNotified": "Get notified when approaching surveillance devices", diff --git a/lib/screens/settings/sections/keep_screen_awake_section.dart b/lib/screens/settings/sections/keep_screen_awake_section.dart index 5bb0ffe..9eec268 100644 --- a/lib/screens/settings/sections/keep_screen_awake_section.dart +++ b/lib/screens/settings/sections/keep_screen_awake_section.dart @@ -1,20 +1,45 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../app_state.dart'; +import '../../../services/localization_service.dart'; class KeepScreenAwakeSection extends StatelessWidget { const KeepScreenAwakeSection({super.key}); @override Widget build(BuildContext context) { - final appState = context.watch(); + // Standard Pattern: Use AnimatedBuilder to respond to language/localization changes + return AnimatedBuilder( + animation: LocalizationService.instance, + builder: (context, child) { + final locService = LocalizationService.instance; + final appState = context.watch(); - return SwitchListTile( - title: const Text('Keep screen awake while using app'), - subtitle: const Text('Prevents the screen from turning off automatically while using the app'), - value: appState.keepScreenAwake, - onChanged: (bool value) { - appState.setKeepScreenAwake(value); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Bold Section Header (matches Max Nodes, Proximity, etc.) + Text( + locService.t('settings.keepScreenAwake'), + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 8), + + // The Functional Toggle + SwitchListTile( + contentPadding: EdgeInsets.zero, // Aligns switch text with the bold header + title: Text(locService.t('keepScreenAwake.title')), + subtitle: Text( + locService.t('keepScreenAwake.subtitle'), + style: const TextStyle(fontSize: 12), + ), + value: appState.keepScreenAwake, + onChanged: (bool value) { + appState.setKeepScreenAwake(value); + }, + ), + ], + ); }, ); } diff --git a/lib/widgets/map_view.dart b/lib/widgets/map_view.dart index 65ad200..2f2e015 100644 --- a/lib/widgets/map_view.dart +++ b/lib/widgets/map_view.dart @@ -293,7 +293,7 @@ class MapViewState extends State { final session = appState.session; final editSession = appState.editSession; - // Call the safe tracker using appState instead + // Keep screen awake based on user setting _updateWakelock(appState.keepScreenAwake); // Check if enabled profiles changed and refresh nodes if needed