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 9edae89..820c334 100644 --- a/lib/pages/map_survey/presentations/controllers/map_survey_controller.dart +++ b/lib/pages/map_survey/presentations/controllers/map_survey_controller.dart @@ -29,6 +29,7 @@ import 'package:terepi_seged/models/point_to_measure.dart'; import 'package:terepi_seged/models/point_with_description_model.dart'; import 'package:proj4dart/proj4dart.dart' as proj4; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:terepi_seged/pages/map_survey/presentations/views/measured_points_table_dialog.dart'; class MapSurveyController extends GetxController { // String gpsAddress = "E8:31:CD:14:8B:B2"; @@ -59,6 +60,8 @@ class MapSurveyController extends GetxController { DateTime.now().add(const Duration(seconds: -30)); NumberFormat formatEov = NumberFormat("##0,000.0", "hu-HU"); + NumberFormat formatEovZ = NumberFormat("###0.0", "hu-HU"); + NumberFormat formatAltitudeError = NumberFormat("####0.000", "hu-HU"); NumberFormat formatEovForFile = NumberFormat("#####0.0", "hu-HU"); NumberFormat formatWgs84Sec = NumberFormat('00.000', 'hu-HU'); @@ -111,6 +114,8 @@ class MapSurveyController extends GetxController { Rx isShowPassword = false.obs; final passwordFieldFocusNode = FocusNode(); + List? measuredPoints; + List pointWithDescriptionList = []; late Directory? directory; late File dataFile; @@ -786,7 +791,9 @@ class MapSurveyController extends GetxController { 'horizontalError': max(gpsLatitudeError.value, gpsLongitudeError.value), 'verticalError': gpsAltitudeError.value, - 'description': pointDescriptionController.text + 'description': pointDescriptionController.text, + 'isDeleted': false, + 'projectId': 2 }); await Supabase.instance.client @@ -850,4 +857,20 @@ class MapSurveyController extends GetxController { if (passwordFieldFocusNode.hasPrimaryFocus) return; passwordFieldFocusNode.canRequestFocus = false; } + + void showMeasuredPointsTableDialog() { + Get.to(() => MeasuredPointsTableDialog(), transition: Transition.fadeIn); + } + + Future readMeasuredPoints() async { + var response = await Supabase.instance.client + .from('TerepiSeged_MeasuredPoints') + .select() + .eq('projectId', 2) + .order('created_at'); + + print(response); + + return response; + } } diff --git a/lib/pages/map_survey/presentations/views/mapsurvey_view.dart b/lib/pages/map_survey/presentations/views/mapsurvey_view.dart index 06ff303..ebb182c 100644 --- a/lib/pages/map_survey/presentations/views/mapsurvey_view.dart +++ b/lib/pages/map_survey/presentations/views/mapsurvey_view.dart @@ -410,14 +410,7 @@ class MapSurveyView extends GetView { FloatingActionButton( onPressed: () { // controller.isMapMoveToCenter(); - // controller.addMeasuredPoint(); - ScaffoldMessenger.of(context).showSnackBar(const SnackBar( - content: Text( - "Fejlesztlés alatt", - style: TextStyle(fontWeight: FontWeight.bold), - ), - backgroundColor: Colors.black54, - )); + controller.showMeasuredPointsTableDialog(); }, heroTag: 'Database test', tooltip: 'Pont bemérése', diff --git a/lib/pages/map_survey/presentations/views/measured_points_table_dialog.dart b/lib/pages/map_survey/presentations/views/measured_points_table_dialog.dart new file mode 100644 index 0000000..748f94b --- /dev/null +++ b/lib/pages/map_survey/presentations/views/measured_points_table_dialog.dart @@ -0,0 +1,114 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart'; + +class MeasuredPointsTableDialog extends StatelessWidget { + final controller = Get.find(); + MeasuredPointsTableDialog({super.key}); + + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.only(top: 20.0), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () { + Get.back(); + }, + icon: const Icon(Icons.close)), + TextButton( + style: ButtonStyle( + overlayColor: + MaterialStateProperty.all(Colors.transparent)), + onPressed: () { + Get.back(); + }, + child: const Text( + 'Bezár', + style: TextStyle(color: Colors.blue, fontSize: 14.0), + )) + ], + ), + ), + const Padding( + padding: EdgeInsets.symmetric(horizontal: 40.0), + child: Text( + 'Bemért pontok', + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), + ), + ), + const SizedBox(height: 5), + Expanded( + child: FutureBuilder>( + future: controller.readMeasuredPoints(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center(child: CircularProgressIndicator()); + } + + if (snapshot.hasError) { + return Center( + child: Text( + snapshot.error.toString(), + ), + ); + } + if (!snapshot.hasData) { + return const Center( + child: Text("No Data available.\n Create new Data")); + } + // print(snapshot.data); + // return const Center(child: Text("Data available.")); + return ListView.builder( + itemCount: snapshot.data!.length, + shrinkWrap: true, + itemBuilder: (context, int index) { + var data = snapshot.data![index]; + print("snapshot data:"); + print(data); + return ListTile( + leading: CircleAvatar( + backgroundColor: const Color(0xff764abc), + child: Text((index + 1).toString())), + title: Text(data['pointNumber'].toString(), + style: TextStyle(fontWeight: FontWeight.bold)), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(data['description'], + style: TextStyle( + fontStyle: FontStyle.italic, + color: Colors.grey.shade700)), + Text( + "EovX: ${controller.formatEov.format(data['eovY'])} - EovY: ${controller.formatEov.format(data['eovX'])}", + style: TextStyle( + fontStyle: FontStyle.italic, + color: Colors.grey.shade400)), + Text( + "EovZ: ${controller.formatEovZ.format(data['altitude'] - data['poleHeight'])} (m)", + style: TextStyle( + fontStyle: FontStyle.italic, + color: Colors.grey.shade400)), + Text( + "H.hiba: ${controller.formatAltitudeError.format(data['horizontalError'])} (m) - V.hiba: ${controller.formatAltitudeError.format(data['verticalError'])} (m)", + style: TextStyle( + fontStyle: FontStyle.italic, + color: Colors.grey.shade400)), + ], + )); + }); + }, + ), + ) + ], + ), + ), + ); + } +}