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

text input validation halfway done

parent a9bf4a1b
No related branches found
No related tags found
No related merge requests found
......@@ -124,6 +124,9 @@ class _AddEventPageState extends State<AddEvent> {
final EventCurrentInstance currentEvent = EventCurrentInstance();
String gnssStatusText = "";
final formKey = GlobalKey<FormState>(); //key for form
if (true == syncGNSSData){
// Update current event coordinates from GNSS stream
currentEvent.store.latitude = lat;
......@@ -149,12 +152,23 @@ class _AddEventPageState extends State<AddEvent> {
children: <Widget>[
TextFormField(
initialValue: currentEvent.store.label,
autovalidateMode: AutovalidateMode.onUserInteraction,
decoration: const InputDecoration(
labelText: 'Label'
labelText: 'Label',
errorText: 'Only: a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , :'
),
onChanged: (value) {
currentEvent.store.label = value;
},
validator: (value){
if(!RegExp(r'^[a-z A-Z . \- 0-9 , ( ) + - _ :]+$').hasMatch(value!)){
return "Only: a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , :";
}else{
currentEvent.store.label = value;
return ''; // Entered Text is valid
}
},
),
DropdownButtonFormField(
value: currentEvent.store.type,
......
......@@ -43,6 +43,8 @@ Future<List<Device>> updateDevices(int collectionId) async {
Future<List<Collection>> fetchCollections() async {
debugPrint("Fetching Collections...");
List<Collection> collectionList = [];
CollectionStoreInstance collections = CollectionStoreInstance();
final response = await http
.get(Uri.parse('https://sensor.awi.de/rest/sensors/collections/getAllCollections?pointInTime=2018-07-03T12%3A30%3A55.389Z'));
......@@ -73,7 +75,6 @@ class _MyHomePageState extends State<Configuration> {
@override
void initState() {
super.initState();
//futureCollection = fetchCollection();
futureCollections = fetchCollections();
}
late Future<String> eventTypes;
......@@ -109,10 +110,13 @@ class _MyHomePageState extends State<Configuration> {
/*Initialize active collection with first received
collection if not initialized yet*/
if(activeCollection.store.collectionName == ''){
if(activeCollection.store.id == -1){
activeCollection.store = collections.store[0];
}
print(activeCollection.store);
print(collections.store);
return DropdownButtonFormField(
value: activeCollection.store.collectionName,
decoration: const InputDecoration(
......
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