feat: Add map navigation, enhance FCM deep linking, localize Google Places API, and refine activity display.
This commit is contained in:
@@ -6,6 +6,9 @@ import 'package:http/http.dart' as http;
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import '../../services/error_service.dart';
|
||||
import '../../services/map_navigation_service.dart';
|
||||
import '../../services/logger_service.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class MapContent extends StatefulWidget {
|
||||
final String? initialSearchQuery;
|
||||
@@ -33,8 +36,37 @@ class _MapContentState extends State<MapContent> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Si une recherche initiale est fournie, la pré-remplir et lancer la recherche
|
||||
if (widget.initialSearchQuery != null &&
|
||||
|
||||
final mapService = context.read<MapNavigationService>();
|
||||
|
||||
// Écouter les nouvelles demandes
|
||||
mapService.requestStream.listen((request) {
|
||||
LoggerService.info(
|
||||
'MapContent: Received navigation request: ${request.name}',
|
||||
);
|
||||
_handleNavigationRequest(request);
|
||||
});
|
||||
|
||||
// Vérifier s'il y a une demande de navigation en attente
|
||||
if (mapService.lastRequest != null) {
|
||||
LoggerService.info(
|
||||
'MapContent: Found pending navigation request: ${mapService.lastRequest!.name}',
|
||||
);
|
||||
// Handle synchronously for initial build
|
||||
final request = mapService.lastRequest!;
|
||||
final position = LatLng(request.latitude, request.longitude);
|
||||
_initialPosition = position;
|
||||
_markers.add(
|
||||
Marker(
|
||||
markerId: MarkerId(
|
||||
'nav_request_${request.timestamp.millisecondsSinceEpoch}',
|
||||
),
|
||||
position: position,
|
||||
infoWindow: InfoWindow(title: request.name ?? 'Lieu sélectionné'),
|
||||
),
|
||||
);
|
||||
// Ne pas lancer _getCurrentLocation() ici pour ne pas écraser la position
|
||||
} else if (widget.initialSearchQuery != null &&
|
||||
widget.initialSearchQuery!.isNotEmpty) {
|
||||
_searchController.text = widget.initialSearchQuery!;
|
||||
// Lancer la recherche automatiquement après un court délai pour laisser l'interface se charger
|
||||
@@ -47,6 +79,54 @@ class _MapContentState extends State<MapContent> {
|
||||
}
|
||||
}
|
||||
|
||||
void _handleNavigationRequest(MapLocationRequest request) {
|
||||
if (!mounted) return;
|
||||
|
||||
LoggerService.info(
|
||||
'MapContent: Handling navigation request to ${request.latitude}, ${request.longitude}',
|
||||
);
|
||||
final position = LatLng(request.latitude, request.longitude);
|
||||
|
||||
setState(() {
|
||||
// Garder le marqueur de position utilisateur
|
||||
_markers.removeWhere((m) => m.markerId.value != 'user_location');
|
||||
|
||||
// Ajouter le marqueur pour le lieu demandé
|
||||
_markers.add(
|
||||
Marker(
|
||||
markerId: MarkerId(
|
||||
'nav_request_${request.timestamp.millisecondsSinceEpoch}',
|
||||
),
|
||||
position: position,
|
||||
infoWindow: InfoWindow(title: request.name ?? 'Lieu sélectionné'),
|
||||
),
|
||||
);
|
||||
_isSearching = false;
|
||||
});
|
||||
|
||||
// Animer la caméra si le contrôleur est prêt
|
||||
if (_mapController != null) {
|
||||
LoggerService.info(
|
||||
'MapContent: Waiting for map to be visible before animating',
|
||||
);
|
||||
// Attendre un peu que l'onglet change et que la carte soit visible
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
if (mounted && _mapController != null) {
|
||||
LoggerService.info('MapContent: Animating camera to position');
|
||||
_mapController!.animateCamera(
|
||||
CameraUpdate.newLatLngZoom(position, 15),
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
LoggerService.info(
|
||||
'MapContent: MapController not ready, setting initial position',
|
||||
);
|
||||
// Si le contrôleur n'est pas encore prêt, définir la position initiale
|
||||
_initialPosition = position;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
|
||||
Reference in New Issue
Block a user