Skip to content
Snippets Groups Projects
Commit 10f5e549 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

add: alert on failed server connection

parent d4f37fb5
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ import 'package:google_fonts/google_fonts.dart'; ...@@ -5,7 +5,7 @@ import 'package:google_fonts/google_fonts.dart';
const String port = "8443"; const String port = "8443";
const String serverURI = "https://127.0.0.1:$port/"; const String serverURI = "https://127.0.0.1:$port/";
const String mapEndpoint = "update_map"; const String mapEndpoint = "update_map";
const int fetchInterval = 5; const int fetchInterval = 60; // Fetch marker data every n minutes
// Font variables // Font variables
const textColor = Colors.white; const textColor = Colors.white;
...@@ -19,7 +19,7 @@ final titleStyle = GoogleFonts.dmSans( ...@@ -19,7 +19,7 @@ final titleStyle = GoogleFonts.dmSans(
color: textColor, color: textColor,
fontWeight: FontWeight.bold, // Add this line to make the text bold fontWeight: FontWeight.bold, // Add this line to make the text bold
); );
final textStyle = GoogleFonts.dmSans(fontSize: 20, color: textColor); final regTextStyle = GoogleFonts.dmSans(fontSize: 20, color: textColor);
final chartTextStyle = GoogleFonts.dmSans(fontSize: 14, color: textColor); final chartTextStyle = GoogleFonts.dmSans(fontSize: 14, color: textColor);
// Colors // Colors
......
...@@ -45,7 +45,23 @@ class _DefaultPageState extends State<DefaultPage> { ...@@ -45,7 +45,23 @@ class _DefaultPageState extends State<DefaultPage> {
print('Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}');
} }
} catch (e) { } catch (e) {
print('Failed to connect to the server: $e'); showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Error"),
content: Text("Failed to connect to the server. Please check your network connection"),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(); // Close the dialog
},
child: Text("OK"),
),
],
);
},
);
} }
} }
......
...@@ -95,7 +95,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -95,7 +95,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
Center( Center(
child: Text( child: Text(
'Placeholder', 'Placeholder',
style: textStyle, style: regTextStyle,
), ),
), ),
Positioned( Positioned(
...@@ -138,11 +138,11 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -138,11 +138,11 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
), ),
Text( Text(
'Latitude: ${selectedMarker?.geoData.latitude}', 'Latitude: ${selectedMarker?.geoData.latitude}',
style: textStyle, style: regTextStyle,
), ),
Text( Text(
'Longitude: ${selectedMarker?.geoData.longitude}', 'Longitude: ${selectedMarker?.geoData.longitude}',
style: textStyle, style: regTextStyle,
), ),
const SizedBox(height: contPadding), const SizedBox(height: contPadding),
SizedBox( SizedBox(
...@@ -175,7 +175,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -175,7 +175,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
const SizedBox(height: contPadding), const SizedBox(height: contPadding),
SizedBox( SizedBox(
width: screenWidth * boxWidth - contPadding * 2, width: screenWidth * boxWidth - contPadding * 2,
height: 200, height: 160,
child: BarChart( child: BarChart(
BarChartData( BarChartData(
alignment: BarChartAlignment.spaceAround, alignment: BarChartAlignment.spaceAround,
...@@ -249,7 +249,6 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -249,7 +249,6 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
), ),
), ),
), ),
const SizedBox(height: contPadding),
], ],
); );
}, },
......
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment