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

update: new loading screen implementation

parent 335ef96b
No related branches found
No related tags found
1 merge request!10Clhp map
...@@ -112,10 +112,26 @@ class _DefaultPageState extends State<DefaultPage> { ...@@ -112,10 +112,26 @@ class _DefaultPageState extends State<DefaultPage> {
color: Colors.white54 color: Colors.white54
), ),
onPressed: () { onPressed: () {
showSearch( showSearch( // Fetch new relation and measurements on search
context: context, context: context,
delegate: CustomSearchDelegate((String result) { delegate: CustomSearchDelegate((String result) {
setState(() { setState(() {
markerListFuture = fetchMeasurements().then((fetchResult) {
List<Measurement> measurements = fetchResult.measurements;
serverConnection = fetchResult.connected;
return measurements;
}).catchError((error) {
serverConnection = false;
throw Exception("Failed to fetch measurements: $error");
});
if (serverConnection){
relationFuture = fetchRelation();
} else { // Read last saved data
relationFuture = loadSavedRelation();
}
selectedLake = result; selectedLake = result;
}); });
}), }),
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'default_page.dart';
class LoadingPage extends StatefulWidget {
const LoadingPage({super.key});
@override
State<StatefulWidget> createState() => _LoadingPageState();
}
class _LoadingPageState extends State<LoadingPage>
with SingleTickerProviderStateMixin{
@override
void initState() {
super.initState();
// Remove app bar
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
// Hold loading page for 5 seconds before navigating to the default page
Future.delayed(const Duration(seconds: 5), () {
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (_) => const DefaultPage(),
)
);
});
}
@override
void dispose() { // Add back app bar
super.dispose();
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual,
overlays: SystemUiOverlay.values,
);
}
class _LoadingPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Scaffold(
decoration: BoxDecoration( // Loading screen body: Container(
color: Colors.grey[900], width: double.infinity,
), decoration: const BoxDecoration( // Loading screen
child: Center( gradient: LinearGradient(
child: Image.asset( colors: [Colors.grey, Colors.black],
'assets/icons/frozen.png', // Loading screen icon begin: Alignment.topLeft,
// Icon from: https://www.flaticon.com/free-icons/cold-water" end: Alignment.bottomRight
color: Colors.grey, ),
width: 170, ),
height: 170, child: Column(
children: [
Image.asset(
'assets/icons/frozen.png', // Loading screen icon
// Icon from: https://www.flaticon.com/free-icons/cold-water"
color: Colors.grey,
),
const SizedBox(height: 20),
const Text(
"IceMap",
style: TextStyle(
color: Colors.white70,
fontStyle: FontStyle.italic,
),
)
]
), ),
), ),
); );
......
No preview for this file type
...@@ -5,6 +5,7 @@ from map_handler.get_measurements import get_all_markers ...@@ -5,6 +5,7 @@ from map_handler.get_measurements import get_all_markers
from map_handler.add_lake import cut_map from map_handler.add_lake import cut_map
from map_handler.process_lake import fetch_divided_map from map_handler.process_lake import fetch_divided_map
from map_handler.input_new_data import input_new_Lidar_data from map_handler.input_new_data import input_new_Lidar_data
from urllib.parse import urlparse, parse_qs
import ssl import ssl
import sqlite3 import sqlite3
...@@ -37,9 +38,13 @@ class IceHTTP(BaseHTTPRequestHandler): ...@@ -37,9 +38,13 @@ class IceHTTP(BaseHTTPRequestHandler):
self.wfile.write(b"Root path hit!") self.wfile.write(b"Root path hit!")
elif self.path == '/update_map': # NB: should be POST? elif self.path == '/update_map': # NB: should be POST?
parsed_path = urlparse(self.path)
query_params = parse_qs(parsed_path.query)
get_all_markers(self, self.cursor, 'mjosa') # Get all markers get_all_markers(self, self.cursor, 'mjosa') # Get all markers
# NB: temporary hardcoded waterBodyName # NB: temporary hardcoded waterBodyName
elif self.path == '/get_relation': elif self.path == '/get_relation':
parsed_path = urlparse(self.path)
query_params = parse_qs(parsed_path.query)
fetch_divided_map(self, 'Mjosa') # NB temp hardcoded value fetch_divided_map(self, 'Mjosa') # NB temp hardcoded value
elif self.path == '/divide_new_relation': elif self.path == '/divide_new_relation':
cut_map(self, 'Mjosa') cut_map(self, 'Mjosa')
......
No preview for this file type
No preview for this file type
...@@ -138,32 +138,3 @@ def write_json_to_file(path: str, file_name: str, json_data: dict): ...@@ -138,32 +138,3 @@ def write_json_to_file(path: str, file_name: str, json_data: dict):
with open(path + '/' + file_name + '_div.json', 'w') as f: with open(path + '/' + file_name + '_div.json', 'w') as f:
json.dump(json_data, f) json.dump(json_data, f)
<<<<<<< HEAD:server/map_handler/add_lake.py
def get_divided_map(file_name):
geo_data = gpd.read_file("server/map_handler/" + file_name + ".geojson")
polygon_data = geo_data[geo_data['geometry'].geom_type == 'Polygon']
polygons = [Polygon(polygon.exterior) for polygon in polygon_data['geometry']]
# Returns a list of [(sub_div_id, sub_div_center)]
def get_id_and_center(file_name): # NB buggy
# Expected format: [(id, [x,y]), (id, [x,y])]
geo_data = gpd.read_file("server/lake_relations/" + file_name + "_div.json")
subdivisions = []
for index, row in geo_data.iterrows():
sub_div_id = row['sub_div_id']
sub_div_center = row['sub_div_center']
print("sub_div_id: ", sub_div_id)
subdivision = {
'sub_div_id': sub_div_id,
'sub_div_center': sub_div_center
}
subdivisions.append(subdivision)
return subdivisions
=======
>>>>>>> b0c6d9be39ffc9557a93873ab827bf05847ef1c1:server/map/add_lake.py
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