From 15be6cd1ee5075ad4317dccdbe3bf16ff1971ac1 Mon Sep 17 00:00:00 2001
From: Maximilian Betz <Maximilian.Betz@awi.de>
Date: Wed, 16 Feb 2022 14:41:30 +0100
Subject: [PATCH] some progress

---
 README.md              | 13 ++++++++++++-
 lib/addevent.dart      |  8 ++++++--
 lib/configuration.dart | 29 +++++++++++++++--------------
 lib/viewevents.dart    |  2 ++
 4 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/README.md b/README.md
index 4486d17..1b250e9 100644
--- a/README.md
+++ b/README.md
@@ -37,4 +37,15 @@ A cross plattform project for android and ios to log events offline everywhere a
 
 ## GNSS
 - Checkbox on add event page which activates GNSS locationing. A field shall signal "no fix" or presision in meter. 
-The fields lat, long, elevation are updated automatically if checkbox is checked. 
\ No newline at end of file
+The fields lat, long, elevation are updated automatically if checkbox is checked. 
+
+
+
+# Input validation 
+
+a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , : 
+ 
+-90 => Latitude <= +90
+-180 => Latitude <= +180
+ Elevation: any numer
+ 
diff --git a/lib/addevent.dart b/lib/addevent.dart
index c3a55b5..746cb23 100644
--- a/lib/addevent.dart
+++ b/lib/addevent.dart
@@ -1,5 +1,6 @@
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
 import 'datamodel.dart';
 import 'dart:async';
 import 'package:geolocator/geolocator.dart';
@@ -255,9 +256,12 @@ class _AddEventPageState extends State<AddEvent>  {
           const SizedBox(width: 50),
           FloatingActionButton(
             heroTag: null,
-            onPressed: _storeCurrentEvent,
+            onPressed: () {
+              _storeCurrentEvent();
+              HapticFeedback.vibrate();
+            },
             tooltip: 'Add Event',
-            child: const Icon(Icons.add),
+            child: const Icon(Icons.check),
           ),
           const SizedBox(width: 20),
         ],
diff --git a/lib/configuration.dart b/lib/configuration.dart
index 0083978..84e9492 100644
--- a/lib/configuration.dart
+++ b/lib/configuration.dart
@@ -6,7 +6,7 @@ import 'datamodel.dart';
 
 
 Future<Collection> fetchCollection() async {
-  print("Start HTTP GET++##");
+  debugPrint("Start HTTP GET++##");
 
   final response = await http
       .get(Uri.parse('https://sensor.awi.de/rest/sensors/collections/getCollection/22'));
@@ -23,13 +23,12 @@ Future<Collection> fetchCollection() async {
 }
 
 Future<List<Collection>> fetchCollections() async {
-  print("Fetching Collections...");
-
+  debugPrint("Fetching Collections...");
+  List<Collection> collectionList = [];
   final response = await http
       .get(Uri.parse('https://sensor.awi.de/rest/sensors/collections/getAllCollections?pointInTime=2018-07-03T12%3A30%3A55.389Z'));
 
   if (response.statusCode == 200) {
-    List<Collection> collectionList;
     return (json.decode(response.body) as List)
         .map((i) => Collection.fromJson(i))
         .toList();
@@ -37,12 +36,16 @@ Future<List<Collection>> fetchCollections() async {
   } else {
     // If the server did not return a 200 OK response,
     // then throw an exception.
-    throw Exception('Failed to load Collection');
+    //throw Exception('Failed to load Collection');
+    debugPrint('Failed to load Collection');
+    return collectionList;
   }
 }
 
 
 class Configuration extends StatefulWidget {
+  const Configuration({Key? key}) : super(key: key);
+
   @override
   State<Configuration> createState() => _MyHomePageState();
 }
@@ -57,7 +60,6 @@ class _MyHomePageState extends State<Configuration> {
     super.initState();
     futureCollection = fetchCollection();
     futureCollections = fetchCollections();
-
   }
   late Future<String> eventTypes;
 
@@ -69,7 +71,7 @@ class _MyHomePageState extends State<Configuration> {
 
     return Scaffold(
       appBar: AppBar(
-        title: Text('Configuration'),
+        title: const Text('Configuration'),
       ),
       body: Center(
         child: Column(
@@ -80,12 +82,11 @@ class _MyHomePageState extends State<Configuration> {
                 builder: (context, snapshot){
                   if (snapshot.hasData)
                   {
-                    print(snapshot.data);
+                    debugPrint('Got collections:');
+                    snapshot.data?.forEach((element) {
+                      debugPrint(element.id.toString() + ' ' + element.toString() + '   #' + element.description.toString());
+                    });
 
-                    print(futureCollections);
-                    //storedCollections.store = snapshot.data!;  // Store data locally
-                    //var listlen = storedCollections.store.length();
-                    //print('Length ###: ' + storedCollections.store.length().toString());
 
                     return DropdownButtonFormField(
                         value: currentCollection.store.collectionName,
@@ -105,7 +106,7 @@ class _MyHomePageState extends State<Configuration> {
                     );
                   }
                   else{
-                    return CircularProgressIndicator();
+                    return const CircularProgressIndicator();
                   }
                 }
             ),
@@ -117,7 +118,7 @@ class _MyHomePageState extends State<Configuration> {
                     return Text(snapshot.data!.collectionName);
                   }
                   else{
-                    return CircularProgressIndicator();
+                    return const CircularProgressIndicator();
                   }
                 }
             ),
diff --git a/lib/viewevents.dart b/lib/viewevents.dart
index 9330cfd..31dff0f 100644
--- a/lib/viewevents.dart
+++ b/lib/viewevents.dart
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
 import 'datamodel.dart';
 
 class ViewEvents extends StatelessWidget {
+  const ViewEvents({Key? key}) : super(key: key);
+
   @override
   Widget build(BuildContext context) {
     // Get singleton to access locally stored events:
-- 
GitLab