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

selecting collection ui works

parent 15be6cd1
No related branches found
No related tags found
No related merge requests found
...@@ -109,6 +109,7 @@ class _AddEventPageState extends State<AddEvent> { ...@@ -109,6 +109,7 @@ class _AddEventPageState extends State<AddEvent> {
currentEvent.store.latitude, currentEvent.store.latitude,
currentEvent.store.longitude, currentEvent.store.longitude,
currentEvent.store.elevation currentEvent.store.elevation
//TODO: add timestamp! Begin & End
)); ));
} }
......
...@@ -66,8 +66,8 @@ class _MyHomePageState extends State<Configuration> { ...@@ -66,8 +66,8 @@ class _MyHomePageState extends State<Configuration> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final CollectionStoreInstance storedCollections = CollectionStoreInstance(); final CollectionStoreInstance collections = CollectionStoreInstance();
final CollectionCurrentInstance currentCollection = CollectionCurrentInstance(); final CollectionCurrentInstance activeCollection = CollectionCurrentInstance();
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
...@@ -82,26 +82,33 @@ class _MyHomePageState extends State<Configuration> { ...@@ -82,26 +82,33 @@ class _MyHomePageState extends State<Configuration> {
builder: (context, snapshot){ builder: (context, snapshot){
if (snapshot.hasData) if (snapshot.hasData)
{ {
debugPrint('Got collections:'); collections.store = [];
//debugPrint('Got Collections:');
snapshot.data?.forEach((element) { snapshot.data?.forEach((element) {
debugPrint(element.id.toString() + ' ' + element.toString() + ' #' + element.description.toString()); //debugPrint(element.id.toString() + ' ' + element.collectionName.toString() + ' #' + element.description.toString());
collections.store.add(element);
}); });
/*Initialize active collection with first received collection if not initialized yet*/
if(activeCollection.store.collectionName == ''){
activeCollection.store = collections.store[0];
}
return DropdownButtonFormField( return DropdownButtonFormField(
value: currentCollection.store.collectionName, value: activeCollection.store.collectionName,
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: 'Chosen Collection', labelText: 'Chose Collection',
), ),
items: items:
storedCollections.store.map((Collection collection) { collections.store.map((Collection collection) {
return DropdownMenuItem( return DropdownMenuItem(
value: collection.collectionName, value: collection.collectionName,
child: Text(collection.collectionName), child: Text(collection.collectionName),
); );
}).toList(), }).toList(),
onChanged: (value) { onChanged: (value) {
currentCollection.store.collectionName = value.toString(); activeCollection.store = collections.getCollectionFromName(value.toString());
} }
); );
} }
...@@ -110,18 +117,6 @@ class _MyHomePageState extends State<Configuration> { ...@@ -110,18 +117,6 @@ class _MyHomePageState extends State<Configuration> {
} }
} }
), ),
FutureBuilder<Collection>(
future: futureCollection,
builder: (context, snapshot){
if (snapshot.hasData)
{
return Text(snapshot.data!.collectionName);
}
else{
return const CircularProgressIndicator();
}
}
),
], ],
), ),
), ),
......
...@@ -109,6 +109,16 @@ class EventType{ ...@@ -109,6 +109,16 @@ class EventType{
abstract class CollectionStoreBase { abstract class CollectionStoreBase {
List<Collection> store = []; List<Collection> store = [];
Collection getCollectionFromName(String name) {
for (var collection in store) {
if (collection.collectionName == name) {
return collection;
}
}
throw Exception('Event with name :' + name + ' was not found.');
}
} }
class CollectionStoreInstance extends CollectionStoreBase { class CollectionStoreInstance extends CollectionStoreBase {
...@@ -157,7 +167,7 @@ abstract class EventCurrentBase{ ...@@ -157,7 +167,7 @@ abstract class EventCurrentBase{
} }
abstract class CollectionCurrentBase{ abstract class CollectionCurrentBase{
Collection store = Collection(id: -1, description: 'description', collectionName: 'name'); Collection store = Collection(id: -1, description: '', collectionName: '');
} }
abstract class EventTypeStoreBase{ abstract class EventTypeStoreBase{
......
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