From 026d7799f97a5a4896ca5fa0f2ea3a01c60af459 Mon Sep 17 00:00:00 2001 From: "torok.istvan" Date: Sun, 21 Jun 2026 12:57:17 +0200 Subject: [PATCH] =?UTF-8?q?Bej=C3=A1r=C3=A1s=20m=C3=B3d:=20pont=20le=C3=AD?= =?UTF-8?q?r=C3=A1s=20ment=C3=A9se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/map_survey_controller.dart | 49 +++++++++++++++++++ .../presentations/views/map_survey_view.dart | 3 +- .../map_edit_point_drawing_content.dart | 30 +++++++----- 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/lib/pages/map_survey/presentations/controllers/map_survey_controller.dart b/lib/pages/map_survey/presentations/controllers/map_survey_controller.dart index ad3e647..a420b51 100644 --- a/lib/pages/map_survey/presentations/controllers/map_survey_controller.dart +++ b/lib/pages/map_survey/presentations/controllers/map_survey_controller.dart @@ -1787,4 +1787,53 @@ class MapSurveyController extends GetxController { ignoreSafeArea: false, ); } + + // ----- Terepbejárás pont mentése + void showSavePointDialog({required LatLng point}) { + final labelCtrl = TextEditingController(); + + Get.dialog( + AlertDialog( + title: const Text('Pont mentése'), + content: TextField( + controller: labelCtrl, + autofocus: true, + decoration: const InputDecoration( + hintText: 'Pont neve (opcionális)', + border: OutlineInputBorder(), + ), + textCapitalization: TextCapitalization.sentences, + onSubmitted: (_) => _doSavePoint(point, labelCtrl.text), + ), + actions: [ + TextButton( + onPressed: Get.back, + child: const Text('Mégse'), + ), + FilledButton( + onPressed: () => _doSavePoint(point, labelCtrl.text), + child: const Text('Mentés'), + ), + ], + ), + barrierDismissible: false, + ); + } + + void _doSavePoint(LatLng point, String label) { + activeEditLabel.value = label.trim(); + Get.back(); + saveEditedPoint(point: point); + } + + void savePointFromCurrentPosition() { + final lat = currentLatitude.value; + final lon = currentLongitude.value; + if (lat == 0.0 && lon == 0.0) { + Get.snackbar('Hiba', 'GPS pozíció nem elérhető', + snackPosition: SnackPosition.BOTTOM); + return; + } + showSavePointDialog(point: LatLng(lat, lon)); + } } diff --git a/lib/pages/map_survey/presentations/views/map_survey_view.dart b/lib/pages/map_survey/presentations/views/map_survey_view.dart index 753ff4b..38458d9 100644 --- a/lib/pages/map_survey/presentations/views/map_survey_view.dart +++ b/lib/pages/map_survey/presentations/views/map_survey_view.dart @@ -51,7 +51,8 @@ class MapSurveyView extends GetView { onCenterOnGps: controller.setIsMapMoveToCenter, onLongPress: (tapPosition, point) { if (controller.activeEditTool.value == MapEditTool.point) { - controller.saveEditedPoint(point: point); + //controller.saveEditedPoint(point: point); + controller.showSavePointDialog(point: point); } if (controller.activeEditTool.value == MapEditTool.line || controller.activeEditTool.value == MapEditTool.polygon) { diff --git a/lib/widgets/map_edit_tools/map_edit_point_drawing_content.dart b/lib/widgets/map_edit_tools/map_edit_point_drawing_content.dart index ba5c00c..7f5ee23 100644 --- a/lib/widgets/map_edit_tools/map_edit_point_drawing_content.dart +++ b/lib/widgets/map_edit_tools/map_edit_point_drawing_content.dart @@ -1,6 +1,9 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart'; +import 'package:terepi_seged/services/gnss/gnss_connection.dart'; +import 'package:terepi_seged/services/gnss/gnss_device_service.dart'; +import 'package:terepi_seged/services/gnss/gnss_service.dart'; import 'map_edit_small_status_chip.dart'; @@ -78,22 +81,25 @@ class PointDrawingContent extends StatelessWidget { Expanded( child: OutlinedButton.icon( //onPressed: controller.addPointFromCurrentPosition, - onPressed: () {}, + onPressed: GnssService.to.connectionState.value == + GnssConnectionState.connected + ? controller.savePointFromCurrentPosition + : null, icon: const Icon(Icons.my_location, size: 18), label: const Text('Saját hely'), ), ), - const SizedBox(width: 8), - Expanded( - child: FilledButton.icon( - // onPressed: controller.canFinishGeometry - // ? controller.finishGeometry - // : null, - onPressed: () {}, - icon: const Icon(Icons.check, size: 18), - label: const Text('Kész'), - ), - ), + // const SizedBox(width: 8), + // Expanded( + // child: FilledButton.icon( + // // onPressed: controller.canFinishGeometry + // // ? controller.finishGeometry + // // : null, + // onPressed: () {}, + // icon: const Icon(Icons.check, size: 18), + // label: const Text('Kész'), + // ), + // ), ], ), ],