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
ca455853
Commit
ca455853
authored
2 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
some more edge cases considered and implemented
parent
6c20b8a5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sw/lib/addeventkottaspegel.dart
+113
-62
113 additions, 62 deletions
sw/lib/addeventkottaspegel.dart
with
113 additions
and
62 deletions
sw/lib/addeventkottaspegel.dart
+
113
−
62
View file @
ca455853
...
@@ -23,7 +23,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -23,7 +23,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
List
<
int
>
measurementOffsets
=
[
0
,
1000
,
2000
,
3000
];
//Colors no, green, red, blue
List
<
int
>
measurementOffsets
=
[
0
,
1000
,
2000
,
3000
];
//Colors no, green, red, blue
//Parameters which shall be added to the measurement event as json string data
//Parameters which shall be added to the measurement event as json string data
List
<
String
>
measurementStatusItems
=
[
'ok'
,
'broken'
,
'missing'
'tilted'
,
];
List
<
String
>
measurementStatusItems
=
[
'ok'
,
'broken'
,
'missing'
,
'tilted'
];
int
measurementStatusId
=
-
1
;
int
measurementStatusId
=
-
1
;
late
String
angleStatus
;
late
String
angleStatus
;
...
@@ -33,6 +33,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -33,6 +33,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
bool
syncGNSSData
=
true
;
bool
syncGNSSData
=
true
;
bool
_addButtonEnabled
=
true
;
bool
_addButtonEnabled
=
true
;
bool
_eventAdded
=
false
;
bool
displayAngle
=
true
;
bool
displayAngle
=
true
;
bool
displayOldLength
=
true
;
bool
displayOldLength
=
true
;
...
@@ -78,7 +79,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -78,7 +79,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
event
.
currentEvent
.
latitude
=
""
;
event
.
currentEvent
.
latitude
=
""
;
event
.
currentEvent
.
longitude
=
""
;
event
.
currentEvent
.
longitude
=
""
;
event
.
currentEvent
.
elevation
=
""
;
event
.
currentEvent
.
elevation
=
""
;
rawMeasurementValue
=
-
1
;
rawMeasurementValue
=
0
;
debugPrint
(
"Rest Query failed
$e
"
);
debugPrint
(
"Rest Query failed
$e
"
);
}
}
...
@@ -167,12 +168,6 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -167,12 +168,6 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
event
.
currentEvent
.
label
=
configuration
.
labelConfig
.
prefix
+
configuration
.
labelConfig
.
cnt
.
toString
();
event
.
currentEvent
.
label
=
configuration
.
labelConfig
.
prefix
+
configuration
.
labelConfig
.
cnt
.
toString
();
angleStatus
=
angleStatusItems
[
0
];
angleStatus
=
angleStatusItems
[
0
];
//Set the device URN for the event fixed here! TODO: create device in sensor, add to a collection!
//event.currentEvent.urn TODO: set the urn here!
//event.currentEvent.urnId
super
.
initState
();
super
.
initState
();
}
}
...
@@ -251,7 +246,9 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -251,7 +246,9 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
if
(
_validateLatitude
(
event
.
currentEvent
.
latitude
)){
if
(
_validateLatitude
(
event
.
currentEvent
.
latitude
)){
if
(
_validateLongitude
(
event
.
currentEvent
.
longitude
)){
if
(
_validateLongitude
(
event
.
currentEvent
.
longitude
)){
if
(
_validateElevation
(
event
.
currentEvent
.
elevation
)){
if
(
_validateElevation
(
event
.
currentEvent
.
elevation
)){
return
true
;
if
(
measurementStatusId
>
=
0
&&
measurementStatusId
<
measurementStatusItems
.
length
)
{
return
true
;
}
}
}
}
}
}
}
...
@@ -340,7 +337,6 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -340,7 +337,6 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
Future
<
void
>
_storeCurrentMeasurementEvent
(
BuildContext
context
)
async
{
Future
<
void
>
_storeCurrentMeasurementEvent
(
BuildContext
context
)
async
{
final
EventStoreInstance
event
=
EventStoreInstance
();
final
EventStoreInstance
event
=
EventStoreInstance
();
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
//TODO: validate all event fields to check if they fullfill the sensor.awi.de requirements for events.
event
.
currentEvent
.
urn
=
'station:neumayer_iii:snow_level_measure'
;
event
.
currentEvent
.
urn
=
'station:neumayer_iii:snow_level_measure'
;
event
.
currentEvent
.
urnId
=
9094
;
//TODO: this is a prototype. Shall later somehow configurable
event
.
currentEvent
.
urnId
=
9094
;
//TODO: this is a prototype. Shall later somehow configurable
...
@@ -358,35 +354,48 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -358,35 +354,48 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
};
};
//TODO: extend Database and add payload field.
//TODO: extend Database and add payload field.
debugPrint
(
'Payload
$data
'
);
debugPrint
(
'Payload
$data
'
);
await
database
.
addEvent
(
event
.
currentEvent
);
await
database
.
addEvent
(
event
.
currentEvent
);
HapticFeedback
.
vibrate
();
//Feedback that adding event succeeded
HapticFeedback
.
vibrate
();
//Feedback that adding event succeeded
_addButtonEnabled
=
true
;
//Activate button for add more events
setState
(()
{});
//Get next Label prefix, id and event timestamp
//_showAddSuccessOverlay(context); //Show pop up to indicated adding event succeeded.
if
(
configuration
.
labelConfig
.
cntUp
==
true
){
_showResultPopup
(
context
,
"Successfully created Event !"
,
false
);
configuration
.
labelConfig
.
cnt
++
;
//TODO: add flag and set/reset here! Use flag for disabling the "create event" button until _storeCurrentMeasurementEvent finished.
}
else
{
configuration
.
labelConfig
.
cnt
--
;
}
event
.
currentEvent
.
label
=
configuration
.
labelConfig
.
prefix
+
configuration
.
labelConfig
.
cnt
.
toString
();
//Get next Label prefix and id
var
date
=
DateTime
.
now
()
.
toUtc
();
var
date
=
DateTime
.
now
()
.
toUtc
();
var
isoDate
=
date
.
toIso8601String
();
var
isoDate
=
date
.
toIso8601String
();
event
.
currentEvent
.
startDate
=
isoDate
;
event
.
currentEvent
.
startDate
=
isoDate
;
event
.
currentEvent
.
endDate
=
isoDate
;
event
.
currentEvent
.
endDate
=
isoDate
;
// Reset fields for next event
measurementStatusId
=
-
1
;
angleStatus
=
angleStatusItems
[
0
];
lengthOld
=
0
;
lengthNew
=
0
;
await
event
.
storeToSharedPrefs
();
await
configuration
.
storeToSharedPrefs
();
_addButtonEnabled
=
true
;
//Activate button to add more events
_eventAdded
=
true
;
// Trigger popup in build method
setState
(()
{});
}
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
/* Get singletons to access relevant data here.*/
/* Get singletons to access relevant data here.*/
final
EventStoreInstance
event
Store
=
EventStoreInstance
();
final
EventStoreInstance
event
=
EventStoreInstance
();
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
String
switchStatusText
=
""
;
String
switchStatusText
=
""
;
String
switchStatusTextLine2
=
""
;
String
switchStatusTextLine2
=
""
;
if
(
true
==
event
Store
.
gnssSync
){
if
(
true
==
event
.
gnssSync
){
switchStatusText
=
"External REST Data"
;
switchStatusText
=
"External REST Data"
;
}
}
else
{
else
{
...
@@ -400,7 +409,6 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -400,7 +409,6 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
}
}
// Set visibility parameters
// Set visibility parameters
measurementStatusItems
=
[
'ok'
,
'broken'
,
'missing'
'tilted'
,];
displayAngle
=
false
;
displayAngle
=
false
;
displayOldLength
=
false
;
displayOldLength
=
false
;
displayNewLength
=
false
;
displayNewLength
=
false
;
...
@@ -421,14 +429,13 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -421,14 +429,13 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
displayNewLength
=
true
;
displayNewLength
=
true
;
}
}
// Validate Input and disable add button if input not correct
if
(
true
==
_eventAdded
){
if
(
true
==
_validateInput
()){
_eventAdded
=
false
;
_addButtonEnabled
=
true
;
}
else
{
_addButtonEnabled
=
false
;
}
Future
.
delayed
(
Duration
.
zero
,()
{
_showResultPopup
(
context
,
"Successfully created Event !"
,
false
);
});
}
if
(
configuration
.
initialized
==
true
)
{
if
(
configuration
.
initialized
==
true
)
{
return
Scaffold
(
return
Scaffold
(
...
@@ -442,12 +449,12 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -442,12 +449,12 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
],
],
),
),
Switch
(
//Enable showing all or only pending events. Default is to show only pending events
Switch
(
//Enable showing all or only pending events. Default is to show only pending events
value:
event
Store
.
gnssSync
,
value:
event
.
gnssSync
,
onChanged:
(
value
)
{
onChanged:
(
value
)
{
event
Store
.
gnssSync
=
value
;
event
.
gnssSync
=
value
;
debugPrint
(
'Switched to:
${event
Store
.gnssSync}
'
);
debugPrint
(
'Switched to:
${event.gnssSync}
'
);
accuracy
=
0.0
;
accuracy
=
0.0
;
if
(
event
Store
.
gnssSync
){
if
(
event
.
gnssSync
){
// Get data from rest / raspberry pi
// Get data from rest / raspberry pi
streamHandler
.
cancel
();
streamHandler
.
cancel
();
startRest
();
startRest
();
...
@@ -456,16 +463,12 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -456,16 +463,12 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
// Get data from internal GNSS
// Get data from internal GNSS
restQueryTimer
.
cancel
();
restQueryTimer
.
cancel
();
startGNSS
();
startGNSS
();
rawMeasurementValue
=
-
1
;
//Clear Raw Measurement value
rawMeasurementValue
=
0
;
//Clear Raw Measurement value
}
}
setState
(()
{
setState
(()
{});
//refresh the UI
});
}),
}),
],
],
),
)
,
body:
SingleChildScrollView
(
body:
SingleChildScrollView
(
child:
Container
(
child:
Container
(
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
5.0
),
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
5.0
),
...
@@ -481,10 +484,10 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -481,10 +484,10 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
controller:
TextEditingController
(
controller:
TextEditingController
(
text:
""
text:
""
"
${event
Store
.currentEvent.startDate.substring(11,19)}
/ "
"
${event.currentEvent.startDate.substring(11,19)}
/ "
"
${event
Store
.currentEvent.latitude}
/ "
"
${event.currentEvent.latitude}
/ "
"
${event
Store
.currentEvent.longitude}
/ "
"
${event.currentEvent.longitude}
/ "
"
${event
Store
.currentEvent.elevation}
"
"
${event.currentEvent.elevation}
"
),
),
decoration:
const
InputDecoration
(
decoration:
const
InputDecoration
(
labelText:
'UTC / Lat / Long / Elv '
,
//Example
labelText:
'UTC / Lat / Long / Elv '
,
//Example
...
@@ -508,14 +511,16 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -508,14 +511,16 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
),
const
SizedBox
(
height:
15.0
),
const
SizedBox
(
height:
15.0
),
TextFormField
(
TextFormField
(
initialValue:
eventStore
.
currentEvent
.
label
,
controller:
TextEditingController
(
text:
event
.
currentEvent
.
label
,
),
autovalidateMode:
AutovalidateMode
.
always
,
autovalidateMode:
AutovalidateMode
.
always
,
decoration:
const
InputDecoration
(
decoration:
const
InputDecoration
(
border:
OutlineInputBorder
(),
border:
OutlineInputBorder
(),
labelText:
'Label'
,
labelText:
'Label'
,
),
),
onChanged:
(
value
){
onChanged:
(
value
){
event
Store
.
currentEvent
.
label
=
value
;
event
.
currentEvent
.
label
=
value
;
setState
(()
{});
setState
(()
{});
},
},
validator:
(
value
)
{
validator:
(
value
)
{
...
@@ -608,12 +613,13 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -608,12 +613,13 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
const
SizedBox
(
height:
15.0
),
const
SizedBox
(
height:
15.0
),
Visibility
(
Visibility
(
visible:
displayOldLength
,
visible:
displayOldLength
,
child:
child:
event
.
gnssSync
?
TextFormField
(
TextFormField
(
readOnly:
false
,
readOnly:
false
,
enabled:
!
event
Store
.
gnssSync
,
enabled:
!
event
.
gnssSync
,
keyboardType:
TextInputType
.
number
,
keyboardType:
TextInputType
.
number
,
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
inputFormatters:
[
FilteringTextInputFormatter
.
allow
(
RegExp
(
"[0-9]"
))],
controller:
TextEditingController
(
controller:
TextEditingController
(
text:
lengthOld
.
toString
(),
text:
lengthOld
.
toString
(),
),
),
...
@@ -621,11 +627,33 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -621,11 +627,33 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
labelText:
'old length'
,
//Example
labelText:
'old length'
,
//Example
border:
OutlineInputBorder
(),
border:
OutlineInputBorder
(),
),
),
validator:
(
value
)
{
if
(
value
==
""
)
{
return
null
;
// Empty value is allowed
}
final
number
=
num
.
tryParse
(
value
!
);
if
(
number
!=
null
){
return
null
;
// Elevation valid
}
return
"Only numerical values [mm]"
;
},
)
:
TextFormField
(
readOnly:
false
,
enabled:
!
event
.
gnssSync
,
keyboardType:
TextInputType
.
number
,
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
inputFormatters:
[
FilteringTextInputFormatter
.
allow
(
RegExp
(
"[0-9]"
))],
initialValue:
lengthOld
.
toString
(),
decoration:
const
InputDecoration
(
labelText:
'old length'
,
//Example
border:
OutlineInputBorder
(),
),
onChanged:
(
value
)
{
onChanged:
(
value
)
{
lengthOld
=
int
.
parse
(
value
);
lengthOld
=
int
.
parse
(
value
);
},
},
onFieldSubmitted:
(
value
){
onFieldSubmitted:
(
value
){
if
(
!
event
Store
.
gnssSync
)
{
if
(
!
event
.
gnssSync
)
{
setState
(()
{});
setState
(()
{});
}
}
},
},
...
@@ -639,7 +667,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -639,7 +667,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
}
}
return
"Only numerical values [mm]"
;
return
"Only numerical values [mm]"
;
},
},
),
)
,
),
),
const
SizedBox
(
height:
5.0
),
const
SizedBox
(
height:
5.0
),
Visibility
(
Visibility
(
...
@@ -651,7 +679,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -651,7 +679,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
ElevatedButton
(
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
style:
ElevatedButton
.
styleFrom
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
primary:
event
Store
.
gnssSync
==
true
?
Colors
.
grey
:
Colors
.
grey
,
primary:
event
.
gnssSync
==
true
?
Colors
.
grey
:
Colors
.
grey
,
),
),
onPressed:
()
{
onPressed:
()
{
lengthOld
=
rawMeasurementValue
+
measurementOffsets
[
0
];
lengthOld
=
rawMeasurementValue
+
measurementOffsets
[
0
];
...
@@ -663,7 +691,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -663,7 +691,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
ElevatedButton
(
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
style:
ElevatedButton
.
styleFrom
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
primary:
event
Store
.
gnssSync
==
true
?
Colors
.
green
:
Colors
.
grey
,
primary:
event
.
gnssSync
==
true
?
Colors
.
green
:
Colors
.
grey
,
),
),
onPressed:
()
{
onPressed:
()
{
lengthOld
=
rawMeasurementValue
+
measurementOffsets
[
1
];
lengthOld
=
rawMeasurementValue
+
measurementOffsets
[
1
];
...
@@ -676,7 +704,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -676,7 +704,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
ElevatedButton
(
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
style:
ElevatedButton
.
styleFrom
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
primary:
event
Store
.
gnssSync
==
true
?
Colors
.
red
:
Colors
.
grey
,
primary:
event
.
gnssSync
==
true
?
Colors
.
red
:
Colors
.
grey
,
),
),
onPressed:
()
{
onPressed:
()
{
lengthOld
=
rawMeasurementValue
+
measurementOffsets
[
2
];
lengthOld
=
rawMeasurementValue
+
measurementOffsets
[
2
];
...
@@ -688,7 +716,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -688,7 +716,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
ElevatedButton
(
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
style:
ElevatedButton
.
styleFrom
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
primary:
event
Store
.
gnssSync
==
true
?
Colors
.
blue
:
Colors
.
grey
,
primary:
event
.
gnssSync
==
true
?
Colors
.
blue
:
Colors
.
grey
,
),
),
onPressed:
()
{
onPressed:
()
{
lengthOld
=
rawMeasurementValue
+
measurementOffsets
[
3
];
lengthOld
=
rawMeasurementValue
+
measurementOffsets
[
3
];
...
@@ -702,12 +730,13 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -702,12 +730,13 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
const
SizedBox
(
height:
15.0
),
const
SizedBox
(
height:
15.0
),
Visibility
(
Visibility
(
visible:
displayNewLength
,
visible:
displayNewLength
,
child:
child:
event
.
gnssSync
?
TextFormField
(
TextFormField
(
readOnly:
false
,
readOnly:
false
,
enabled:
!
event
Store
.
gnssSync
,
enabled:
!
event
.
gnssSync
,
keyboardType:
TextInputType
.
number
,
keyboardType:
TextInputType
.
number
,
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
inputFormatters:
[
FilteringTextInputFormatter
.
allow
(
RegExp
(
"[0-9]"
))],
controller:
TextEditingController
(
controller:
TextEditingController
(
text:
lengthNew
.
toString
()
text:
lengthNew
.
toString
()
),
),
...
@@ -719,7 +748,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -719,7 +748,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
lengthNew
=
int
.
parse
(
value
);
lengthNew
=
int
.
parse
(
value
);
},
},
onFieldSubmitted:
(
value
){
onFieldSubmitted:
(
value
){
if
(
!
event
Store
.
gnssSync
)
{
if
(
!
event
.
gnssSync
)
{
setState
(()
{});
setState
(()
{});
}
}
},
},
...
@@ -733,6 +762,28 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -733,6 +762,28 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
}
}
return
"Only numerical values for elevation in [m]"
;
return
"Only numerical values for elevation in [m]"
;
},
},
)
:
TextFormField
(
readOnly:
false
,
enabled:
!
event
.
gnssSync
,
keyboardType:
TextInputType
.
number
,
autovalidateMode:
AutovalidateMode
.
onUserInteraction
,
inputFormatters:
[
FilteringTextInputFormatter
.
allow
(
RegExp
(
"[0-9]"
))],
initialValue:
lengthNew
.
toString
(),
decoration:
const
InputDecoration
(
labelText:
'new length'
,
//Example
border:
OutlineInputBorder
(),
),
validator:
(
value
)
{
if
(
value
==
""
)
{
return
null
;
// Empty value is allowed
}
final
number
=
num
.
tryParse
(
value
!
);
if
(
number
!=
null
){
return
null
;
// Elevation valid
}
return
"Only numerical values for elevation in [m]"
;
},
),
),
),
),
const
SizedBox
(
height:
5.0
),
const
SizedBox
(
height:
5.0
),
...
@@ -745,7 +796,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -745,7 +796,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
ElevatedButton
(
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
style:
ElevatedButton
.
styleFrom
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
primary:
event
Store
.
gnssSync
==
true
?
Colors
.
grey
:
Colors
.
grey
,
primary:
event
.
gnssSync
==
true
?
Colors
.
grey
:
Colors
.
grey
,
),
),
onPressed:
()
{
onPressed:
()
{
lengthNew
=
rawMeasurementValue
+
measurementOffsets
[
0
];
lengthNew
=
rawMeasurementValue
+
measurementOffsets
[
0
];
...
@@ -757,7 +808,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -757,7 +808,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
ElevatedButton
(
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
style:
ElevatedButton
.
styleFrom
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
primary:
event
Store
.
gnssSync
==
true
?
Colors
.
green
:
Colors
.
grey
,
primary:
event
.
gnssSync
==
true
?
Colors
.
green
:
Colors
.
grey
,
),
),
onPressed:
()
{
onPressed:
()
{
lengthNew
=
rawMeasurementValue
+
measurementOffsets
[
1
];
lengthNew
=
rawMeasurementValue
+
measurementOffsets
[
1
];
...
@@ -769,7 +820,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -769,7 +820,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
ElevatedButton
(
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
style:
ElevatedButton
.
styleFrom
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
primary:
event
Store
.
gnssSync
==
true
?
Colors
.
red
:
Colors
.
grey
,
primary:
event
.
gnssSync
==
true
?
Colors
.
red
:
Colors
.
grey
,
),
),
onPressed:
()
{
onPressed:
()
{
lengthNew
=
rawMeasurementValue
+
measurementOffsets
[
2
];
lengthNew
=
rawMeasurementValue
+
measurementOffsets
[
2
];
...
@@ -781,7 +832,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -781,7 +832,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
ElevatedButton
(
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
style:
ElevatedButton
.
styleFrom
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
//TODO: find a more dynamic solution without a fixed value
primary:
event
Store
.
gnssSync
==
true
?
Colors
.
blue
:
Colors
.
grey
,
primary:
event
.
gnssSync
==
true
?
Colors
.
blue
:
Colors
.
grey
,
),
),
onPressed:
()
{
onPressed:
()
{
lengthNew
=
rawMeasurementValue
+
measurementOffsets
[
3
];
lengthNew
=
rawMeasurementValue
+
measurementOffsets
[
3
];
...
@@ -794,14 +845,14 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
...
@@ -794,14 +845,14 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
),
const
SizedBox
(
height:
15.0
),
const
SizedBox
(
height:
15.0
),
TextFormField
(
TextFormField
(
initialValue:
event
Store
.
currentEvent
.
description
,
initialValue:
event
.
currentEvent
.
description
,
autovalidateMode:
AutovalidateMode
.
always
,
autovalidateMode:
AutovalidateMode
.
always
,
decoration:
const
InputDecoration
(
decoration:
const
InputDecoration
(
border:
OutlineInputBorder
(),
border:
OutlineInputBorder
(),
labelText:
'Description'
labelText:
'Description'
),
),
onChanged:
(
value
){
onChanged:
(
value
){
event
Store
.
currentEvent
.
description
=
value
;
event
.
currentEvent
.
description
=
value
;
setState
(()
{});
setState
(()
{});
},
},
validator:
(
value
)
{
validator:
(
value
)
{
...
...
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