From dd811ff9b109b0ba2dc15ca4cca7e371b792e667 Mon Sep 17 00:00:00 2001
From: Maximilian Betz <Maximilian.Betz@awi.de>
Date: Mon, 13 Jun 2022 15:19:13 +0200
Subject: [PATCH] preparing own sync widget on viewevents

---
 README.md           |  8 +++++++-
 lib/overview.dart   |  6 ++++++
 lib/viewevents.dart | 48 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 2cacd7c..19d5d1e 100644
--- a/README.md
+++ b/README.md
@@ -63,6 +63,8 @@ Text: #57827E
 - 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 a selection mode functionality. 1. Own devices (based on e-mail adress as editor on devices), 2. Collections, 3. Mission management based
+- https://sandbox.sensor.awi.de/rest/sensors/device/getItemsOfContact/mbetz%40awi.de
+- Split in two widgets? 1st to login und 2nd to configure. Allow configuration only with successfull login? 
 
 ## Add Event
 - Show \* next to lable for required fields. 
@@ -72,14 +74,18 @@ Text: #57827E
 - Block creation of a new event for e.g. 2 seconds after creation. This shall prevent unintended creation of multiple events. 
 - Deactivate Timestamp field and Now button if GNSS sync active. 
 - Choose Urns in configuration: Label on Add Event is beeing cleared but GNSS data is not Harmonize. 
+- GNSS switch next to lat long elevation field. Similar as the NOW field. (Feedback from Dana)
 
 ## 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 (only pending events). Select an event and open event in edit mode with all details (including start and finish time), allow to remove event.
 - Feedback "Success" to line above table and below top bar. 
-- Show sync widget, show sync status, allow canceling of sync process. E.g. an error can be caused if "Sync" is pressed multiple times in the View & Sync Widget as multiple async functions are syncing events in parallel. Simple solution would be to deactivate the sync button if a sync process is active. 
+- Show sync widget (similar to the information widget), show sync status progress, allow canceling of sync process. Currently an error can be caused if "Sync" is pressed multiple times in the View & Sync Widget as multiple async functions are syncing events in parallel. Simple solution would be to deactivate the sync button if a sync process is active. 
+- Clone event data from here to Add Event widget. 
 
+## Wishlist:
+- Allow upload of pictures  check interface how to upload with sensor. 
 
 
 
diff --git a/lib/overview.dart b/lib/overview.dart
index 95c2eb0..03140c8 100644
--- a/lib/overview.dart
+++ b/lib/overview.dart
@@ -30,6 +30,12 @@ class Overview extends StatelessWidget {
         ],
       ),
       actions: <Widget>[
+        TextButton(
+          onPressed: () {
+            //TODO: show legal notices text
+          },
+          child: const Text('Legal notices'),
+        ),
         TextButton(
           onPressed: () {
             Navigator.of(context).pop();
diff --git a/lib/viewevents.dart b/lib/viewevents.dart
index f4db460..c28c43d 100644
--- a/lib/viewevents.dart
+++ b/lib/viewevents.dart
@@ -20,6 +20,46 @@ class _ViewEvents extends State<ViewEvents> {
   var database = DatabaseInstance();
   List<Event> _localEvents = [];
 
+  Widget _buildSyncDialog(BuildContext context) {
+    SensorConnector sensorConnector = SensorConnector();
+
+
+
+    return WillPopScope(
+        onWillPop: () async => false,
+        child: AlertDialog(
+          content: Column(
+            mainAxisSize: MainAxisSize.min,
+            crossAxisAlignment: CrossAxisAlignment.center,
+            children: const <Widget>[
+              Text('Syncing Events...'),
+              //TODO: show progress bar here.,  Horizontal progress bar?
+              //TODO: show text XX pending events. count down
+            ],
+          ),
+          actions: <Widget>[
+            TextButton(
+              onPressed: () {
+                //Start sync process but only once.
+              },
+              child: const Text('Start'),  //Change text to Syncing... during Sync process.
+            ),
+            TextButton(
+              onPressed: () {
+                // Depending on state. Cancel or close. TODO: implement statemachine.
+                Navigator.of(context).pop();
+              },
+              child: const Text('Close'),  // Change to Cancel during Sync process.
+            ),
+          ],
+        )
+    );
+
+
+
+
+  }
+
   Future<void> fetchEventsFromDb() async{
     final EventStoreInstance event = EventStoreInstance();
     int pendingEvents = 0;
@@ -256,6 +296,14 @@ class _ViewEvents extends State<ViewEvents> {
               label: const Text('Sync'),
               onPressed: () {
                 syncEvents();
+
+                //showDialog(
+                //  barrierDismissible: false,
+                //  context: context,
+                //  builder: (BuildContext context) => _buildSyncDialog(context),
+                //);
+
+
               },
             ),
           ],
-- 
GitLab