Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sara Savanovic Djordjevic
PROG2900
Commits
2f9ee128
Commit
2f9ee128
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: simple info layer for color explanations
parent
adf8af22
No related branches found
No related tags found
1 merge request
!16
Clhp map into main
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/widgets/info_layer.dart
+91
-0
91 additions, 0 deletions
app/lib/widgets/info_layer.dart
app/lib/widgets/main_layout.dart
+12
-43
12 additions, 43 deletions
app/lib/widgets/main_layout.dart
with
103 additions
and
43 deletions
app/lib/widgets/info_layer.dart
0 → 100644
+
91
−
0
View file @
2f9ee128
import
'package:flutter/material.dart'
;
import
'../../consts.dart'
;
class
InfoLayer
extends
StatefulWidget
{
const
InfoLayer
({
Key
?
key
,
})
:
super
(
key:
key
);
@override
InfoLayerState
createState
()
=
>
InfoLayerState
();
}
class
InfoLayerState
extends
State
<
InfoLayer
>
{
@override
void
initState
()
{
super
.
initState
();
}
// _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
)
{
return
Container
(
padding:
const
EdgeInsets
.
all
(
40
),
color:
Colors
.
black
.
withOpacity
(
0.8
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
// Align contents vertically centered
children:
[
Text
(
'Color categorization'
,
style:
subHeadingStyle
,
),
const
SizedBox
(
height:
20
),
Text
(
'The map shows the safety of applying x kg per x m^2'
,
style:
regTextStyle
,
textAlign:
TextAlign
.
center
,
),
const
SizedBox
(
height:
30
),
_buildLegend
(),
const
SizedBox
(
height:
30
),
Text
(
'Placeholder for other information...'
,
style:
smallTextStyle
,
textAlign:
TextAlign
.
center
,
),
],
),
);
}
}
This diff is collapsed.
Click to expand it.
app/lib/widgets/main_layout.dart
+
12
−
43
View file @
2f9ee128
...
...
@@ -5,6 +5,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import
'osm_layer.dart'
;
import
'stat_charts.dart'
;
import
'info_layer.dart'
;
import
'../../consts.dart'
;
import
'choropleth_map.dart'
;
import
'../data_classes.dart'
;
...
...
@@ -39,7 +40,7 @@ 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
bool
infoLayer
=
false
;
// Additional color legend visibility
Measurement
?
selectedMeasurement
=
selectedMeasurements
[
0
];
...
...
@@ -75,46 +76,6 @@ 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
...
...
@@ -163,6 +124,14 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
child:
OSM
(
markerList:
widget
.
measurements
),
),
),
SizedBox
(
width:
screenWidth
*
boxWidth
,
height:
screenWidth
*
boxHeight
,
child:
Visibility
(
visible:
infoLayer
,
child:
const
InfoLayer
(),
),
),
Positioned
(
// Satellite button
top:
10
,
right:
10
,
...
...
@@ -264,12 +233,12 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
child:
GestureDetector
(
onTap:
()
{
setState
(()
{
showColorMeanings
=
!
showColorMeanings
;
// Toggle satellite layer state on press
infoLayer
=
!
infoLayer
;
// Toggle satellite layer state on press
});
},
child:
Container
(
padding:
const
EdgeInsets
.
all
(
8
),
decoration:
showColorMeanings
?
const
BoxDecoration
(
// Add decoration only when pressed
decoration:
infoLayer
?
const
BoxDecoration
(
// Add decoration only when pressed
shape:
BoxShape
.
circle
,
color:
Colors
.
grey
,
)
:
null
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment