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';
const String port = "8443";
const String serverURI = "https://127.0.0.1:$port/";
const String mapEndpoint = "update_map";
const int fetchInterval = 5;
const int fetchInterval = 60; // Fetch marker data every n minutes
// Font variables
const textColor = Colors.white;
......@@ -19,7 +19,7 @@ final titleStyle = GoogleFonts.dmSans(
color: textColor,
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);
// Colors
......
......@@ -45,7 +45,23 @@ class _DefaultPageState extends State<DefaultPage> {
print('Request failed with status: ${response.statusCode}');
}
} 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> {
Center(
child: Text(
'Placeholder',
style: textStyle,
style: regTextStyle,
),
),
Positioned(
......@@ -138,11 +138,11 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
),
Text(
'Latitude: ${selectedMarker?.geoData.latitude}',
style: textStyle,
style: regTextStyle,
),
Text(
'Longitude: ${selectedMarker?.geoData.longitude}',
style: textStyle,
style: regTextStyle,
),
const SizedBox(height: contPadding),
SizedBox(
......@@ -175,7 +175,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
const SizedBox(height: contPadding),
SizedBox(
width: screenWidth * boxWidth - contPadding * 2,
height: 200,
height: 160,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
......@@ -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.
Finish editing this message first!
Please register or to comment