diff --git a/app/lib/data_classes.dart b/app/lib/data_classes.dart index e0466a012ea61cb635699ba03812e2558c79a9f2..dadf4356c21dc45a990d0a6414e0b57fc1d5e30d 100644 --- a/app/lib/data_classes.dart +++ b/app/lib/data_classes.dart @@ -1,6 +1,5 @@ import 'dart:core'; import 'package:latlong2/latlong.dart'; -import 'package:flutter/material.dart'; class Measurement { int measurementID; @@ -41,11 +40,21 @@ class Measurement { } } + Map<String, dynamic> toJson() { + return { + 'MeasurementID': measurementID, + 'TimeMeasured': timeMeasured.toIso8601String(), + 'Sensor': sensor.toJson(), + 'BodyOfWater': bodyOfWater, + 'CenterLat': center.latitude, + 'CenterLon': center.longitude, + 'Subdivisions': subDivs.map((subDiv) => subDiv.toJson()).toList(), + }; + } } class SubDiv { String sub_div_id; - int groupID; double minThickness; double avgThickness; LatLng center; @@ -55,7 +64,6 @@ class SubDiv { SubDiv({ required this.sub_div_id, - required this.groupID, required this.minThickness, required this.avgThickness, required this.center, @@ -68,7 +76,6 @@ class SubDiv { try { return SubDiv( sub_div_id: json['SubdivID'].toString(), - groupID: json['GroupID'] ?? 0, minThickness: (json['MinThickness'] as num?)?.toDouble() ?? 0, avgThickness: (json['AvgThickness'] as num?)?.toDouble() ?? 0, center: json['CenLatitude'] != null && json['CenLongitude'] != null @@ -85,6 +92,25 @@ class SubDiv { throw FormatException('Error parsing SubDiv: $e'); } } + + Map<String, dynamic> toJson() { + // Call the toJson method of every element in the list 'iceStats' + List<Map<String, dynamic>> iceStatsJSON = []; + for (var element in iceStats) { + iceStatsJSON.add(element.toJson()); + } + + return { + 'SubdivID': sub_div_id, + 'MinThickness': minThickness, + 'AvgThickness': avgThickness, + 'CenLatitude': center.latitude, + 'CenLongitude': center.longitude, + 'Accuracy': accuracy, + 'Color': color, + 'IceStats': iceStatsJSON, + }; + } } class IceStats { @@ -137,6 +163,19 @@ class IceStats { throw FormatException('Error parsing IceStats: $e'); } } + + Map<String, dynamic> toJson() { + return { + 'Date': dateTime.toIso8601String(), // Convert DateTime object to string + 'Slush ice (m)': slushIce, + 'Black ice (m)': blackIce, + 'Total ice (m)': totalIce, + 'Snow depth (m)': snowDepth, + 'Total snow (m)': totalSnow, + 'Cloud cover': cloudCover, + 'Temperature (t)': temperature, + }; + } } class Sensor { @@ -166,4 +205,12 @@ class Sensor { throw FormatException('Error parsing Sensor: $e'); } } + + Map<String, dynamic> toJson() { + return { + 'SensorID': sensorID, + 'SensorType': sensorType, + 'Active': active, + }; + } } diff --git a/app/lib/widgets/main_layout.dart b/app/lib/widgets/main_layout.dart index c534d57342bc7ba6fb846197f0a2e3e76f31f830..531469c4e272066918a9b0688a1e90e898740211 100644 --- a/app/lib/widgets/main_layout.dart +++ b/app/lib/widgets/main_layout.dart @@ -1,5 +1,7 @@ +import 'dart:convert'; import 'dart:typed_data'; import 'package:flutter/material.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -201,10 +203,14 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { backgroundColor: MaterialStateProperty.all<Color>(Colors.white24), ), child: const Text("Export JSON"), - onPressed: () { - // Close bottom sheet before displaying progress bar - showProgressIndicator(context); - + onPressed: () { // Export all measurements as JSON + List<Map<String, dynamic>> measurementsJSON = []; + // Convert every measurement to JSON + for (var element in selectedMeasurements) { + measurementsJSON.add(element.toJson()); + } + // Export the processed data + Share.share(selectedMeasurements.toString()); }, ) ], diff --git a/app/linux/flutter/generated_plugin_registrant.cc b/app/linux/flutter/generated_plugin_registrant.cc index e71a16d23d05881b554326e645083799ab9bfc5e..f6f23bfe970ffe22ab2e64b10b6ae24575915cda 100644 --- a/app/linux/flutter/generated_plugin_registrant.cc +++ b/app/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include <url_launcher_linux/url_launcher_plugin.h> void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/app/linux/flutter/generated_plugins.cmake b/app/linux/flutter/generated_plugins.cmake index 2e1de87a7eb61e17463f7406106f6c413533cecf..f16b4c34213acd9dbc719b4548786853e6e9503b 100644 --- a/app/linux/flutter/generated_plugins.cmake +++ b/app/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/app/macos/Flutter/GeneratedPluginRegistrant.swift b/app/macos/Flutter/GeneratedPluginRegistrant.swift index 37769918364446aa1f43f8b67f5daefcd48374aa..6a0d7b860a7ca4a184755a36b3c32f0800932471 100644 --- a/app/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/app/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,10 +7,14 @@ import Foundation import connectivity_plus import path_provider_foundation +import share_plus_macos import shared_preferences_foundation +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/app/pubspec.lock b/app/pubspec.lock index 984f6899ab9a4b32ab6cb57848133f5223380fdc..a241b638f7057e170e1b88a9fe7360d7213f73b5 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -65,6 +65,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.4" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32" + url: "https://pub.dev" + source: hosted + version: "0.3.4+1" crypto: dependency: transitive description: @@ -109,10 +117,18 @@ packages: dependency: transitive description: name: file - sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" fl_chart: dependency: "direct main" description: @@ -296,6 +312,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" + mime: + dependency: transitive + description: + name: mime + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + url: "https://pub.dev" + source: hosted + version: "1.0.5" nested: dependency: transitive description: @@ -440,6 +464,54 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" + share_plus: + dependency: "direct main" + description: + name: share_plus + sha256: f582d5741930f3ad1bf0211d358eddc0508cc346e5b4b248bd1e569c995ebb7a + url: "https://pub.dev" + source: hosted + version: "4.5.3" + share_plus_linux: + dependency: transitive + description: + name: share_plus_linux + sha256: dc32bf9f1151b9864bb86a997c61a487967a08f2e0b4feaa9a10538712224da4 + url: "https://pub.dev" + source: hosted + version: "3.0.1" + share_plus_macos: + dependency: transitive + description: + name: share_plus_macos + sha256: "44daa946f2845045ecd7abb3569b61cd9a55ae9cc4cbec9895b2067b270697ae" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + share_plus_platform_interface: + dependency: transitive + description: + name: share_plus_platform_interface + sha256: "251eb156a8b5fa9ce033747d73535bf53911071f8d3b6f4f0b578505ce0d4496" + url: "https://pub.dev" + source: hosted + version: "3.4.0" + share_plus_web: + dependency: transitive + description: + name: share_plus_web + sha256: eaef05fa8548b372253e772837dd1fbe4ce3aca30ea330765c945d7d4f7c9935 + url: "https://pub.dev" + source: hosted + version: "3.1.0" + share_plus_windows: + dependency: transitive + description: + name: share_plus_windows + sha256: "3a21515ae7d46988d42130cd53294849e280a5de6ace24bae6912a1bffd757d4" + url: "https://pub.dev" + source: hosted + version: "3.0.1" shared_preferences: dependency: "direct main" description: @@ -509,6 +581,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" stack_trace: dependency: transitive description: @@ -597,6 +677,78 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.1" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e" + url: "https://pub.dev" + source: hosted + version: "6.2.6" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "360a6ed2027f18b73c8d98e159dda67a61b7f2e0f6ec26e86c3ada33b0621775" + url: "https://pub.dev" + source: hosted + version: "6.3.1" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "7068716403343f6ba4969b4173cbf3b84fc768042124bc2c011e5d782b24fe89" + url: "https://pub.dev" + source: hosted + version: "6.3.0" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811 + url: "https://pub.dev" + source: hosted + version: "3.1.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7 + url: "https://pub.dev" + source: hosted + version: "3.1.1" + uuid: + dependency: transitive + description: + name: uuid + sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8" + url: "https://pub.dev" + source: hosted + version: "4.4.0" vector_math: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index bf57d419713fba1c91219959ff327e205365c657..b272b26428b3ee12950a3a780b49daa10f64dffd 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -9,20 +9,21 @@ environment: dependencies: flutter: sdk: flutter - flutter_map: ^4.0.0 # Maps ans map customization + flutter_map: ^4.0.0 # OpenStreetMap layer http: ^0.13.3 # HTTPS requests - latlong2: ^0.8.2 # LatLng object - provider: ^5.0.0 # Ice layer bar chart configuration + latlong2: ^0.8.2 # LatLng object for maps + provider: ^5.0.0 # Ice layer bar chart fl_chart: ^0.20.0-nullsafety1 # Charts and diagrams google_fonts: any # Fonts syncfusion_flutter_maps: ^20.4.41 # Choropleth map_handler - syncfusion_flutter_core: any # Choropleth shape selection - path_provider: ^2.0.8 # Persistent variables - shared_preferences: any # Persistent data storage + syncfusion_flutter_core: any # Map shape selection + path_provider: ^2.0.8 # Persistent file storage + shared_preferences: any # Persistent variables fuzzy: any # Search algorithm - connectivity_plus: ^3.0.3 # Check internet connection - get: ^4.6.5 # HTTP get requests + connectivity_plus: ^3.0.3 # Check internet connectivity + get: ^4.6.5 # HTTP GET requests liquid_pull_to_refresh: ^3.0.0 # Pull to refresh animation + share_plus: ^4.0.4 # Exportation of lake measurement data dev_dependencies: flutter_test: diff --git a/app/windows/flutter/generated_plugin_registrant.cc b/app/windows/flutter/generated_plugin_registrant.cc index 8777c93d985871e9830122b808f7cf84bf118fb6..5777988dc32e2b608bf7f61873be41f25ac304d6 100644 --- a/app/windows/flutter/generated_plugin_registrant.cc +++ b/app/windows/flutter/generated_plugin_registrant.cc @@ -7,8 +7,11 @@ #include "generated_plugin_registrant.h" #include <connectivity_plus/connectivity_plus_windows_plugin.h> +#include <url_launcher_windows/url_launcher_windows.h> void RegisterPlugins(flutter::PluginRegistry* registry) { ConnectivityPlusWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/app/windows/flutter/generated_plugins.cmake b/app/windows/flutter/generated_plugins.cmake index cc1361d8d899e7b84030221abc04b40f4b859842..31032063d2b416c9a26ea5480971f83588243380 100644 --- a/app/windows/flutter/generated_plugins.cmake +++ b/app/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST connectivity_plus + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST