diff --git a/lib/viewevents.dart b/lib/viewevents.dart index 23369ae689b3cb3eaee0c6888144142a2c5c07d7..b47072937d209279c315aafa216732d3cac841c5 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>[