feat: Add RX/TX indicators preference with toggle in settings

This commit is contained in:
Janez T
2025-10-16 14:25:15 +02:00
parent 9c1922b4fd
commit 9ab5469759
2 changed files with 133 additions and 83 deletions

View File

@@ -29,6 +29,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
late AppThemeMode _selectedTheme;
PackageInfo? _packageInfo;
bool _isLoadingSampleData = false;
bool _showRxTxIndicators = true;
final LocationTrackingService _locationService = LocationTrackingService();
@override
@@ -37,6 +38,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_selectedTheme = widget.currentTheme;
_loadPackageInfo();
_initializeLocationService();
_loadRxTxPreference();
}
Future<void> _loadPackageInfo() async {
@@ -48,6 +50,20 @@ class _SettingsScreenState extends State<SettingsScreen> {
}
}
Future<void> _loadRxTxPreference() async {
final prefs = await SharedPreferences.getInstance();
if (mounted) {
setState(() {
_showRxTxIndicators = prefs.getBool('show_rx_tx_indicators') ?? true;
});
}
}
Future<void> _saveRxTxPreference(bool value) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('show_rx_tx_indicators', value);
}
Future<void> _initializeLocationService() async {
// Initialize location service with BLE service
WidgetsBinding.instance.addPostFrameCallback((_) async {
@@ -294,6 +310,18 @@ class _SettingsScreenState extends State<SettingsScreen> {
trailing: const Icon(Icons.chevron_right),
onTap: () => _showThemeDialog(),
),
SwitchListTile(
secondary: const Icon(Icons.radar),
title: const Text('Show RX/TX Indicators'),
subtitle: const Text('Display packet activity indicators in top bar'),
value: _showRxTxIndicators,
onChanged: (value) async {
setState(() {
_showRxTxIndicators = value;
});
await _saveRxTxPreference(value);
},
),
const Divider(),
// Location Settings Section