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