Új térkép widget, melyet több oldal is használ
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map_polywidget/flutter_map_polywidget.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/views/settings_dialog.dart';
|
||||
import 'package:terepi_seged/utils/rive_utils.dart';
|
||||
import 'package:terepi_seged/widgets/coordinate_panel.dart';
|
||||
import 'package:terepi_seged/widgets/save_point_fab.dart';
|
||||
import 'package:terepi_seged/widgets/shared_map_widgets.dart';
|
||||
|
||||
import 'map_add_point_dialog.dart';
|
||||
|
||||
class MapSurveyView extends GetView<MapSurveyController> {
|
||||
const MapSurveyView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(children: [
|
||||
const SharedMapWidget(),
|
||||
Positioned(
|
||||
top: 8,
|
||||
right: 8,
|
||||
left: 8,
|
||||
child: CoordinatePanel.fromController(controller),
|
||||
),
|
||||
Positioned(top: 8, left: 0, right: 0, child: _ModeSelector()),
|
||||
Positioned(
|
||||
bottom: 80,
|
||||
left: 8,
|
||||
right: 8,
|
||||
child: Obx(
|
||||
() => controller.mode.value == MapSurveyMode.stakeout
|
||||
? _StakeoutPanel() // ΔY, ΔX, távolság, irányszög
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 16,
|
||||
right: 16,
|
||||
child: SavePointFab(controller: controller),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
class _ModeSelector extends GetView<MapSurveyController> {
|
||||
const _ModeSelector();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(() => SegmentedButton<MapSurveyMode>(
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: MapSurveyMode.measure,
|
||||
icon: Icon(Icons.gps_fixed, size: 16),
|
||||
label: Text('Bemérés'),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: MapSurveyMode.stakeout,
|
||||
icon: Icon(Icons.my_location, size: 16),
|
||||
label: Text('Kitűzés'),
|
||||
),
|
||||
],
|
||||
selected: {controller.mode.value},
|
||||
onSelectionChanged: (s) => controller.switchMode(s.first),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class _StakeoutPanel extends GetView<MapSurveyController> {
|
||||
const _StakeoutPanel();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Obx(() {
|
||||
final onTarget = controller.isOnTarget;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Célpont neve
|
||||
Row(children: [
|
||||
const Icon(Icons.flag, size: 16, color: Colors.orange),
|
||||
const SizedBox(width: 6),
|
||||
Text(controller.targetName.value,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||
const Spacer(),
|
||||
TextButton(
|
||||
onPressed: _showTargetPicker,
|
||||
child: const Text('Változtat'),
|
||||
),
|
||||
]),
|
||||
|
||||
const Divider(height: 16),
|
||||
|
||||
// Eltérések
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_DeltaCell(
|
||||
label: 'ΔY',
|
||||
value: controller.deltaY,
|
||||
unit: 'm',
|
||||
),
|
||||
_DeltaCell(
|
||||
label: 'ΔX',
|
||||
value: controller.deltaX,
|
||||
unit: 'm',
|
||||
),
|
||||
_DeltaCell(
|
||||
label: 'Táv',
|
||||
value: controller.distanceToTarget,
|
||||
unit: 'm',
|
||||
alwaysPositive: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Státusz
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: onTarget
|
||||
? Colors.green.withOpacity(0.12)
|
||||
: Colors.orange.withOpacity(0.12),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
onTarget
|
||||
? '✓ Célponton — pont rögzíthető'
|
||||
: '${controller.distanceToTarget.toStringAsFixed(3)} m a céltól',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: onTarget ? Colors.green : Colors.orange,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showTargetPicker() {
|
||||
// Lista a korábban bemért vagy tervezett pontokból
|
||||
//Get.bottomSheet(const _TargetPickerSheet());
|
||||
}
|
||||
}
|
||||
|
||||
class _DeltaCell extends StatelessWidget {
|
||||
final String label;
|
||||
final double value;
|
||||
final String unit;
|
||||
final bool alwaysPositive;
|
||||
|
||||
const _DeltaCell({
|
||||
required this.label,
|
||||
required this.value,
|
||||
required this.unit,
|
||||
this.alwaysPositive = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final display = alwaysPositive ? value.abs() : value;
|
||||
final prefix = (!alwaysPositive && value > 0) ? '+' : '';
|
||||
final color = value.abs() < 0.05
|
||||
? Colors.green
|
||||
: value.abs() < 0.5
|
||||
? Colors.orange
|
||||
: Colors.red;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Text(label, style: const TextStyle(fontSize: 11, color: Colors.grey)),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'$prefix${display.toStringAsFixed(3)} $unit',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,423 +0,0 @@
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map_polywidget/flutter_map_polywidget.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/views/settings_dialog.dart';
|
||||
import 'package:terepi_seged/utils/rive_utils.dart';
|
||||
|
||||
import 'map_add_point_dialog.dart';
|
||||
|
||||
class MapSurveyView extends GetView<MapSurveyController> {
|
||||
const MapSurveyView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
late SMIBool gpsTrigger;
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
extendBody: true,
|
||||
appBar: AppBar(
|
||||
title: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Térkép'),
|
||||
Text(
|
||||
"",
|
||||
style: TextStyle(fontSize: 12.0),
|
||||
)
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: Obx(
|
||||
() => GestureDetector(
|
||||
onTap: () {
|
||||
if (controller.gpsIsConnected.value) {
|
||||
controller.disconnectFromGps();
|
||||
} else {
|
||||
controller.connectToGps();
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.gps_fixed,
|
||||
size: 26.0,
|
||||
color: controller.gpsIsConnected.value
|
||||
? Colors.green
|
||||
: Colors.red),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: Obx(
|
||||
() => GestureDetector(
|
||||
onTap: () {
|
||||
if (controller.ntripIsConnected.value) {
|
||||
controller.disconnectFromNtripServer();
|
||||
} else {
|
||||
controller.connectToNtripServer();
|
||||
}
|
||||
},
|
||||
child: Icon(
|
||||
Icons.assistant,
|
||||
size: 26.0,
|
||||
color: controller.ntripIsConnected.value
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (controller.ntripUserName.value.isNotEmpty) {
|
||||
controller.ntripUsernameController.text =
|
||||
controller.ntripUserName.value;
|
||||
}
|
||||
if (controller.ntripPassword.value.isNotEmpty) {
|
||||
controller.ntripPasswordController.text =
|
||||
controller.ntripPassword.value;
|
||||
}
|
||||
Get.to(() => SettingsDialog(), transition: Transition.downToUp);
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.more_vert,
|
||||
size: 26.0,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Obx(
|
||||
() => controller.gpsIsConnected.value
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 170.0,
|
||||
// height: 160.0,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 2.0,
|
||||
color: const Color.fromARGB(
|
||||
130, 255, 255, 255)),
|
||||
color:
|
||||
const Color.fromARGB(130, 255, 255, 255)),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${controller.gpsDateTime} (UTC)",
|
||||
style: const TextStyle(fontSize: 10.0),
|
||||
),
|
||||
const Divider(
|
||||
height: 5.0,
|
||||
color: Colors.black,
|
||||
),
|
||||
Text(
|
||||
"EovX: ${controller.formatEov.format(controller.eov.value.Y)}"),
|
||||
Text(
|
||||
"EovY: ${controller.formatEov.format(controller.eov.value.X)}"),
|
||||
Text("Alt: ${controller.gpsAltitude} (m)"),
|
||||
const Divider(
|
||||
height: 5.0,
|
||||
color: Colors.black,
|
||||
),
|
||||
Text(
|
||||
"Hor. error: ${max(controller.gpsLatitudeError.value, controller.gpsLongitudeError.value)} (m)",
|
||||
style: const TextStyle(fontSize: 14.0),
|
||||
),
|
||||
Text(
|
||||
"Vert. error: ${controller.gpsAltitudeError} (m)",
|
||||
style: const TextStyle(fontSize: 14.0),
|
||||
),
|
||||
const Divider(
|
||||
height: 5.0,
|
||||
color: Colors.black,
|
||||
),
|
||||
Text(
|
||||
"GPS quality -> ${controller.getGpsQualityIndicator(quality: controller.gpsQuality.value)} ",
|
||||
style: const TextStyle(fontSize: 8.0),
|
||||
),
|
||||
controller.ntripIsConnected.value
|
||||
? Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Divider(
|
||||
height: 5.0,
|
||||
color: Colors.black,
|
||||
),
|
||||
Text(
|
||||
"Ntrip ${controller.ntripReceivedData} byte(s) (${controller.ntripDataPacketNumbers})",
|
||||
style:
|
||||
const TextStyle(fontSize: 10.0),
|
||||
),
|
||||
Text(
|
||||
"GGA last send: ${controller.ggaSendLastTimeStr} (${controller.ggaSenDataPacketNumber})",
|
||||
style:
|
||||
const TextStyle(fontSize: 10.0),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox(
|
||||
width: 0.0,
|
||||
height: 0.0,
|
||||
)
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Obx(
|
||||
() => controller.mapIsInitialized.value
|
||||
? FlutterMap(
|
||||
mapController: controller.mapController,
|
||||
options: MapOptions(
|
||||
initialCenter: LatLng(
|
||||
controller.currentLatitude.value,
|
||||
controller.currentLongitude.value),
|
||||
maxZoom: 25,
|
||||
initialZoom: controller.currentZoom.value,
|
||||
),
|
||||
children: [
|
||||
TileLayer(
|
||||
urlTemplate:
|
||||
'http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}',
|
||||
subdomains: const ['mt0', 'mt1', 'mt2', 'mt3'],
|
||||
maxNativeZoom: 18,
|
||||
// urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
// userAgentPackageName: 'hu.app_dev.terepi_seged',
|
||||
),
|
||||
MarkerLayer(
|
||||
markers: controller.pointNotesMarker,
|
||||
),
|
||||
MarkerLayer(
|
||||
markers: controller.currentLocationMarker),
|
||||
// MarkerLayer(markers: controller.parser.markers),
|
||||
MarkerLayer(
|
||||
markers: controller.pointsToMeasureMarker),
|
||||
// PolylineLayer(
|
||||
// polylines: controller.parser.polylines),
|
||||
PolyWidgetLayer(
|
||||
polyWidgets: controller.pointsToMeasureLabel)
|
||||
],
|
||||
)
|
||||
: const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
// Obx(
|
||||
// () => controller.gpsIsConnected.value
|
||||
// ? Positioned(
|
||||
// left: 4.0,
|
||||
// top: 4.0,
|
||||
// child: Container(
|
||||
// width: 170.0,
|
||||
// // height: 160.0,
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(
|
||||
// width: 2.0,
|
||||
// color: const Color.fromARGB(
|
||||
// 130, 255, 255, 255)),
|
||||
// color:
|
||||
// const Color.fromARGB(130, 255, 255, 255)),
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// "${controller.gpsDateTime} (UTC)",
|
||||
// style: const TextStyle(fontSize: 10.0),
|
||||
// ),
|
||||
// const Divider(
|
||||
// height: 5.0,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// Text(
|
||||
// "EovX: ${controller.formatEov.format(controller.eov.value.Y)}"),
|
||||
// Text(
|
||||
// "EovY: ${controller.formatEov.format(controller.eov.value.X)}"),
|
||||
// Text("Alt: ${controller.gpsAltitude} (m)"),
|
||||
// const Divider(
|
||||
// height: 5.0,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// Text(
|
||||
// "Hor. error: ${max(controller.gpsLatitudeError.value, controller.gpsLongitudeError.value)} (m)",
|
||||
// style: const TextStyle(fontSize: 14.0),
|
||||
// ),
|
||||
// Text(
|
||||
// "Vert. error: ${controller.gpsAltitudeError} (m)",
|
||||
// style: const TextStyle(fontSize: 14.0),
|
||||
// ),
|
||||
// const Divider(
|
||||
// height: 5.0,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// Text(
|
||||
// "GPS quality -> ${controller.getGpsQualityIndicator(quality: controller.gpsQuality.value)} ",
|
||||
// style: const TextStyle(fontSize: 8.0),
|
||||
// ),
|
||||
// controller.ntripIsConnected.value
|
||||
// ? Column(
|
||||
// crossAxisAlignment:
|
||||
// CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// const Divider(
|
||||
// height: 5.0,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// Text(
|
||||
// "Ntrip ${controller.ntripReceivedData} byte(s) (${controller.ntripDataPacketNumbers})",
|
||||
// style: const TextStyle(
|
||||
// fontSize: 10.0),
|
||||
// ),
|
||||
// Text(
|
||||
// "GGA last send: ${controller.ggaSendLastTimeStr} (${controller.ggaSenDataPacketNumber})",
|
||||
// style: const TextStyle(
|
||||
// fontSize: 10.0),
|
||||
// ),
|
||||
// ],
|
||||
// )
|
||||
// : const SizedBox(
|
||||
// width: 0.0,
|
||||
// height: 0.0,
|
||||
// )
|
||||
// ],
|
||||
// )),
|
||||
// )
|
||||
// : const Positioned(
|
||||
// child: SizedBox(
|
||||
// width: 0.0,
|
||||
// height: 0.0,
|
||||
// )),
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// bottomNavigationBar: Container(
|
||||
// padding: const EdgeInsets.all(12),
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 24),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.black.withOpacity(0.5),
|
||||
// borderRadius: const BorderRadius.all(Radius.circular(24))),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// GestureDetector(
|
||||
// onTap: () {
|
||||
// gpsTrigger.change(true);
|
||||
// Future.delayed(const Duration(seconds: 1), () {
|
||||
// gpsTrigger.change(false);
|
||||
// });
|
||||
// // controller.onBottomNavigationBarTap(0);
|
||||
// Get.to(() => const MapAddPointDialog(),
|
||||
// fullscreenDialog: true,
|
||||
// transition: Transition.downToUp,
|
||||
// duration: const Duration(milliseconds: 600));
|
||||
// },
|
||||
// child: SizedBox(
|
||||
// height: 36,
|
||||
// width: 36,
|
||||
// child: RiveAnimation.asset(
|
||||
// "assets/RiveAssets/travel_icons_pack.riv",
|
||||
// artboard: "GPS", onInit: (artboard) {
|
||||
// StateMachineController controllerRive =
|
||||
// RiveUtils.getRiveController(artboard,
|
||||
// stateMachineName: "gps_interactivity");
|
||||
// gpsTrigger = controllerRive.findSMI("active") as SMIBool;
|
||||
// }),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
|
||||
floatingActionButton: Wrap(
|
||||
direction: Axis.horizontal,
|
||||
children: [
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
controller.mapZoomOut();
|
||||
},
|
||||
heroTag: 'ZoomOut',
|
||||
tooltip: 'Zoom out',
|
||||
child: const Icon(Icons.remove_circle_outline_rounded),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
controller.mapZoomIn();
|
||||
},
|
||||
heroTag: 'ZoomIn',
|
||||
tooltip: 'Zoom in',
|
||||
child: const Icon(Icons.add_circle_outline_rounded),
|
||||
),
|
||||
const SizedBox(width: 15.0),
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
// controller.isMapMoveToCenter();
|
||||
controller.setIsMapMoveToCenter();
|
||||
},
|
||||
heroTag: 'Center map',
|
||||
tooltip: 'Center map',
|
||||
child: Obx(
|
||||
() => Icon(Icons.center_focus_strong,
|
||||
color: controller.isMapMoveToCenter.value
|
||||
? Colors.green
|
||||
: Colors.red),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15.0,
|
||||
),
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
// controller.addMeasuredPoint();
|
||||
// controller.onBottomNavigationBarTap(0);
|
||||
controller.showAddPointDialog();
|
||||
},
|
||||
heroTag: 'Pont bemérése',
|
||||
tooltip: 'Pont bemérése',
|
||||
child: const Icon(Icons.flag_sharp),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15.0,
|
||||
),
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
// controller.isMapMoveToCenter();
|
||||
controller.showMeasuredPointsTableDialog();
|
||||
},
|
||||
heroTag: 'Database test',
|
||||
tooltip: 'Pont bemérése',
|
||||
child: const Icon(Icons.dataset),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user