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

some progress

parent 35104c2b
No related branches found
No related tags found
No related merge requests found
...@@ -37,4 +37,15 @@ A cross plattform project for android and ios to log events offline everywhere a ...@@ -37,4 +37,15 @@ A cross plattform project for android and ios to log events offline everywhere a
## GNSS ## GNSS
- Checkbox on add event page which activates GNSS locationing. A field shall signal "no fix" or presision in meter. - 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. The fields lat, long, elevation are updated automatically if checkbox is checked.
\ No newline at end of file
# Input validation
a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , :
-90 => Latitude <= +90
-180 => Latitude <= +180
Elevation: any numer
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'datamodel.dart'; import 'datamodel.dart';
import 'dart:async'; import 'dart:async';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
...@@ -255,9 +256,12 @@ class _AddEventPageState extends State<AddEvent> { ...@@ -255,9 +256,12 @@ class _AddEventPageState extends State<AddEvent> {
const SizedBox(width: 50), const SizedBox(width: 50),
FloatingActionButton( FloatingActionButton(
heroTag: null, heroTag: null,
onPressed: _storeCurrentEvent, onPressed: () {
_storeCurrentEvent();
HapticFeedback.vibrate();
},
tooltip: 'Add Event', tooltip: 'Add Event',
child: const Icon(Icons.add), child: const Icon(Icons.check),
), ),
const SizedBox(width: 20), const SizedBox(width: 20),
], ],
......
...@@ -6,7 +6,7 @@ import 'datamodel.dart'; ...@@ -6,7 +6,7 @@ import 'datamodel.dart';
Future<Collection> fetchCollection() async { Future<Collection> fetchCollection() async {
print("Start HTTP GET++##"); debugPrint("Start HTTP GET++##");
final response = await http final response = await http
.get(Uri.parse('https://sensor.awi.de/rest/sensors/collections/getCollection/22')); .get(Uri.parse('https://sensor.awi.de/rest/sensors/collections/getCollection/22'));
...@@ -23,13 +23,12 @@ Future<Collection> fetchCollection() async { ...@@ -23,13 +23,12 @@ Future<Collection> fetchCollection() async {
} }
Future<List<Collection>> fetchCollections() async { Future<List<Collection>> fetchCollections() async {
print("Fetching Collections..."); debugPrint("Fetching Collections...");
List<Collection> collectionList = [];
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'));
if (response.statusCode == 200) { if (response.statusCode == 200) {
List<Collection> collectionList;
return (json.decode(response.body) as List) return (json.decode(response.body) as List)
.map((i) => Collection.fromJson(i)) .map((i) => Collection.fromJson(i))
.toList(); .toList();
...@@ -37,12 +36,16 @@ Future<List<Collection>> fetchCollections() async { ...@@ -37,12 +36,16 @@ Future<List<Collection>> fetchCollections() async {
} else { } else {
// If the server did not return a 200 OK response, // If the server did not return a 200 OK response,
// then throw an exception. // 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 { class Configuration extends StatefulWidget {
const Configuration({Key? key}) : super(key: key);
@override @override
State<Configuration> createState() => _MyHomePageState(); State<Configuration> createState() => _MyHomePageState();
} }
...@@ -57,7 +60,6 @@ class _MyHomePageState extends State<Configuration> { ...@@ -57,7 +60,6 @@ class _MyHomePageState extends State<Configuration> {
super.initState(); super.initState();
futureCollection = fetchCollection(); futureCollection = fetchCollection();
futureCollections = fetchCollections(); futureCollections = fetchCollections();
} }
late Future<String> eventTypes; late Future<String> eventTypes;
...@@ -69,7 +71,7 @@ class _MyHomePageState extends State<Configuration> { ...@@ -69,7 +71,7 @@ class _MyHomePageState extends State<Configuration> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('Configuration'), title: const Text('Configuration'),
), ),
body: Center( body: Center(
child: Column( child: Column(
...@@ -80,12 +82,11 @@ class _MyHomePageState extends State<Configuration> { ...@@ -80,12 +82,11 @@ class _MyHomePageState extends State<Configuration> {
builder: (context, snapshot){ builder: (context, snapshot){
if (snapshot.hasData) 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( return DropdownButtonFormField(
value: currentCollection.store.collectionName, value: currentCollection.store.collectionName,
...@@ -105,7 +106,7 @@ class _MyHomePageState extends State<Configuration> { ...@@ -105,7 +106,7 @@ class _MyHomePageState extends State<Configuration> {
); );
} }
else{ else{
return CircularProgressIndicator(); return const CircularProgressIndicator();
} }
} }
), ),
...@@ -117,7 +118,7 @@ class _MyHomePageState extends State<Configuration> { ...@@ -117,7 +118,7 @@ class _MyHomePageState extends State<Configuration> {
return Text(snapshot.data!.collectionName); return Text(snapshot.data!.collectionName);
} }
else{ else{
return CircularProgressIndicator(); return const CircularProgressIndicator();
} }
} }
), ),
......
...@@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; ...@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'datamodel.dart'; import 'datamodel.dart';
class ViewEvents extends StatelessWidget { class ViewEvents extends StatelessWidget {
const ViewEvents({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Get singleton to access locally stored events: // Get singleton to access locally stored events:
......
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