Skip to content
Snippets Groups Projects
Commit d3525993 authored by Maximilian Betz's avatar Maximilian Betz
Browse files

simplified textfields and enabled editing in all modes

parent e0541d00
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,9 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
TextEditingController labelEditingController = TextEditingController();
TextEditingController oldLengthEditingController = TextEditingController();
TextEditingController newLengthEditingController = TextEditingController();
Future startRest() async {
final ConfigurationStoreInstance configuration = ConfigurationStoreInstance();
final EventStoreInstance event = EventStoreInstance();
......@@ -187,9 +190,12 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
//Update current event with prefix and cnt
event.currentEvent.label = configuration.labelConfig.prefix + configuration.labelConfig.cnt.toString().padLeft(3, '0');
labelEditingController.text = event.currentEvent.label;
angleStatus = angleStatusItems[0];
oldLengthEditingController.text = lengthOld.toString();
newLengthEditingController.text = lengthNew.toString();
super.initState();
}
......@@ -376,6 +382,15 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
);
}
void _resetSelectedFields(){
measurementStatusId = -1;
rodColorValuesIdOld = -1;
rodColorValuesIdNew = -1;
angleStatus = angleStatusItems[0];
lengthOld = 0;
lengthNew = 0;
}
Future<void> _storeCurrentMeasurementEvent(BuildContext context, bool addAngle, bool addOldLength, bool addNewLength) async {
final EventStoreInstance event = EventStoreInstance();
......@@ -428,12 +443,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
event.currentEvent.endDate = isoDate;
// Reset fields for next event
measurementStatusId = -1;
rodColorValuesIdOld = -1;
rodColorValuesIdNew = -1;
angleStatus = angleStatusItems[0];
lengthOld = 0;
lengthNew = 0;
_resetSelectedFields();
await event.storeToSharedPrefs();
......@@ -555,18 +565,22 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
),
const SizedBox(height: 15.0),
TextFormField(
readOnly: false,
enabled: false,
style: const TextStyle(fontSize: 30.0),
keyboardType: TextInputType.number,
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: TextEditingController(
text: "Length: ${rawMeasurementValue.toString()} [mm]"
),
decoration: const InputDecoration(
labelText: '', //Example
border: OutlineInputBorder(),
Visibility(
visible: event.gnssSync,
child:
TextFormField(
readOnly: false,
enabled: false,
style: const TextStyle(fontSize: 30.0),
keyboardType: TextInputType.number,
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: TextEditingController(
text: "Length: ${rawMeasurementValue.toString()} [mm]"
),
decoration: const InputDecoration(
labelText: '', //Example
border: OutlineInputBorder(),
),
),
),
const SizedBox(height: 15.0),
......@@ -642,7 +656,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
]
),
const SizedBox(height: 15.0),
const SizedBox(height: 30.0),
Visibility(
visible: displayAngle,
child:
......@@ -652,7 +666,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
isExpanded: true,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Angle',
labelText: 'old angle',
),
items:
angleStatusItems.map((String angle) {
......@@ -670,61 +684,23 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
const SizedBox(height: 15.0),
Visibility(
visible: displayOldLength,
child: event.gnssSync ?
TextFormField(
readOnly: false,
enabled: true,
keyboardType: TextInputType.number,
autovalidateMode: AutovalidateMode.onUserInteraction,
inputFormatters:[FilteringTextInputFormatter.allow(RegExp("[0-9]"))],
controller: TextEditingController(
text: lengthOld.toString(),
),
decoration: const InputDecoration(
labelText: 'old 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 [mm]";
},
) :
child:
TextFormField(
readOnly: false,
enabled: true,
keyboardType: TextInputType.number,
autovalidateMode: AutovalidateMode.onUserInteraction,
inputFormatters:[FilteringTextInputFormatter.allow(RegExp("[0-9]"))],
initialValue: lengthOld.toString(),
controller: oldLengthEditingController,
decoration: const InputDecoration(
labelText: 'old length', //Example
border: OutlineInputBorder(),
),
onChanged: (value) {
lengthOld = int.parse(value);
setState(() {});
},
onFieldSubmitted: (value){
if (!event.gnssSync) {
setState(() {});
}
},
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]";
},
) ,
),
),
const SizedBox(height: 5.0),
Visibility(
......@@ -794,6 +770,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
onPressed: () {
lengthOld = rawMeasurementValue + 0;
oldLengthEditingController.text = lengthOld.toString();
setState(() {});
},
child: const Text('+0m'),
......@@ -805,6 +782,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
onPressed: () {
lengthOld = rawMeasurementValue + 2000; //2m offset
oldLengthEditingController.text = lengthOld.toString();
setState(() {});
},
child: const Text('+2m'),
......@@ -813,61 +791,31 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
),
const SizedBox(height: 30.0),
Visibility(
visible: displayNewLength,
child: event.gnssSync ?
child:
TextFormField(
readOnly: false,
enabled: true,
keyboardType: TextInputType.number,
autovalidateMode: AutovalidateMode.onUserInteraction,
inputFormatters:[FilteringTextInputFormatter.allow(RegExp("[0-9]"))],
controller: TextEditingController(
text: lengthNew.toString()
),
controller: newLengthEditingController,
decoration: const InputDecoration(
labelText: 'new length', //Example
border: OutlineInputBorder(),
),
onChanged: (value) {
lengthNew = int.parse(value);
},
onFieldSubmitted: (value){
if (!event.gnssSync) {
setState(() {});
}
},
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]";
},
) :
TextFormField(
readOnly: false,
enabled: true,
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]";
setState(() {});
},
),
),
......@@ -939,6 +887,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
onPressed: () {
lengthNew = rawMeasurementValue + 0;
newLengthEditingController.text = lengthOld.toString();
setState(() {});
},
child: const Text('+0m'),
......@@ -950,6 +899,7 @@ class _AddEventKottasPegelPageState extends State<AddEventKottasPegel> {
),
onPressed: () {
lengthNew = rawMeasurementValue + 2000; //2m offset
newLengthEditingController.text = lengthOld.toString();
setState(() {});
},
child: const Text('+2m'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment