From adf8af2248d41e016592083d4a31c856c3fb741b Mon Sep 17 00:00:00 2001 From: Sara <sarasdj@stud.ntnu.no> Date: Fri, 10 May 2024 19:26:27 +0200 Subject: [PATCH] add: info button --- app/lib/widgets/main_layout.dart | 68 +++++++++++++++++- .../__pycache__/add_new_lake.cpython-311.pyc | Bin 9894 -> 9899 bytes 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/app/lib/widgets/main_layout.dart b/app/lib/widgets/main_layout.dart index 1cdb9b08..5f915d0c 100644 --- a/app/lib/widgets/main_layout.dart +++ b/app/lib/widgets/main_layout.dart @@ -39,6 +39,8 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { bool isSatTapped = false; // Satellite button tap state tracker bool isMapTapped = false; // OSM button tap state tracker + bool showColorMeanings = false; // Additional color legend visibility + Measurement? selectedMeasurement = selectedMeasurements[0]; // Initialise lastUpdate variable from persistent storage if server fetch fails @@ -73,6 +75,46 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { }); } + // _buildLegendItem renders a colored circle and text to form a legend + Widget _legendItem(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, + ), + ), + ], + ); + } + + /// Builds an additional legend to explain the colors + Widget _buildLegend() { + return Column( + children: [ + _legendItem(const Color(0xffff0000), "Very unsafe"), + const SizedBox(height: 10), + _legendItem(const Color(0xffff6a00), "Unsafe"), + const SizedBox(height: 10), + _legendItem(const Color(0xFFb1ff00), "Safe"), + const SizedBox(height: 10), + _legendItem(const Color(0xFF00d6ff), "Very safe"), + const SizedBox(height: 10), + ], + ); + } + @override Widget build(BuildContext context) { // Initialise selectedMarker to first element in markerList @@ -216,6 +258,28 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ), ), ), + Positioned( // Color info button + top: 130, + right: 10, + child: GestureDetector( + onTap: () { + setState(() { + showColorMeanings = !showColorMeanings; // Toggle satellite layer state on press + }); + }, + child: Container( + padding: const EdgeInsets.all(8), + decoration: showColorMeanings ? const BoxDecoration( // Add decoration only when pressed + shape: BoxShape.circle, + color: Colors.grey, + ) : null, + child: const Icon( + Icons.info, + color: Colors.white54, + ), + ), + ), + ), ], ), ), @@ -246,7 +310,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { child: Align( alignment: Alignment.topLeft, child: Padding( - padding: const EdgeInsets.only(top: 20, left: 30), // Updated padding + padding: const EdgeInsets.only(top: 20, left: 30), // Custom padding child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -255,7 +319,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { style: titleStyle, ), const Divider(), - const SizedBox(height: 10), // Reduced padding + const SizedBox(height: 10), Text( 'Tile ID: ${selectedSubDiv?.sub_div_id}', style: regTextStyle, diff --git a/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc b/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc index 4275e07f2c440de66eb2bcb0143d024e5c9475cd..16eb848c6c0ecf96a3d721fd22b4de5d91527f39 100644 GIT binary patch delta 972 zcmZva&rcIU6vubEi|wwv{7?$?7e88xmIzq&poS$us)PdvltT0(E4wXCpoQ70po?&j zL=vKyxp3rQ&;(*6y%-NB1`;`_v<U}Y!(X6>l6WAR7~gDTK;&ijGv9gd&E(C@Tk2l! zmYz$Jz<{0TZHo=9N*5&bGt()(MW}@wDS3d-lbMovG?1w%ov}}~Kpy5P!hn#76{>?2 z4HQ<qm#Qd5A4NaF6yi9c-W*OOHQhuL_$u|Gab1M5cAw!2y5jU-%!1HA0;ZX~n<+j< z+*RLf<2LfO#-9nfyhu>_6=8{Gm}Qo{bGbaUGRq9x5&|#$1)F3^yQhLk?kdq>4E7Gf zw+wbsAc%F6Pww!)`viE_u&GB?aYZ6wPZuiA-1m&3G8}@vLdbMz$-$JGNXE%`Zyo9+ z#Xe7OGlWboHL4|X#FFamkx`QyPAO{PrZ_B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