diff --git a/app/lib/consts.dart b/app/lib/consts.dart index 13b7ca3b3bbebe953f24e62f53e93072154af512..d1c7751a71c5564ccd46cbcae484bfc4e276be05 100644 --- a/app/lib/consts.dart +++ b/app/lib/consts.dart @@ -16,8 +16,8 @@ Uint8List selectedRelation = Uint8List(0); List<Measurement> selectedMarkerList = []; LatLng mapCenter = LatLng(60.8000, 10.8471); DateTime ?lastUpdate; // Last time data was fetched from server - List<String> lakeSearchOptions = []; // Init empty +bool internetConnection = true; // Font settings const textColor = Colors.white; diff --git a/app/lib/controller/dependency_injection.dart b/app/lib/controller/dependency_injection.dart new file mode 100644 index 0000000000000000000000000000000000000000..8b5c31ff959c0cf90600d9503e4888f988583e62 --- /dev/null +++ b/app/lib/controller/dependency_injection.dart @@ -0,0 +1,9 @@ + +import 'package:get/get.dart'; +import 'package:app/controller/network_controller.dart'; + +class DependencyInjection { + static void init() { + Get.put<NetworkController>(NetworkController(), permanent:true); + } +} \ No newline at end of file diff --git a/app/lib/controller/network_controller.dart b/app/lib/controller/network_controller.dart new file mode 100644 index 0000000000000000000000000000000000000000..7da8a58bb64191fbc9769ae4774dd38e309fb4b8 --- /dev/null +++ b/app/lib/controller/network_controller.dart @@ -0,0 +1,47 @@ +import 'package:get/get.dart'; +import 'package:flutter/material.dart'; +import 'package:connectivity_plus/connectivity_plus.dart'; + +import '../consts.dart'; + +/// NetworkController checks the network connection of the application globally +class NetworkController extends GetxController { + final Connectivity _connectivity = Connectivity(); + + @override + void onInit() { + super.onInit(); + _connectivity.onConnectivityChanged.listen(_updateConnectionStatus); + } + + void _updateConnectionStatus(ConnectivityResult connectivityResult) { + + // If no network connection, show snack-bar + if (connectivityResult == ConnectivityResult.none) { + internetConnection = false; + + Get.rawSnackbar( + messageText: Text( + 'No internet connection. The displayed information may be outdated!', + style: regTextStyle, + ), + isDismissible: false, + duration: const Duration(days: 1), // Display the message until a network connection is established + backgroundColor: Colors.black45, + icon: const Icon( + Icons.wifi_off, + color: Colors.white, + size: 35, + ), + margin: EdgeInsets.zero, + snackStyle: SnackStyle.GROUNDED, + ); + } else { + internetConnection = true; + + if (Get.isSnackbarOpen) { // Close snack-bar upon establishing internet connection + Get.closeCurrentSnackbar(); + } + } + } +} \ No newline at end of file diff --git a/app/lib/main.dart b/app/lib/main.dart index b6384264455e6fbc32bea4a9dfd61e77c9a88b69..3fa16618b7b5ea5f70ce7e61fec12d956451a5fd 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -1,9 +1,12 @@ +import 'package:get/get.dart'; import 'package:flutter/material.dart'; import 'pages/loading_page.dart'; +import 'package:app/controller/dependency_injection.dart'; void main() { runApp(const MyApp()); + DependencyInjection.init(); } class MyApp extends StatelessWidget { @@ -11,7 +14,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( + return const GetMaterialApp( // GetMaterialApp for snack-bar support home: LoadingPage(), ); } diff --git a/app/lib/server_requests/fetch_markers.dart b/app/lib/server_requests/fetch_markers.dart index cd67bc7b348c5ac74c9150c0b6e391b6a7053327..80cbc1726d1dc265c8c97da753c1b44c1efeabd6 100644 --- a/app/lib/server_requests/fetch_markers.dart +++ b/app/lib/server_requests/fetch_markers.dart @@ -62,18 +62,23 @@ Future<FetchResult> fetchMeasurements() async { } Future<FetchResult> loadSavedData() async { - // Get latest saved data from file if the server does not respond - Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); - String filePath = '${appDocumentsDirectory.path}/last_data.json'; + try { + // Get latest saved data from file if the server does not respond + Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); + String filePath = '${appDocumentsDirectory.path}/last_data.json'; - // Read file contents - File file = File(filePath); - if (await file.exists()) { - String contents = await file.readAsString(); - List<dynamic> jsonData = json.decode(contents); // Parse JSON string from file - List<Measurement> measurements = jsonData.map((data) => Measurement.fromJson(data)).toList(); - return FetchResult(measurements, false); - } else { - throw Exception('File does not exist'); + // Read file contents + File file = File(filePath); + if (await file.exists()) { + String contents = await file.readAsString(); + List<dynamic> jsonData = json.decode(contents); // Parse JSON string from file + List<Measurement> measurements = jsonData.map((data) => Measurement.fromJson(data)).toList(); + return FetchResult(measurements, false); + } else { + throw Exception('File does not exist'); + } + } catch (error) { + print('Error in reading measurements from file: $error'); + return FetchResult([], false); } } diff --git a/app/lib/server_requests/fetch_relation.dart b/app/lib/server_requests/fetch_relation.dart index 88e1ca2003a6a872679a983e49f74c53ae5c1e48..999ec52e5795cd5c521c9aced78dae5427c97ae6 100644 --- a/app/lib/server_requests/fetch_relation.dart +++ b/app/lib/server_requests/fetch_relation.dart @@ -45,20 +45,23 @@ Future<Uint8List> fetchRelation() async { } } +/// Load last saved relation data form last_relation.json Future<Uint8List> loadSavedRelation() async { - // Get latest saved relation from file if the server does not respond - Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); - String filePath = '${appDocumentsDirectory.path}/last_relation.json'; + try { + // Get latest saved relation from file if the server does not respond + Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); + String filePath = '${appDocumentsDirectory.path}/last_relation.json'; - // Read file contents - File file = File(filePath); - if (await file.exists()) { - String contents = await file.readAsString(); - List<dynamic> jsonData = json.decode(contents); // Parse JSON string from file - Uint8List relation = Uint8List.fromList(utf8.encode(jsonData.toString())); - return relation; - } else { - throw Exception('File does not exist'); + // Read file contents as bytes + File file = File(filePath); + if (await file.exists()) { + Uint8List bytes = await file.readAsBytes(); + return bytes; + } else { + throw Exception('Relation file does not exist'); + } + } catch (error) { + print('Error in reading relation from file: $error'); + return Uint8List(0); } } - diff --git a/app/lib/server_requests/init_state.dart b/app/lib/server_requests/init_state.dart index d4ca66a1e597d6d6ec999f5581a55550ab8988ff..4338c4a2971c8b3873f474ae3f5c0909c3d6ce63 100644 --- a/app/lib/server_requests/init_state.dart +++ b/app/lib/server_requests/init_state.dart @@ -4,42 +4,62 @@ import 'dart:convert'; import 'dart:typed_data'; import 'package:app/consts.dart'; +import '../consts.dart'; import '../data_classes.dart'; import '../server_requests/fetch_markers.dart'; import '../server_requests/fetch_relation.dart'; -Future<void> initialiseState() async{ +/// initialiseState makes three requests to the server, one requesting +/// measurements for the selected relation, the other requesting the relation, +/// and the last requesting the list of all system lakes +Future<void> initialiseState() async { bool serverConnection = true; late Future<List<Measurement>> markerListFuture; late Future<Uint8List> relationFuture; - // Try to fetch measurement data from server - markerListFuture = fetchMeasurements().then((fetchResult) { - List<Measurement> measurements = fetchResult.measurements; - serverConnection = fetchResult.connected; - - // Return the measurements - return measurements; - }).catchError((error) { - serverConnection = false; - throw Exception("Failed to fetch measurements: $error"); - }); - - // Attempt to fetch relation from server if app establishes connection - if (serverConnection) { - relationFuture = fetchRelation(); - } else { // Read last saved data - relationFuture = loadSavedRelation(); - } + try { + if (!internetConnection) { // Read data from files if no internet connection + selectedRelation = await loadSavedRelation(); + + FetchResult fetchResult = await loadSavedData(); + List<Measurement> measurements = fetchResult.measurements; + selectedMarkerList = measurements; - initSearchOptions(); + lakeSearchOptions = ["Mjøsa"]; + } else { // Try to fetch measurement data from server + markerListFuture = fetchMeasurements().then((fetchResult) { + List<Measurement> measurements = fetchResult.measurements; + serverConnection = fetchResult.connected; + + // Return measurements + return measurements; + }).catchError((error) { + serverConnection = false; + throw Exception("Failed to fetch measurements: $error"); + }); + + // If measurements were fetched successfully, request relation + if (serverConnection) { + relationFuture = fetchRelation(); + } else { // Read last saved data + relationFuture = loadSavedRelation(); + } - selectedRelation = await relationFuture; - selectedMarkerList = await markerListFuture; + initSearchOptions(); + + //selectedRelation = await relationFuture; + selectedRelation = await relationFuture; // NB update once fixed + selectedMarkerList = await markerListFuture; + } + } catch (e) { + // Handle any errors that occur during the initialization process + print("Error during initialization: $e"); + } } + /// initSearchOptions fetches a list of all lake names in the system /// and initialises lakeSearchOptions Future<void> initSearchOptions() async { diff --git a/app/lib/widgets/bar_graph/bar_data.dart b/app/lib/widgets/bar_graph/bar_data.dart new file mode 100644 index 0000000000000000000000000000000000000000..6ef9b182597faf1fd8a5cc2dab159c7edea16153 --- /dev/null +++ b/app/lib/widgets/bar_graph/bar_data.dart @@ -0,0 +1,168 @@ +import 'package:flutter/material.dart'; +import 'package:fl_chart/fl_chart.dart'; + +class BarData extends StatefulWidget { + const BarData({super.key}); + + @override + State<StatefulWidget> createState() => _BarDataState(); +} + + +class _BarDataState extends State<BarData> { + static const double barWidth = 30; + + // NB should be rounded to two decimals in server + // NB should be allocated values dynamically + // Bar items show data for 10 previous days + static const barData = <int, List<double>>{ + 0: [1.5, 4, 2.5], + 1: [1.8, 5.6, 3], + 2: [1.5, 3.1, 3.5], + 3: [1.5, 1.5, 4], + 4: [2, 2, 5], + 5: [1.2, 1.5, 4.3], + 6: [1.2, 4.8, 5], + }; + int touchedIndex = -1; + + @override + void initState() { + super.initState(); + } + + BarChartGroupData generateGroup( + int x, + double value1, + double value2, + double value3, + ) { + final sum = value1 + value2 + value3; + final isTouched = touchedIndex == x; + return BarChartGroupData( + x: x, + showingTooltipIndicators: isTouched ? [0] : [], + barRods: [ + BarChartRodData( + y: sum, + width: barWidth, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(6), + topRight: Radius.circular(6), + ), + rodStackItems: [ + BarChartRodStackItem( + 0, + value1, + const Color(0xFF13dbff), + ), + BarChartRodStackItem( + value1, + value1 + value2, + const Color(0xFF000085), + ), + BarChartRodStackItem( + value1 + value2, + value1 + value2 + value3, + Colors.white60, + ), + ], + ), + ], + ); + } + + // _buildLegendItem renders a colored circle and text to form a legend + Widget _buildLegendItem(Color color, String text) { + return Row( + children: [ + Container( + width: 20, + height: 20, + decoration: BoxDecoration( + color: color, + shape: BoxShape.circle, + ), + ), + const SizedBox(width: 8), + Text( + text, + style: const TextStyle( + fontSize: 14, + color: Colors.white, + ), + ), + ], + ); + } + + + @override + Widget build(BuildContext context) { + return Column( + children: [ + SizedBox( + width: MediaQuery.of(context).size.width, // Set the desired width + child: BarChart( + BarChartData( + alignment: BarChartAlignment.center, + maxY: 12, + minY: 0, + titlesData: FlTitlesData( + show: true, + bottomTitles: SideTitles( + showTitles: true, + reservedSize: 5, + getTextStyles: (value) => const TextStyle(color: Colors.white60), + ), + leftTitles: SideTitles( + showTitles: true, + getTextStyles: (value) => const TextStyle(color: Colors.white60), + margin: 10, + reservedSize: 30, + interval: 2, + ), + rightTitles: SideTitles( + showTitles: true, + getTextStyles: (value) => const TextStyle(color: Colors.white60), + margin: 10, + reservedSize: 30, + interval: 2, + ), + ), + groupsSpace: 14, + gridData: FlGridData( + show: true, + ), + borderData: FlBorderData( + show: false, + ), + barGroups: barData.entries + .map( + (e) => generateGroup( + e.key, + e.value[0], + e.value[1], + e.value[2], + ), + ).toList(), + ), + ), + ), + Padding( // Legend items + padding: const EdgeInsets.only(top: 20), + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + _buildLegendItem(Colors.white60, "Snow"), + _buildLegendItem(const Color(0xFF000085), "Black ice"), + _buildLegendItem(const Color(0xFF13dbff), "Slush ice"), + ], + ), + ), + ), + ], + ); + } +} \ No newline at end of file diff --git a/app/lib/widgets/main_layout.dart b/app/lib/widgets/main_layout.dart index a4391d8fc20b0dda3ba1ea579d56bd80b470c484..767d42292b6ed5c7f3fbcdba7092036842e27d22 100644 --- a/app/lib/widgets/main_layout.dart +++ b/app/lib/widgets/main_layout.dart @@ -208,7 +208,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { lastUpdate?.month == DateTime.now().month && lastUpdate?.year == DateTime.now().year ? '${lastUpdate?.hour}:${lastUpdate?.minute}' : - '${lastUpdate?.day}-${lastUpdate?.month}-${lastUpdate?.year}') : ''}', + '${lastUpdate?.day}.${formatMonth(lastUpdate!.month)} ${lastUpdate?.year}') : ''}', style: GoogleFonts.dmSans( fontSize: 14, color: Colors.white60, @@ -217,49 +217,85 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ], ), const SizedBox(height: contPadding), // Padding between containers - ClipRRect( - borderRadius: BorderRadius.circular(20), - child: SizedBox( - width: screenWidth * boxWidth, - height: screenWidth * boxHeight * 1.5, // NB: make dynamic - child: Align( - alignment: Alignment.topLeft, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: screenWidth * boxWidth, + child: Align( + alignment: Alignment.topLeft, + child: Padding( + padding: const EdgeInsets.only(top: 20, left: 30), // Updated padding + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Ice stats', + style: titleStyle, + ), + const Divider(), + const SizedBox(height: 10), // Reduced padding + Text( + 'Measured at ', + style: subHeadingStyle, + ), + Text( + 'Date: ${(selectedTile?.timeMeasured.day ?? '-')}/${(selectedTile?.timeMeasured.month ?? '-')}/${(selectedTile?.timeMeasured.year ?? '-')}', + style: regTextStyle, + ), + Text( + 'Time: ${selectedTile?.timeMeasured.hour}:00', + style: regTextStyle, + ), + ], + ), + ), + ), + ), + const SizedBox(height: contPadding*2), + SizedBox( + width: screenWidth * boxWidth * 1.2, + child: Center( + child: Text( + 'Measuring point: (${selectedTile?.measurementID}, ${selectedTile?.measurementID})', + style: regTextStyle, + ), + ), + ), + SizedBox( + width: screenWidth * boxWidth * 1.2, + child: const StatCharts(), + ), + const SizedBox(height: contPadding*2), + SizedBox( + width: screenWidth * boxWidth * 1.2, child: Padding( - padding: const EdgeInsets.only(top: 20, left: 20), // Edge padding, text + padding: const EdgeInsets.only(top: 20, left: 30), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - 'Ice stats', - style: titleStyle, - ), - const Divider(), - const Padding(padding: EdgeInsets.all(10)), - Text( - 'Measured at ', - style: subHeadingStyle, - ), - Text( - 'Date: ${(selectedTile?.timeMeasured.day ?? '-')}/${(selectedTile?.timeMeasured.month ?? '-')}/${(selectedTile?.timeMeasured.year ?? '-')}', - style: regTextStyle, - ), - Text( - 'Time: ${selectedTile?.timeMeasured.hour}:00', - style: regTextStyle, + Row( + children: [ + const Icon( + Icons.info, + color: Colors.white54, + ), + const SizedBox(width: 10), + Expanded( + child: Text( + 'For every x of y, there has to be z cm of ' + 'q for every kg of applied weight to ensure ?', + style: regTextStyle, + ), + ), + ], ), - const SizedBox(height: contPadding), - Text( - 'Measuring point: (${selectedTile?.measurementID}, ${selectedTile?.measurementID})', - style: regTextStyle, - ), - const SizedBox(height: contPadding), - const SizedBox(height: 15), - const StatCharts(), ], ), ), ), - ), + const SizedBox(height: contPadding*2), + ], ), ], ); @@ -267,3 +303,34 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ); } } + +String formatMonth(int month) { + switch (month) { + case 1: + return 'Jan'; + case 2: + return 'Feb'; + case 3: + return 'Mar'; + case 4: + return 'Apr'; + case 5: + return 'May'; + case 6: + return 'Jun'; + case 7: + return 'Jul'; + case 8: + return 'Aug'; + case 9: + return 'Sep'; + case 10: + return 'Oct'; + case 11: + return 'Nov'; + case 12: + return 'Dec'; + default: + return ''; + } +} \ No newline at end of file diff --git a/app/lib/widgets/stat_charts.dart b/app/lib/widgets/stat_charts.dart index 8d480da1f448588aecf67fdec4e210092e6286e2..f97ee153ee00e797d83b30065e7371f4e7c6be1e 100644 --- a/app/lib/widgets/stat_charts.dart +++ b/app/lib/widgets/stat_charts.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:fl_chart/fl_chart.dart'; +import 'bar_graph/bar_data.dart'; class StatCharts extends StatelessWidget { const StatCharts({Key? key}) : super(key: key); @@ -63,84 +64,19 @@ class StatCharts extends StatelessWidget { ); } - Widget buildBarChart(BuildContext context) { - return Padding( - padding: const EdgeInsets.only(right: 20), - child: BarChart( - BarChartData( - alignment: BarChartAlignment.spaceAround, - maxY: 20, - barTouchData: BarTouchData(enabled: false), - backgroundColor: Colors.grey.shade800, - titlesData: FlTitlesData( - bottomTitles: SideTitles( - showTitles: true, - getTextStyles: (value) => const TextStyle(color: Colors.white60), - margin: 10, - getTitles: (value) { - switch (value.toInt()) { - case 0: - return 'Value'; - case 1: - return 'Value'; - case 2: - return 'Value'; - default: - return ''; - } - }, - ), - leftTitles: SideTitles( - showTitles: true, - getTextStyles: (value) => const TextStyle(color: Colors.white60), - margin: 10, - reservedSize: 30, - interval: 5, - ), - ), - borderData: FlBorderData( - show: true, - border: Border.all(color: Colors.white60, width: 1), - ), - barGroups: [ - BarChartGroupData( - x: 0, - barRods: [ - BarChartRodData(y: 15, width: 10), - ], - ), - BarChartGroupData( - x: 1, - barRods: [ - BarChartRodData(y: 10, width: 10), - ], - ), - BarChartGroupData( - x: 2, - barRods: [ - BarChartRodData(y: 18, width: 10), - ], - ), - ], - ), - ), - ); - } - @override Widget build(BuildContext context) { return Column( children: [ - SizedBox( + /*SizedBox( width: MediaQuery.of(context).size.width * 0.8, // Set the width of the LineChart height: 200, child: buildLineChart(context), - ), + ),*/ const SizedBox(height: 20), SizedBox( - width: MediaQuery.of(context).size.width * 0.8, - height: 160, - child: buildBarChart(context), + width: MediaQuery.of(context).size.width, + child: const BarData(), ), ], ); diff --git a/app/macos/Flutter/GeneratedPluginRegistrant.swift b/app/macos/Flutter/GeneratedPluginRegistrant.swift index b8e2b22f76117bd244aa074a3298db850fb02ef1..37769918364446aa1f43f8b67f5daefcd48374aa 100644 --- a/app/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/app/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,10 +5,12 @@ import FlutterMacOS import Foundation +import connectivity_plus import path_provider_foundation import shared_preferences_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) } diff --git a/app/pubspec.lock b/app/pubspec.lock index 73538620a0a9ffeefd9ba57ea9b53da96d8dabc0..f052b8a782a53e5dfd02c4305034688622205349 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: @@ -41,6 +49,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + connectivity_plus: + dependency: "direct main" + description: + name: connectivity_plus + sha256: b74247fad72c171381dbe700ca17da24deac637ab6d43c343b42867acb95c991 + url: "https://pub.dev" + source: hosted + version: "3.0.6" + connectivity_plus_platform_interface: + dependency: transitive + description: + name: connectivity_plus_platform_interface + sha256: cf1d1c28f4416f8c654d7dc3cd638ec586076255d407cef3ddbdaf178272a71a + url: "https://pub.dev" + source: hosted + version: "1.2.4" crypto: dependency: transitive description: @@ -49,6 +73,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + dbus: + dependency: transitive + description: + name: dbus + sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac" + url: "https://pub.dev" + source: hosted + version: "0.7.10" equatable: dependency: transitive description: @@ -128,6 +160,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.1" + get: + dependency: "direct main" + description: + name: get + sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e + url: "https://pub.dev" + source: hosted + version: "4.6.6" google_fonts: dependency: "direct main" description: @@ -160,6 +200,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.19.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" latlong2: dependency: "direct main" description: @@ -248,6 +296,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + nm: + dependency: transitive + description: + name: nm + sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254" + url: "https://pub.dev" + source: hosted + version: "0.5.0" path: dependency: transitive description: @@ -328,6 +384,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" + source: hosted + version: "6.0.2" platform: dependency: transitive description: @@ -573,6 +637,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + xml: + dependency: transitive + description: + name: xml + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" + source: hosted + version: "6.5.0" sdks: dart: ">=3.3.0 <4.0.0" flutter: ">=3.19.0" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index c87dfe4687ef61b2a1849409c71d948d5a22c588..84fd4516d63b13f277e6f5a31ed0f71f9752840a 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -9,9 +9,9 @@ environment: dependencies: flutter: sdk: flutter - flutter_map: ^4.0.0 # Various maps + flutter_map: ^4.0.0 # Maps ans map customization http: ^0.13.3 # HTTPS requests - latlong2: ^0.8.2 + latlong2: ^0.8.2 # LatLng object provider: ^5.0.0 fl_chart: ^0.20.0-nullsafety1 # Charts and diagrams google_fonts: any # Fonts @@ -20,6 +20,8 @@ dependencies: path_provider: ^2.0.8 shared_preferences: any # Persistent data storage fuzzy: any # Search algorithm + connectivity_plus: ^3.0.3 # Check internet connection + get: ^4.6.5 dev_dependencies: flutter_test: diff --git a/app/windows/flutter/generated_plugin_registrant.cc b/app/windows/flutter/generated_plugin_registrant.cc index 8b6d4680af388f28db8742ef7fb8246e2bb1fffb..8777c93d985871e9830122b808f7cf84bf118fb6 100644 --- a/app/windows/flutter/generated_plugin_registrant.cc +++ b/app/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include <connectivity_plus/connectivity_plus_windows_plugin.h> void RegisterPlugins(flutter::PluginRegistry* registry) { + ConnectivityPlusWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); } diff --git a/app/windows/flutter/generated_plugins.cmake b/app/windows/flutter/generated_plugins.cmake index b93c4c30c16703f640bc38523e56204ade09399e..cc1361d8d899e7b84030221abc04b40f4b859842 100644 --- a/app/windows/flutter/generated_plugins.cmake +++ b/app/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + connectivity_plus ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/server/main.py b/server/main.py index 2232bc36504cec3b8e5ef809ecb7b472a4f43e8d..846143eea398bb521be833e62899746a588c7bbb 100644 --- a/server/main.py +++ b/server/main.py @@ -13,6 +13,7 @@ import sqlite3 app = Flask(__name__) terminate_server = 0 + class IceHTTPServer(HTTPServer): def __init__(self, server_address, handler_class, cursor): super().__init__(server_address, handler_class) @@ -65,7 +66,8 @@ class IceHTTP(BaseHTTPRequestHandler): def do_POST(self): if self.path == '/new_lidar_data': - input_new_Lidar_data(self,self.cursor, 1, 'Mjosa') # hardcoded body of water must change later + input_new_Lidar_data(self, self.cursor, 1, 'Mjosa') # hardcoded body of water must change later + # Start a server on port 8443 using self defined HTTP class if __name__ == "__main__":