mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-10-12 02:37:11 +02:00
fix gps on android
This commit is contained in:
1 parent
2d0dc7fd66
commit
24b20e8a57
2 files changed
+7
-11
No files matched your search
@@ -93,7 +93,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
icon: Icon(_getFollowMeIcon()),
|
icon: Icon(_getFollowMeIcon()),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
final oldMode = _followMeMode;
|
||||||
_followMeMode = _getNextFollowMeMode();
|
_followMeMode = _getNextFollowMeMode();
|
||||||
|
debugPrint('[HomeScreen] Follow mode changed: $oldMode → $_followMeMode');
|
||||||
});
|
});
|
||||||
// If enabling follow-me, retry location init in case permission was granted
|
// If enabling follow-me, retry location init in case permission was granted
|
||||||
if (_followMeMode != FollowMeMode.off) {
|
if (_followMeMode != FollowMeMode.off) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import 'map/direction_cones.dart';
|
|||||||
import 'map/map_overlays.dart';
|
import 'map/map_overlays.dart';
|
||||||
import 'network_status_indicator.dart';
|
import 'network_status_indicator.dart';
|
||||||
import '../dev_config.dart';
|
import '../dev_config.dart';
|
||||||
|
|
||||||
import '../screens/home_screen.dart' show FollowMeMode;
|
import '../screens/home_screen.dart' show FollowMeMode;
|
||||||
|
|
||||||
class MapView extends StatefulWidget {
|
class MapView extends StatefulWidget {
|
||||||
@@ -137,14 +136,15 @@ class MapViewState extends State<MapView> {
|
|||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant MapView oldWidget) {
|
void didUpdateWidget(covariant MapView oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
|
// Back to original pattern - simple check
|
||||||
if (widget.followMeMode != FollowMeMode.off &&
|
if (widget.followMeMode != FollowMeMode.off &&
|
||||||
oldWidget.followMeMode == FollowMeMode.off &&
|
oldWidget.followMeMode == FollowMeMode.off &&
|
||||||
_currentLatLng != null) {
|
_currentLatLng != null) {
|
||||||
// Use smooth animation when follow me is first enabled
|
// Move to current location when follow me is first enabled
|
||||||
if (widget.followMeMode == FollowMeMode.northUp) {
|
if (widget.followMeMode == FollowMeMode.northUp) {
|
||||||
_controller.move(_currentLatLng!, _controller.camera.zoom);
|
_controller.move(_currentLatLng!, _controller.camera.zoom);
|
||||||
} else if (widget.followMeMode == FollowMeMode.rotating) {
|
} else if (widget.followMeMode == FollowMeMode.rotating) {
|
||||||
// When switching to rotating mode, reset to north-up first, then let GPS handle rotation
|
// When switching to rotating mode, reset to north-up first
|
||||||
_controller.moveAndRotate(_currentLatLng!, _controller.camera.zoom, 0.0);
|
_controller.moveAndRotate(_currentLatLng!, _controller.camera.zoom, 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,18 +155,12 @@ class MapViewState extends State<MapView> {
|
|||||||
if (perm == LocationPermission.denied ||
|
if (perm == LocationPermission.denied ||
|
||||||
perm == LocationPermission.deniedForever) return;
|
perm == LocationPermission.deniedForever) return;
|
||||||
|
|
||||||
// Configure location settings for smoother tracking
|
|
||||||
const locationSettings = LocationSettings(
|
|
||||||
accuracy: LocationAccuracy.high,
|
|
||||||
distanceFilter: 1, // Update every 1 meter
|
|
||||||
timeLimit: Duration(seconds: 2), // Max 2 seconds between updates
|
|
||||||
);
|
|
||||||
|
|
||||||
_positionSub =
|
_positionSub =
|
||||||
Geolocator.getPositionStream(locationSettings: locationSettings).listen((Position position) {
|
Geolocator.getPositionStream().listen((Position position) {
|
||||||
final latLng = LatLng(position.latitude, position.longitude);
|
final latLng = LatLng(position.latitude, position.longitude);
|
||||||
setState(() => _currentLatLng = latLng);
|
setState(() => _currentLatLng = latLng);
|
||||||
|
|
||||||
|
// Back to original pattern - directly check widget parameter
|
||||||
if (widget.followMeMode != FollowMeMode.off) {
|
if (widget.followMeMode != FollowMeMode.off) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
|||||||
Reference in new issue
Block a user