From f04ddb40e112fd4faff57e32fd69a8bf65ea53de Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 18:13:34 +0100 Subject: [PATCH 1/4] display days correct --- lib/utils/timer_util.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/timer_util.dart b/lib/utils/timer_util.dart index 57b9f9c..554173a 100644 --- a/lib/utils/timer_util.dart +++ b/lib/utils/timer_util.dart @@ -9,7 +9,7 @@ String formatTime(int seconds) { String minutes = twoDigits(duration.inMinutes.remainder(60)); String formattedSeconds = twoDigits(duration.inSeconds.remainder(60)); if (duration.inDays != 0) { - formattedTime += '$days Tag ${duration.inDays > 1 ? "e" : ""}, '; + formattedTime += '$days Tag${duration.inDays > 1 ? "e" : ""}, '; } if (duration.inHours != 0) formattedTime += '$hours:'; formattedTime += '$minutes:'; From d18231966ccd1b17bfa538cc1a222d90c8933d48 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 18:39:36 +0100 Subject: [PATCH 2/4] fix scanner, try catch export --- lib/models/settings.dart | 2 +- lib/services/export_service.dart | 18 ++++++++++++------ lib/services/settings_service.dart | 3 +-- lib/widgets/scanner.dart | 7 +++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/models/settings.dart b/lib/models/settings.dart index dfa79be..1954cc8 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -19,7 +19,7 @@ class Settings { chessTime = json['chess_time'] != null ? TimeConfig.fromJson(json['chess_time']) : null, - startedAt = DateTime.parse(json['startedAt']); + startedAt = DateTime.now(); } class QueryConfig { diff --git a/lib/services/export_service.dart b/lib/services/export_service.dart index 9758270..223ecf3 100644 --- a/lib/services/export_service.dart +++ b/lib/services/export_service.dart @@ -33,11 +33,17 @@ class ExportService { Future exportData() async { Map> body = await _loadRecords(); - final response = await http.post(url, - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - }, - body: jsonEncode(body)); - return response.statusCode >= 400 ? 0 : 1; + try { + final response = await http.post(url, + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: jsonEncode(body)); + return response.statusCode >= 400 ? 0 : 1; + } catch (e) { + // ignore: avoid_print + print(jsonEncode(body)); + return 0; + } } } diff --git a/lib/services/settings_service.dart b/lib/services/settings_service.dart index ec8a656..7349c75 100644 --- a/lib/services/settings_service.dart +++ b/lib/services/settings_service.dart @@ -49,7 +49,6 @@ Future?> _getStringListSetting(String settingKey) => Future loadSettingsFromLocalJSON() async { Map configJSON = await loadLocalConfigJSON(); - configJSON['startedAt'] = DateTime.now().toIso8601String(); Settings settings = Settings.fromJson(configJSON); saveSettings(settings); } @@ -63,7 +62,7 @@ void saveSettings(Settings settings) { _setStringListSetting('sleep_query_days', settings.sleepQuery!.days!); _setIntSetting('sleep_query_hours', settings.sleepQuery!.hours!); _setIntSetting('sleep_query_minutes', settings.sleepQuery!.minutes!); - _setStringSetting('startedAt', DateTime.now().toIso8601String()); + _setStringSetting('startedAt', settings.startedAt.toIso8601String()); if (settings.chessTime != null) { _setIntSetting('chess_hours', settings.chessTime!.hours!); _setIntSetting('chess_minutes', settings.chessTime!.minutes!); diff --git a/lib/widgets/scanner.dart b/lib/widgets/scanner.dart index c292bf4..0eed1e4 100644 --- a/lib/widgets/scanner.dart +++ b/lib/widgets/scanner.dart @@ -16,7 +16,8 @@ class MyScanner extends StatelessWidget { Widget build(BuildContext context) { SettingsProvider settingsProvider = context.watch(); - void handleSucces(String? rawValue) { + void handleSuccess(String? rawValue) { + print('in Success: $rawValue'); String qrText = rawValue!; Map json = stringToJSON(qrText); Settings settings = Settings.fromJson(json); @@ -49,10 +50,12 @@ class MyScanner extends StatelessWidget { final List barcodes = capture.barcodes; for (final barcode in barcodes) { if (barcode.rawValue != null) { - return handleSucces(barcode.rawValue); + print(barcode.rawValue); + return handleSuccess(barcode.rawValue); } } } catch (e) { + print(e); handleError(); } } From ebc5776e78b80aa2dac2932e452b200863d6b080 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 18:51:00 +0100 Subject: [PATCH 3/4] add asset background --- lib/globals.dart | 2 +- lib/pages/main_page.dart | 9 ++++++++- pubspec.yaml | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/globals.dart b/lib/globals.dart index 3cdf823..1381241 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -7,4 +7,4 @@ DatabaseService databaseService = DatabaseMock(); // DatabaseService databaseService = DatabaseService.instance; // set this to read settings from local json file instead of scanning a qr code -bool useLocalConfig = false; +bool useLocalConfig = true; diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index 9d6c77b..2fd100f 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -37,7 +37,14 @@ class MyHomePage extends StatelessWidget { '${pageProvider.currentPageData['title']} ${isConfigured ? "Gruppe ${settingsProvider.settings?.group}" : ""}') ], )), - body: pageProvider.currentPageData['page'], + body: Stack(alignment: Alignment.center, children: [ + Image.asset( + 'assets/ZI_logo.png', + opacity: const AlwaysStoppedAnimation(0.05), + width: MediaQuery.of(context).size.width * 0.8, + ), + pageProvider.currentPageData['page'], + ]), bottomNavigationBar: NavigationBar( onDestinationSelected: isConfigured ? pageProvider.setCurrentPage diff --git a/pubspec.yaml b/pubspec.yaml index ac1fafe..79d6adc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,3 +48,4 @@ flutter: - assets/finish.mp3 - assets/group1.json - assets/group3.json + - assets/ZI_logo.png From 597fe9224c4716b17963f19805c82f7b5f4f9199 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 6 Mar 2023 19:04:49 +0100 Subject: [PATCH 4/4] remove prints --- lib/widgets/scanner.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/widgets/scanner.dart b/lib/widgets/scanner.dart index 0eed1e4..19864a8 100644 --- a/lib/widgets/scanner.dart +++ b/lib/widgets/scanner.dart @@ -17,7 +17,6 @@ class MyScanner extends StatelessWidget { SettingsProvider settingsProvider = context.watch(); void handleSuccess(String? rawValue) { - print('in Success: $rawValue'); String qrText = rawValue!; Map json = stringToJSON(qrText); Settings settings = Settings.fromJson(json); @@ -50,12 +49,10 @@ class MyScanner extends StatelessWidget { final List barcodes = capture.barcodes; for (final barcode in barcodes) { if (barcode.rawValue != null) { - print(barcode.rawValue); return handleSuccess(barcode.rawValue); } } } catch (e) { - print(e); handleError(); } }