From 028072b8cc9ff0b5d7c1bec1d01482a3dc25742d Mon Sep 17 00:00:00 2001 From: Maximilian Betz <Maximilian.Betz@awi.de> Date: Fri, 10 Jun 2022 15:39:10 +0200 Subject: [PATCH] some preparations for editing existing events from viewevents --- README.md | 16 +++---- lib/viewevents.dart | 106 ++++++++++++++++---------------------------- 2 files changed, 47 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 0e2968d..2c48606 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ A cross plattform project for android and ios to log events offline everywhere a - Functionality to export events locally for backup in the field! -## TODOs +# TODOs - Allow adding an event to more than one device (urn)! "make UrnId => UrnIds" sync a event to every listed urn. ? Really needed? - Compile an Apple iOS version. - On older Android 6 Devices the following error is shown" OS Error CERTIFICATE_VERIFY_FAILED: certificate has expired". Fix or require at least Android x? @@ -57,25 +57,25 @@ Text: #57827E - Add Impressum: CC-BY licence - Add Legal Notice as on sensor.awi.de +## Overview +- Add Icon to Add, View and Configuration button. Then use uppercase Text. - -# Configuration +## Configuration - animated Feedbackpopup on first line : "speech bubble" (Download successfull) Show pop up for 2s. "Detail information as is below the collection dropdown menu. - Collection List Drop Down. Item separation "grey line" + Abbort button. "Highlight "chosen collection" italic or pinned on top. Sort alphabetic. -# Add Event +## Add Event - Show \* next to lable for required fields. - Event Type /URN Item separation and hightlighting chosen type as in configuration. - Is a field for end time required here? -# View & Events -- "All Events" "Pending Events" on first line above table. Alligned right. 50pix hight distance to table start. +## View & Events +- "All Events" "Pending Events" on first line above table. Alligned right. 50pix hight distance to table start. - Multiple lines for one event to reduce width. Alternative: Do not show all event details in table but show them in a separate widget on selection. This could also be the view to edit event details. - Edit mode. Select an event and open event in edit mode with all event details - Allow to remove pending events. - Feedback "Success" to line above table and below top bar. -# Overview -- Add Icon to Add, View and Configuration button. Then use uppercase Text. + diff --git a/lib/viewevents.dart b/lib/viewevents.dart index e3c08df..f4db460 100644 --- a/lib/viewevents.dart +++ b/lib/viewevents.dart @@ -16,6 +16,7 @@ class _ViewEvents extends State<ViewEvents> { String _status = ''; TextStyle _statusStyle = const TextStyle(color: Colors.black); String _appBarText = ''; + int _selectedRow = -1; var database = DatabaseInstance(); List<Event> _localEvents = []; @@ -132,13 +133,7 @@ class _ViewEvents extends State<ViewEvents> { columns: const <DataColumn>[ DataColumn( label: Text( - 'UrnId', - style: TextStyle(fontStyle: FontStyle.italic), - ), - ), - DataColumn( - label: Text( - 'URN', + '(ID) URN', style: TextStyle(fontStyle: FontStyle.italic), ), ), @@ -198,71 +193,48 @@ class _ViewEvents extends State<ViewEvents> { ), ], rows: <DataRow>[ - for (var event in _localEvents) + //for (var event in _localEvents) + for (var i = 0; i < _localEvents.length; i++) DataRow( + selected: i == _selectedRow, + onLongPress: () { + debugPrint("Selected Row: " + i.toString()); + //TODO: open widget to edit the rows event values. Provide "cancel" and "update" functionality + //TODO: display "Exported Events are read only, Edit via Sensor.awi.de" when trying to edit. + debugPrint(_localEvents[i].toString()); + + //Navigator.pushNamed(context, '/second', arguments: {'event': _localEvents[i]},); + // TODO: create an edit widget. As Add Event, GNSS editing always enabled, No GNSS switch, Now Button? + + /* //How to get the argument. + @override + Widget build(BuildContext context) { + final arguments = (ModalRoute.of(context)?.settings.arguments ?? <String, dynamic>{}) as Map; + + print(arguments['exampleArgument']); + + return Scaffold(...); + } + */ + + + }, cells: <DataCell>[ - DataCell(Text(event.urnId.toString())), - DataCell(Text(event.urn)), + //DataCell(Text(_localEvents[i].urnId.toString())), + DataCell(Text('('+_localEvents[i].urnId.toString()+') ' + _localEvents[i].urn)), DataCell( - TextFormField( - readOnly: true, - initialValue: event.label, - onFieldSubmitted: (val) { - event.label = val; //Update Database - }, - ), - ), - DataCell(Text(event.type)), - DataCell( - TextFormField( - readOnly: true, - initialValue: event.description, - onFieldSubmitted: (val) { - event.description = val; //Update Database - }, - ), + Text(_localEvents[i].label), ), + DataCell(Text(_localEvents[i].type)), + DataCell(Text(_localEvents[i].description)), + //Do not show microseconds - DataCell(Text(event.startDate.substring(0, 19) + 'Z')), - DataCell(Text(event.endDate.substring(0, 19) + 'Z')), - DataCell( - TextFormField( - readOnly: true, - initialValue: event.latitude, - onFieldSubmitted: (val) { - event.latitude = val; //Update Database - }, - ), - ), - DataCell( - TextFormField( - readOnly: true, - initialValue: event.longitude, - onFieldSubmitted: (val) { - event.longitude = val; //Update Database - }, - ), - ), - DataCell( - TextFormField( - readOnly: true, - initialValue: event.elevation == '' ? '' : double.parse(event.elevation).toStringAsFixed(2), - onFieldSubmitted: (val) { - event.elevation = val; //Update Database - }, - ), - ), - DataCell( - TextFormField( - readOnly: true, - controller: TextEditingController( //Required to update field here - text: event.status, - ), - onFieldSubmitted: (val) { - event.status = val; //Update Database - }, - ), - ), + DataCell(Text(_localEvents[i].startDate.substring(0, 19) + 'Z')), + DataCell(Text(_localEvents[i].endDate.substring(0, 19) + 'Z')), + DataCell(Text(_localEvents[i].latitude)), + DataCell(Text(_localEvents[i].longitude)), + DataCell(Text(_localEvents[i].elevation == '' ? '' : double.parse(_localEvents[i].elevation).toStringAsFixed(2))), + DataCell(Text(_localEvents[i].status)), ], ), ], -- GitLab