mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-13 01:10:28 +00:00
feat: Add setting to disable map tab for battery savings
Add a new "Disable Map" toggle in settings that allows users to hide the map tab entirely. This is useful for scenarios where the map is not needed and battery conservation is a priority. Changes: - Add disableMap and disableMapDescription localized strings (all languages) - Add isMapEnabled state to AppProvider with persistence - Update HomeScreen to dynamically adjust tab count based on setting - Make onNavigateToMap optional in MessagesTab and ContactsTab - Add toggle switch in Settings screen under Interface section
This commit is contained in:
@@ -28,6 +28,9 @@ class AppProvider with ChangeNotifier {
|
||||
bool _isSimpleMode = true;
|
||||
bool get isSimpleMode => _isSimpleMode;
|
||||
|
||||
bool _isMapEnabled = true;
|
||||
bool get isMapEnabled => _isMapEnabled;
|
||||
|
||||
AppProvider({
|
||||
required this.connectionProvider,
|
||||
required this.contactsProvider,
|
||||
@@ -40,6 +43,7 @@ class AppProvider with ChangeNotifier {
|
||||
_initializeTileCache();
|
||||
_initializeLocationTracking();
|
||||
_loadSimpleMode();
|
||||
_loadMapEnabled();
|
||||
_syncDrawingsOnStartup(); // Sync drawings immediately after providers load
|
||||
_isInitialized = true;
|
||||
}
|
||||
@@ -84,6 +88,29 @@ class AppProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// Load map enabled setting from shared preferences
|
||||
Future<void> _loadMapEnabled() async {
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_isMapEnabled = prefs.getBool('map_enabled') ?? true;
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
debugPrint('Error loading map enabled setting: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/// Toggle map on/off
|
||||
Future<void> toggleMapEnabled(bool enabled) async {
|
||||
try {
|
||||
_isMapEnabled = enabled;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('map_enabled', enabled);
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
debugPrint('Error saving map enabled setting: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize tile cache service
|
||||
Future<void> _initializeTileCache() async {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user