Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MobileEventLog
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
Container 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
Data-Logistics-Support
MobileEventLog
Commits
8cecc49e
Commit
8cecc49e
authored
3 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
cleaned up adding event gnss code
parent
a7d5d302
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/addevent.dart
+50
-49
50 additions, 49 deletions
lib/addevent.dart
with
50 additions
and
49 deletions
lib/addevent.dart
+
50
−
49
View file @
8cecc49e
...
...
@@ -10,6 +10,7 @@ class AddEvent extends StatefulWidget {
}
class
_AddEventPageState
extends
State
<
AddEvent
>
{
bool
disableGnssEditing
=
true
;
final
List
<
bool
>
_isGNSSSelected
=
[
true
];
bool
servicestatus
=
false
;
bool
haspermission
=
false
;
...
...
@@ -37,9 +38,10 @@ class _AddEventPageState extends State<AddEvent> {
alt
=
position
.
altitude
.
toString
();
accuracy
=
position
.
accuracy
;
if
(
mounted
){
setState
(()
{
//refresh UI
});
});
};
StreamSubscription
<
Position
>
positionStream
=
Geolocator
.
getPositionStream
(
locationSettings:
locationSettings
)
.
listen
((
Position
position
)
{
print
(
'Get Location: Lat:'
+
position
.
latitude
.
toString
()
+
...
...
@@ -51,14 +53,18 @@ class _AddEventPageState extends State<AddEvent> {
alt
=
position
.
altitude
.
toString
();
accuracy
=
position
.
accuracy
;
setState
(()
{
//refresh UI on update
});
if
(
disableGnssEditing
==
true
)
{
if
(
mounted
){
setState
(()
{
//refresh UI on update
});};
};
});
}
checkGnssPermission
()
async
{
startGNSS
()
async
{
print
(
"CheckGnssPermission"
);
servicestatus
=
await
Geolocator
.
isLocationServiceEnabled
();
if
(
servicestatus
){
...
...
@@ -79,24 +85,25 @@ class _AddEventPageState extends State<AddEvent> {
if
(
haspermission
){
print
(
'Location permissions granted'
);
if
(
this
.
mounted
){
setState
(()
{
//refresh the UI
});
});
};
getLocation
();
}
}
else
{
print
(
"GPS Service is not enabled, turn on GPS location"
);
}
if
(
this
.
mounted
){
setState
(()
{
//refresh the UI
});
});
};
}
@override
void
initState
()
{
checkGnssPermission
();
startGNSS
();
super
.
initState
();
}
...
...
@@ -115,7 +122,6 @@ class _AddEventPageState extends State<AddEvent> {
}
//TODO: add field validators for freetext fields. Check allowed characters in sensor.awi.de
//TODO: (Description, Label, Latitude, Longitude, Elevation, )
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -124,34 +130,27 @@ class _AddEventPageState extends State<AddEvent> {
final
DeviceStoreInstance
availableDevice
=
DeviceStoreInstance
();
final
EventStoreInstance
storedEvents
=
EventStoreInstance
();
final
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
String
gnssStatusText
=
""
;
final
bool
_disable_gnss_editing
=
_isGNSSSelected
[
0
];
String
_gnss_status_text
=
""
;
//print("###"+currentEvent.store.toString());
//final TextEditingController _controllerLat = TextEditingController(text: currentEvent.store.latitude);
final
TextEditingController
_controllerLat
=
TextEditingController
(
text:
"LAT123"
);
//final TextEditingController _controllerLong = TextEditingController(text: currentEvent.store.longitude);
final
TextEditingController
_controllerLong
=
TextEditingController
(
text:
"Long123"
);
//final TextEditingController _controllerAlt = TextEditingController(text: currentEvent.store.elevation);
final
TextEditingController
_controllerAlt
=
TextEditingController
(
text:
"Alt123"
);
if
(
true
==
disableGnssEditing
){
//currentEvent.store.
if
(
true
==
_isGNSSSelected
[
0
]){
_controllerLat
.
text
=
lat
;
_controllerLong
.
text
=
long
;
_controllerAlt
.
text
=
alt
;
// Update current event coordinates
currentEvent
.
store
.
latitude
=
lat
;
currentEvent
.
store
.
longitude
=
long
;
currentEvent
.
store
.
elevation
=
alt
;
_gnss_status_text
=
"Precision: "
+
accuracy
.
toStringAsFixed
(
2
)
+
"m"
;
if
(
accuracy
==
0.0
){
gnssStatusText
=
"No-Fix"
;
}
else
{
gnssStatusText
=
"Precision: "
+
accuracy
.
toStringAsFixed
(
2
)
+
"m"
;
}
}
else
{
_gnss_status_text
=
"Off"
;
// do nothing and keep old value,
// Just display old event coordinates
gnssStatusText
=
"GNSS Disabled"
;
}
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"Add Event"
)),
body:
...
...
@@ -210,28 +209,29 @@ class _AddEventPageState extends State<AddEvent> {
},
),
TextField
(
readOnly:
true
,
enabled:
!
_disable_gnss_editing
,
controller:
_controllerLat
,
decoration:
InputDecoration
(
readOnly:
false
,
enabled:
!
disableGnssEditing
,
//controller: _controllerLat,
controller:
TextEditingController
(
text:
currentEvent
.
store
.
latitude
.
toString
()),
decoration:
const
InputDecoration
(
labelText:
'Latitude'
,
border:
OutlineInputBorder
(),
),
),
TextField
(
readOnly:
tru
e
,
enabled:
!
_
disable
_g
nss
_e
diting
,
controller:
_controllerLong
,
decoration:
InputDecoration
(
readOnly:
fals
e
,
enabled:
!
disable
G
nss
E
diting
,
controller:
TextEditingController
(
text:
currentEvent
.
store
.
longitude
.
toString
())
,
decoration:
const
InputDecoration
(
labelText:
'Longitude'
,
border:
OutlineInputBorder
(),
),
),
TextField
(
readOnly:
tru
e
,
enabled:
!
_
disable
_g
nss
_e
diting
,
controller:
_controllerAlt
,
decoration:
InputDecoration
(
readOnly:
fals
e
,
enabled:
!
disable
G
nss
E
diting
,
controller:
TextEditingController
(
text:
currentEvent
.
store
.
elevation
.
toString
())
,
decoration:
const
InputDecoration
(
labelText:
'Elevation'
,
border:
OutlineInputBorder
(),
),
...
...
@@ -240,27 +240,28 @@ class _AddEventPageState extends State<AddEvent> {
bottomNavigationBar:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
Text
(
_
gnss
_s
tatus
_t
ext
),
SizedBox
(
width:
50
),
Text
(
gnss
S
tatus
T
ext
),
const
SizedBox
(
width:
50
),
ToggleButtons
(
children:
<
Widget
>[
children:
const
<
Widget
>[
Icon
(
Icons
.
my_location
),
],
isSelected:
_isGNSSSelected
,
onPressed:
(
int
index
)
{
setState
(()
{
_isGNSSSelected
[
index
]
=
!
_isGNSSSelected
[
index
];
disableGnssEditing
=
_isGNSSSelected
[
index
];
});
},
),
SizedBox
(
width:
50
),
const
SizedBox
(
width:
50
),
FloatingActionButton
(
heroTag:
null
,
onPressed:
_storeCurrentEvent
,
tooltip:
'Add Event'
,
child:
Icon
(
Icons
.
add
),
child:
const
Icon
(
Icons
.
add
),
),
SizedBox
(
width:
20
),
const
SizedBox
(
width:
20
),
],
),
);
...
...
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