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

expanded urn field to two lines

parent c0a9ff21
No related branches found
No related tags found
No related merge requests found
......@@ -270,6 +270,7 @@ class _AddEventPageState extends State<AddEvent> {
const SizedBox(height: 15.0),
DropdownButtonFormField(
value: eventStore.currentEvent.urn,
isDense: false,
isExpanded: true,
decoration: const InputDecoration(
border: OutlineInputBorder(),
......@@ -512,10 +513,13 @@ class _AddEventPageState extends State<AddEvent> {
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: const <Widget>[
Text(
' Visit Configuration first',
style: TextStyle(fontSize: 20)
children: <Widget>[
Container(
margin: const EdgeInsets.all(10.0),
child:const Text(
'Check Configuration Page for initial setup!',
style: TextStyle(fontSize: 20)
),
),
],
),
......
......@@ -66,6 +66,9 @@ class _MyHomePageState extends State<Configuration> {
configuration.devices = await connector.fetchCollectionDevices(configuration.currentCollection.id); //await futureDevices; //already fetched just use the data.
configuration.eventTypes = await connector.fetchEventTypes();
if (configuration.devices.isEmpty){
throw Exception('Collection with 0 devices.');
}
event.currentEvent.id = 0;
event.currentEvent.urnId = configuration.devices[0].id; //TODO: fix if devices are an empty list.
event.currentEvent.urn = configuration.devices[0].urn;
......@@ -139,7 +142,7 @@ class _MyHomePageState extends State<Configuration> {
children: <Widget>[
const SizedBox(height: 50),
const Text(
'You must be online to do something here!',
'Online access required for initial configuration!',
style: TextStyle(fontSize: 14)
),
const SizedBox(height: 50),
......@@ -244,6 +247,11 @@ class _MyHomePageState extends State<Configuration> {
label: const Text('Dump Events'),
onPressed: () {
dumpToFile();
//Reset for debug testing only. //Remove in RELEASE Version:
database.delete();
events.reset();
configuration.reset();
},
),
FloatingActionButton.extended(
......@@ -253,7 +261,6 @@ class _MyHomePageState extends State<Configuration> {
label: const Text('Set'),
onPressed: () {
updateConfiguration();
//TODO: display failed as user feedback somehow
},
),
],
......
......@@ -333,7 +333,7 @@ abstract class ConfigurationStoreBase {
devices = [];
eventTypes = [];
currentCollection = Collection(id: -1, description: '', collectionName: '');
loginInformation = SensorLogin('admin', 'adminadmin');
loginInformation = SensorLogin('', '');
initialized = false;
}
}
......@@ -343,6 +343,12 @@ class ConfigurationStoreInstance extends ConfigurationStoreBase {
static final ConfigurationStoreInstance _instance = ConfigurationStoreInstance
._internal();
@override
void reset(){
super.reset();
deleteSharedPrefs();
}
Future<void> storeToSharedPrefs() async {
const secureStorage = FlutterSecureStorage();
......@@ -377,6 +383,15 @@ class ConfigurationStoreInstance extends ConfigurationStoreBase {
}
}
Future<void> deleteSharedPrefs() async {
final prefs = await SharedPreferences.getInstance();
prefs.clear();
await prefs.remove('configuration');
const secureStorage = FlutterSecureStorage();
secureStorage.delete(key: 'login');
}
factory ConfigurationStoreInstance() {
return _instance;
}
......@@ -445,6 +460,11 @@ class EventStoreInstance extends EventStoreBase {
}
}
Future<void> deleteSharedPrefs() async {
final prefs = await SharedPreferences.getInstance();
await prefs.remove('currentEvent');
}
factory EventStoreInstance() {
return _instance;
}
......@@ -468,6 +488,8 @@ class EventStoreInstance extends EventStoreBase {
}
void reset(){
gnssSync = true;
showAllEvents = false;
currentEvent = Event(
id:0,
urnId:-1,
......@@ -483,6 +505,7 @@ class EventStoreInstance extends EventStoreBase {
longitude: '',
elevation: ''
);
deleteSharedPrefs();
}
}
......
......@@ -19,7 +19,6 @@ class _ViewEvents extends State<ViewEvents> {
var database = DatabaseInstance();
List<Event> _localEvents = [];
Future<void> fetchEventsFromDb() async{
final EventStoreInstance event = EventStoreInstance();
int pendingEvents = 0;
......@@ -47,6 +46,15 @@ class _ViewEvents extends State<ViewEvents> {
fetchEventsFromDb();
}
@override
void dispose() async {
/*Async update current configuration to shared preferences*/
final EventStoreInstance event = EventStoreInstance();
event.storeToSharedPrefs();
super.dispose();
}
Future<void> syncEvents() async {
final ConfigurationStoreInstance configuration = ConfigurationStoreInstance();
SensorConnector connection = SensorConnector();
......
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