From 5cc95545286e9a01e301a0b8487abf71bbe9ffa6 Mon Sep 17 00:00:00 2001
From: Maximilian Betz <Maximilian.Betz@awi.de>
Date: Mon, 21 Mar 2022 13:05:29 +0100
Subject: [PATCH] minor updated

---
 lib/viewevents.dart | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/lib/viewevents.dart b/lib/viewevents.dart
index 23369ae..b470729 100644
--- a/lib/viewevents.dart
+++ b/lib/viewevents.dart
@@ -12,12 +12,15 @@ class ViewEvents extends StatefulWidget {
 }
 
 class _ViewEvents extends State<ViewEvents> {
-  int _synccounter = 0;  //For displaying progress during event upload
+  // Get singleton to access locally stored events:
+  EventStoreInstance events = EventStoreInstance();
+  //TODO: add exception handling and display exceptions to user.
 
   Future<bool> syncEvents() async {
-    final EventStoreInstance events = EventStoreInstance();
+    //final EventStoreInstance events = EventStoreInstance();
     final ConfigurationStoreInstance configuration = ConfigurationStoreInstance();
     SensorConnector connection = SensorConnector();
+    int _synccounter = 0;  //For displaying progress during event upload
 
     String? token = await connection.getAuthToken(configuration.loginInformation.mail,
         configuration.loginInformation.password);
@@ -37,8 +40,8 @@ class _ViewEvents extends State<ViewEvents> {
             _synccounter--;
             debugPrint('put success, remaining events: ' + _synccounter.toString());
             event.status = 'EXPORTED'; //Update event status so that it is only exported once.
+            setState(() {});
           }
-          setState(() {});
         }
       }
       return true;
@@ -48,17 +51,20 @@ class _ViewEvents extends State<ViewEvents> {
 
   @override
   Widget build(BuildContext context) {
-    // Get singleton to access locally stored events:
-    final EventStoreInstance events = EventStoreInstance();
+
     return Scaffold(
       appBar: AppBar(
         title: const Text("View Added Events"),
       ),
-      body: SingleChildScrollView(
+      body: Container(
+      margin: const EdgeInsets.symmetric(horizontal: 5.0),
+      child:
+      SingleChildScrollView(
         scrollDirection: Axis.horizontal,
         child: SingleChildScrollView(
           scrollDirection: Axis.vertical,
           child: DataTable(
+
             columns: const <DataColumn>[
               DataColumn(
                 label: Text(
@@ -184,7 +190,9 @@ class _ViewEvents extends State<ViewEvents> {
                     DataCell(
                       TextFormField(
                         readOnly: true,
-                        initialValue: event.status,
+                        controller: TextEditingController(  //Required to update field here
+                            text: event.status,
+                        ),
                         onFieldSubmitted: (val) {
                           event.status = val; //Update Database
                         },
@@ -196,9 +204,11 @@ class _ViewEvents extends State<ViewEvents> {
           ),
         ),
       ),
+      ),
       bottomNavigationBar: Row(
-        mainAxisAlignment: MainAxisAlignment.end,
+        mainAxisAlignment: MainAxisAlignment.spaceBetween,
         children: [
+          Text('Remaining events to sync: ' + events.getPendingEventCount().toString()),
           FloatingActionButton.extended(
             heroTag: null,
             tooltip: 'Upload Events',
@@ -231,7 +241,7 @@ class _ViewEvents extends State<ViewEvents> {
           //Text("Progress"),
           const CircularProgressIndicator(),
           const SizedBox(height: 10),
-          Text('Remaining events to sync: ' + _synccounter.toString()),
+          Text('Remaining events to sync'),
         ],
       ),
       actions: <Widget>[
-- 
GitLab