Navigációs képernyőn útvonal megjelenítése supabase táblából és navigációs képernyővel történő indítás beállítások alapján
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:terepi_seged/models/measure_source_point.dart';
|
||||
import 'package:terepi_seged/models/vibro_nav_route.dart';
|
||||
import 'package:terepi_seged/services/app_logger.dart';
|
||||
import 'package:terepi_seged/services/coord_converter_service.dart';
|
||||
import 'package:terepi_seged/services/gnss/gnss_connection.dart';
|
||||
@@ -16,6 +17,7 @@ import 'package:terepi_seged/services/gnss/phone_gps_connection.dart';
|
||||
import 'package:terepi_seged/services/measure_source_point_service.dart';
|
||||
import 'package:terepi_seged/services/project_service.dart';
|
||||
import 'package:terepi_seged/services/vechicle_identity_service.dart';
|
||||
import 'package:terepi_seged/services/vibro_nav_route_service.dart';
|
||||
|
||||
/// Forráspont + egyszer kiszámolt WGS84 pozíció. A térkép ebből rajzol,
|
||||
/// így GNSS-frissítéskor nincs újraszámolás.
|
||||
@@ -66,6 +68,9 @@ class VibroNavController extends GetxController {
|
||||
final Map<String, LatLng?> _geoCache = {};
|
||||
final isLoadingSourcePoints = false.obs;
|
||||
|
||||
final routes = <VibroNavRoute>[].obs;
|
||||
StreamSubscription<List<VibroNavRoute>>? _routesSub;
|
||||
|
||||
/// Ha false, a tartalék (plan_state = 0) pontok nem jelennek meg a
|
||||
/// térképen — csak a jelgerjesztés helyei (plan_state = 1) látszanak.
|
||||
final showReservePoints = false.obs;
|
||||
@@ -93,7 +98,11 @@ class VibroNavController extends GetxController {
|
||||
super.onInit();
|
||||
|
||||
watchSourcePoints();
|
||||
ever(ProjectService.to.activeProject, (_) => watchSourcePoints());
|
||||
watchRoutes();
|
||||
ever(ProjectService.to.activeProject, (_) {
|
||||
watchSourcePoints();
|
||||
watchRoutes();
|
||||
});
|
||||
|
||||
if (Get.isRegistered<GnssService>()) {
|
||||
_gnssUpdateSub =
|
||||
@@ -130,6 +139,7 @@ class VibroNavController extends GetxController {
|
||||
void onClose() {
|
||||
_gnssUpdateSub?.cancel();
|
||||
_sourcePointsSub?.cancel();
|
||||
_routesSub?.cancel();
|
||||
_externalUploadTimer?.cancel();
|
||||
_internalUploadTimer?.cancel();
|
||||
_internalPositionSub?.cancel();
|
||||
@@ -357,4 +367,26 @@ class VibroNavController extends GetxController {
|
||||
List<GeoSourcePoint> get visibleGeoSourcePoints => showReservePoints.value
|
||||
? geoSourcePoints
|
||||
: geoSourcePoints.where((g) => g.point.isShotLocation).toList();
|
||||
|
||||
void watchRoutes() {
|
||||
_routesSub?.cancel();
|
||||
final projectId = ProjectService.to.activeProject.value?.uuid;
|
||||
if (projectId == null) {
|
||||
routes.clear();
|
||||
return;
|
||||
}
|
||||
_routesSub = VibroNavRouteService.to.watchForToday(projectId).listen(
|
||||
(list) => routes.value = list,
|
||||
onError: (e) =>
|
||||
AppLogger.e('VibroNavController', 'Útvonal-stream hiba: $e'),
|
||||
);
|
||||
}
|
||||
|
||||
/// A térkép ezt rajzolja: a mai napra érvényes útvonalak közül azok,
|
||||
/// amelyek minden járműre szólnak, vagy erre a járműre. A járműváltásra
|
||||
/// azonnal reagál.
|
||||
List<VibroNavRoute> get visibleRoutes {
|
||||
final v = VehicleIdentityService.to.selectedVehicle.value;
|
||||
return routes.where((r) => r.vehicle == null || r.vehicle == v).toList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user