From b3b03f9fb74512d2e1d21c0c0d9d79b6e668d836 Mon Sep 17 00:00:00 2001 From: Maximilian Betz <Maximilian.Betz@awi.de> Date: Wed, 19 Jan 2022 14:00:24 +0100 Subject: [PATCH] added fields for adding events --- lib/data_model.dart | 12 ++--- lib/main.dart | 125 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 108 insertions(+), 29 deletions(-) diff --git a/lib/data_model.dart b/lib/data_model.dart index c690bf1..5c914b7 100644 --- a/lib/data_model.dart +++ b/lib/data_model.dart @@ -35,13 +35,13 @@ class Event{ abstract class EventStoreBase{ List<Event> store = []; - void setStore(List<Event> st){ - store = st; - } + //void setStore(List<Event> st){ + // store = st; + //} - void reset(){ - store = []; - } + //void reset(){ + // store = []; + //} } class EventType{ diff --git a/lib/main.dart b/lib/main.dart index 754cbd5..82b6fa3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,29 +2,53 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'data_model.dart'; - -class EventStoreInstance extends EventStoreBase{ +class EventStoreInstance extends EventStoreBase { static final EventStoreInstance _instance = EventStoreInstance._internal(); - factory EventStoreInstance(){ + factory EventStoreInstance() { return _instance; } - EventStoreInstance._internal(){ + EventStoreInstance._internal() { store = []; } - } void main() { - //Add some dummy events to eventstore EventStoreInstance events = EventStoreInstance(); - events.store.add(Event.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1', 'label':'SML_KO21_SC01', 'type':'Deployment', 'description':'Remi tool Tag1 1 Traverse', 'status':'PENDING' })); - events.store.add(Event.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1', 'label':'SML_KO21_SC01', 'type':'Deployment', 'description':'Remi tool Tag1 1 Traverse', 'status':'PENDING' })); - events.store.add(Event.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1', 'label':'SML_KO21_SC01', 'type':'Deployment', 'description':'Remi tool Tag1 1 Traverse', 'status':'PENDING' })); - events.store.add(Event.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1', 'label':'SML_KO21_SC01', 'type':'Deployment', 'description':'Remi tool Tag1 1 Traverse', 'status':'PENDING' })); - + events.store.add(Event.fromJson({ + 'id': 8311, + 'urn': 'station:neumayer_iii:awi_snow_sampler_1', + 'label': 'SML_KO21_SC01', + 'type': 'Deployment', + 'description': 'Remi tool Tag1 1 Traverse', + 'status': 'PENDING' + })); + events.store.add(Event.fromJson({ + 'id': 8311, + 'urn': 'station:neumayer_iii:awi_snow_sampler_1', + 'label': 'SML_KO21_SC01', + 'type': 'Deployment', + 'description': 'Remi tool Tag1 1 Traverse', + 'status': 'PENDING' + })); + events.store.add(Event.fromJson({ + 'id': 8311, + 'urn': 'station:neumayer_iii:awi_snow_sampler_1', + 'label': 'SML_KO21_SC01', + 'type': 'Deployment', + 'description': 'Remi tool Tag1 1 Traverse', + 'status': 'PENDING' + })); + events.store.add(Event.fromJson({ + 'id': 8311, + 'urn': 'station:neumayer_iii:awi_snow_sampler_1', + 'label': 'SML_KO21_SC01', + 'type': 'Deployment', + 'description': 'Remi tool Tag1 1 Traverse', + 'status': 'PENDING' + })); runApp(MaterialApp( title: 'Mobile Event Log', @@ -78,17 +102,73 @@ class AddEvent extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text("Add Event"), - ), - body: Center( - child: ElevatedButton( - onPressed: () { - Navigator.pop(context); - }, - child: const Text('Back!'), - ), - ), + appBar: AppBar(title: const Text("Add Event")), + body: + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: <Widget>[ + TextFormField( + decoration: InputDecoration( + labelText: 'Label' + ), + ), + DropdownButtonFormField( + decoration: InputDecoration( + labelText: 'Event Type', + ), + items: [ + DropdownMenuItem( + child: Text('Calibration'), + value: 'Calibration', + ), + DropdownMenuItem( + child: Text('Information'), + value: 'Information', + ) + ], + onChanged: (value) { + + } + ), + DropdownButtonFormField( + decoration: InputDecoration( + labelText: 'URN', + ), + items: [ + DropdownMenuItem( + child: Text('ADCP'), + value: 'ADCP', + ), + DropdownMenuItem( + child: Text('EM712'), + value: 'EM712', + ) + ], + onChanged: (value) { + + } + ), + TextFormField( + decoration: InputDecoration( + labelText: 'Description' + ), + ), + TextFormField( + decoration: InputDecoration( + labelText: 'Latitude' + ), + ), + TextFormField( + decoration: InputDecoration( + labelText: 'Longitude' + ), + ), + TextFormField( + decoration: InputDecoration( + labelText: 'Elevation' + ), + ) + ]), bottomNavigationBar: Row( mainAxisAlignment: MainAxisAlignment.end, children: const [ @@ -105,7 +185,6 @@ class AddEvent extends StatelessWidget { } class ViewEvents extends StatelessWidget { - @override Widget build(BuildContext context) { // Get singleton to access locally stored events: -- GitLab