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
8765d4c9
Commit
8765d4c9
authored
3 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
removed redundant code
parent
8cecc49e
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
+28
-44
28 additions, 44 deletions
lib/addevent.dart
with
28 additions
and
44 deletions
lib/addevent.dart
+
28
−
44
View file @
8765d4c9
...
...
@@ -5,15 +5,15 @@ import 'dart:async';
import
'package:geolocator/geolocator.dart'
;
class
AddEvent
extends
StatefulWidget
{
const
AddEvent
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
AddEvent
>
createState
()
=
>
_AddEventPageState
();
}
class
_AddEventPageState
extends
State
<
AddEvent
>
{
bool
disableG
nss
Editing
=
true
;
bool
disableG
NSS
Editing
=
true
;
final
List
<
bool
>
_isGNSSSelected
=
[
true
];
bool
servicestatus
=
false
;
bool
haspermission
=
false
;
late
LocationPermission
permission
;
late
Position
position
;
late
String
long
=
""
;
...
...
@@ -27,24 +27,9 @@ class _AddEventPageState extends State<AddEvent> {
);
getLocation
()
async
{
position
=
await
Geolocator
.
getCurrentPosition
(
desiredAccuracy:
LocationAccuracy
.
high
);
print
(
'Get Location: Lat:'
+
position
.
latitude
.
toString
()
+
' Long:'
+
position
.
longitude
.
toString
()
+
' Alt:'
+
position
.
altitude
.
toString
());
long
=
position
.
longitude
.
toString
();
lat
=
position
.
latitude
.
toString
();
alt
=
position
.
altitude
.
toString
();
accuracy
=
position
.
accuracy
;
if
(
mounted
){
setState
(()
{
//refresh UI
});};
StreamSubscription
<
Position
>
positionStream
=
Geolocator
.
getPositionStream
(
locationSettings:
locationSettings
)
.
listen
((
Position
position
)
{
p
rint
(
'Get Location: Lat:'
+
position
.
latitude
.
toString
()
+
debugP
rint
(
'Get Location: Lat:'
+
position
.
latitude
.
toString
()
+
' Long:'
+
position
.
longitude
.
toString
()
+
' Alt:'
+
position
.
altitude
.
toString
());
...
...
@@ -54,38 +39,39 @@ class _AddEventPageState extends State<AddEvent> {
accuracy
=
position
.
accuracy
;
if
(
disableG
nss
Editing
==
true
)
{
if
(
disableG
NSS
Editing
==
true
)
{
if
(
mounted
){
setState
(()
{
//refresh UI on update
});}
;
});}
};
});
}
startGNSS
()
async
{
print
(
"CheckGnssPermission"
);
servicestatus
=
await
Geolocator
.
isLocationServiceEnabled
();
if
(
servicestatus
){
debugPrint
(
"Check Location Permission"
);
bool
serviceStatus
=
false
;
bool
hasPermission
=
false
;
serviceStatus
=
await
Geolocator
.
isLocationServiceEnabled
();
if
(
serviceStatus
){
permission
=
await
Geolocator
.
checkPermission
();
if
(
permission
==
LocationPermission
.
denied
)
{
permission
=
await
Geolocator
.
requestPermission
();
if
(
permission
==
LocationPermission
.
denied
)
{
p
rint
(
'Location permissions are denied'
);
debugP
rint
(
'Location permissions are denied'
);
}
else
if
(
permission
==
LocationPermission
.
deniedForever
){
p
rint
(
'Location permissions are permanently denied'
);
debugP
rint
(
'Location permissions are permanently denied'
);
}
else
{
has
p
ermission
=
true
;
has
P
ermission
=
true
;
}
}
else
{
has
p
ermission
=
true
;
has
P
ermission
=
true
;
}
if
(
has
p
ermission
){
p
rint
(
'Location permissions granted'
);
if
(
this
.
mounted
){
if
(
has
P
ermission
){
debugP
rint
(
'Location permissions granted'
);
if
(
mounted
){
setState
(()
{
//refresh the UI
});};
...
...
@@ -93,12 +79,12 @@ class _AddEventPageState extends State<AddEvent> {
getLocation
();
}
}
else
{
p
rint
(
"GPS Service is not enabled, turn on GPS location"
);
debugP
rint
(
"GPS Service is not enabled, turn on GPS location"
);
}
if
(
this
.
mounted
){
if
(
mounted
){
setState
(()
{
//refresh the UI
});}
;
});}
}
@override
...
...
@@ -132,9 +118,8 @@ class _AddEventPageState extends State<AddEvent> {
final
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
String
gnssStatusText
=
""
;
if
(
true
==
disableGnssEditing
){
// Update current event coordinates
if
(
true
==
disableGNSSEditing
){
// Update current event coordinates from GNSS stream
currentEvent
.
store
.
latitude
=
lat
;
currentEvent
.
store
.
longitude
=
long
;
currentEvent
.
store
.
elevation
=
alt
;
...
...
@@ -147,8 +132,7 @@ class _AddEventPageState extends State<AddEvent> {
}
}
else
{
// Just display old event coordinates
gnssStatusText
=
"GNSS Disabled"
;
gnssStatusText
=
"GNSS Disabled"
;
// Just display existing event coordinates
}
return
Scaffold
(
...
...
@@ -210,7 +194,7 @@ class _AddEventPageState extends State<AddEvent> {
),
TextField
(
readOnly:
false
,
enabled:
!
disableG
nss
Editing
,
enabled:
!
disableG
NSS
Editing
,
//controller: _controllerLat,
controller:
TextEditingController
(
text:
currentEvent
.
store
.
latitude
.
toString
()),
decoration:
const
InputDecoration
(
...
...
@@ -220,7 +204,7 @@ class _AddEventPageState extends State<AddEvent> {
),
TextField
(
readOnly:
false
,
enabled:
!
disableG
nss
Editing
,
enabled:
!
disableG
NSS
Editing
,
controller:
TextEditingController
(
text:
currentEvent
.
store
.
longitude
.
toString
()),
decoration:
const
InputDecoration
(
labelText:
'Longitude'
,
...
...
@@ -229,7 +213,7 @@ class _AddEventPageState extends State<AddEvent> {
),
TextField
(
readOnly:
false
,
enabled:
!
disableG
nss
Editing
,
enabled:
!
disableG
NSS
Editing
,
controller:
TextEditingController
(
text:
currentEvent
.
store
.
elevation
.
toString
()),
decoration:
const
InputDecoration
(
labelText:
'Elevation'
,
...
...
@@ -250,7 +234,7 @@ class _AddEventPageState extends State<AddEvent> {
onPressed:
(
int
index
)
{
setState
(()
{
_isGNSSSelected
[
index
]
=
!
_isGNSSSelected
[
index
];
disableG
nss
Editing
=
_isGNSSSelected
[
index
];
disableG
NSS
Editing
=
_isGNSSSelected
[
index
];
});
},
),
...
...
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