mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-14 15:10:36 +02:00
Feature: Keep screen on while using app. Initial working.
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_animations/flutter_map_animations.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
|
||||
import '../app_state.dart' show AppState, FollowMeMode;
|
||||
import '../services/offline_area_service.dart';
|
||||
@@ -84,7 +85,20 @@ class MapViewState extends State<MapView> {
|
||||
// Track active pointers to suppress follow-me animations during touch
|
||||
int _activePointers = 0;
|
||||
|
||||
bool _isWakelockEnabled = false;
|
||||
|
||||
void _updateWakelock(bool shouldBeAwake) {
|
||||
if (_isWakelockEnabled != shouldBeAwake) {
|
||||
_isWakelockEnabled = shouldBeAwake;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (shouldBeAwake) {
|
||||
WakelockPlus.enable();
|
||||
} else {
|
||||
WakelockPlus.disable();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -213,6 +227,7 @@ class MapViewState extends State<MapView> {
|
||||
_nodeController.dispose();
|
||||
_tileManager.dispose();
|
||||
_gpsController.dispose();
|
||||
WakelockPlus.disable();
|
||||
// PrefetchAreaService no longer used - replaced with NodeDataManager
|
||||
super.dispose();
|
||||
}
|
||||
@@ -278,6 +293,9 @@ class MapViewState extends State<MapView> {
|
||||
final session = appState.session;
|
||||
final editSession = appState.editSession;
|
||||
|
||||
// Call the safe tracker using appState instead
|
||||
_updateWakelock(appState.keepScreenAwake);
|
||||
|
||||
// Check if enabled profiles changed and refresh nodes if needed
|
||||
_nodeController.checkAndHandleProfileChanges(
|
||||
currentEnabledProfiles: appState.enabledProfiles,
|
||||
|
||||
Reference in New Issue
Block a user