Merge branch 'fixes' into 'main'

Fixes

See merge request Crondung/hsma_cpd!36
main
Kai Mannweiler 2023-03-06 18:09:07 +00:00
commit 95d055d316
8 changed files with 27 additions and 14 deletions

View File

@ -7,4 +7,4 @@ DatabaseService databaseService = DatabaseMock();
// DatabaseService databaseService = DatabaseService.instance; // DatabaseService databaseService = DatabaseService.instance;
// set this to read settings from local json file instead of scanning a qr code // set this to read settings from local json file instead of scanning a qr code
bool useLocalConfig = false; bool useLocalConfig = true;

View File

@ -19,7 +19,7 @@ class Settings {
chessTime = json['chess_time'] != null chessTime = json['chess_time'] != null
? TimeConfig.fromJson(json['chess_time']) ? TimeConfig.fromJson(json['chess_time'])
: null, : null,
startedAt = DateTime.parse(json['startedAt']); startedAt = DateTime.now();
} }
class QueryConfig { class QueryConfig {

View File

@ -37,7 +37,14 @@ class MyHomePage extends StatelessWidget {
'${pageProvider.currentPageData['title']} ${isConfigured ? "Gruppe ${settingsProvider.settings?.group}" : ""}') '${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( bottomNavigationBar: NavigationBar(
onDestinationSelected: isConfigured onDestinationSelected: isConfigured
? pageProvider.setCurrentPage ? pageProvider.setCurrentPage

View File

@ -33,11 +33,17 @@ class ExportService {
Future<int> exportData() async { Future<int> exportData() async {
Map<String, List<String>> body = await _loadRecords(); Map<String, List<String>> body = await _loadRecords();
final response = await http.post(url, try {
headers: <String, String>{ final response = await http.post(url,
'Content-Type': 'application/json; charset=UTF-8', headers: <String, String>{
}, 'Content-Type': 'application/json; charset=UTF-8',
body: jsonEncode(body)); },
return response.statusCode >= 400 ? 0 : 1; body: jsonEncode(body));
return response.statusCode >= 400 ? 0 : 1;
} catch (e) {
// ignore: avoid_print
print(jsonEncode(body));
return 0;
}
} }
} }

View File

@ -49,7 +49,6 @@ Future<List<String>?> _getStringListSetting(String settingKey) =>
Future<void> loadSettingsFromLocalJSON() async { Future<void> loadSettingsFromLocalJSON() async {
Map<String, dynamic> configJSON = await loadLocalConfigJSON(); Map<String, dynamic> configJSON = await loadLocalConfigJSON();
configJSON['startedAt'] = DateTime.now().toIso8601String();
Settings settings = Settings.fromJson(configJSON); Settings settings = Settings.fromJson(configJSON);
saveSettings(settings); saveSettings(settings);
} }
@ -63,7 +62,7 @@ void saveSettings(Settings settings) {
_setStringListSetting('sleep_query_days', settings.sleepQuery!.days!); _setStringListSetting('sleep_query_days', settings.sleepQuery!.days!);
_setIntSetting('sleep_query_hours', settings.sleepQuery!.hours!); _setIntSetting('sleep_query_hours', settings.sleepQuery!.hours!);
_setIntSetting('sleep_query_minutes', settings.sleepQuery!.minutes!); _setIntSetting('sleep_query_minutes', settings.sleepQuery!.minutes!);
_setStringSetting('startedAt', DateTime.now().toIso8601String()); _setStringSetting('startedAt', settings.startedAt.toIso8601String());
if (settings.chessTime != null) { if (settings.chessTime != null) {
_setIntSetting('chess_hours', settings.chessTime!.hours!); _setIntSetting('chess_hours', settings.chessTime!.hours!);
_setIntSetting('chess_minutes', settings.chessTime!.minutes!); _setIntSetting('chess_minutes', settings.chessTime!.minutes!);

View File

@ -9,7 +9,7 @@ String formatTime(int seconds) {
String minutes = twoDigits(duration.inMinutes.remainder(60)); String minutes = twoDigits(duration.inMinutes.remainder(60));
String formattedSeconds = twoDigits(duration.inSeconds.remainder(60)); String formattedSeconds = twoDigits(duration.inSeconds.remainder(60));
if (duration.inDays != 0) { if (duration.inDays != 0) {
formattedTime += '$days Tag ${duration.inDays > 1 ? "e" : ""}, '; formattedTime += '$days Tag${duration.inDays > 1 ? "e" : ""}, ';
} }
if (duration.inHours != 0) formattedTime += '$hours:'; if (duration.inHours != 0) formattedTime += '$hours:';
formattedTime += '$minutes:'; formattedTime += '$minutes:';

View File

@ -16,7 +16,7 @@ class MyScanner extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
SettingsProvider settingsProvider = context.watch<SettingsProvider>(); SettingsProvider settingsProvider = context.watch<SettingsProvider>();
void handleSucces(String? rawValue) { void handleSuccess(String? rawValue) {
String qrText = rawValue!; String qrText = rawValue!;
Map<String, dynamic> json = stringToJSON(qrText); Map<String, dynamic> json = stringToJSON(qrText);
Settings settings = Settings.fromJson(json); Settings settings = Settings.fromJson(json);
@ -49,7 +49,7 @@ class MyScanner extends StatelessWidget {
final List<Barcode> barcodes = capture.barcodes; final List<Barcode> barcodes = capture.barcodes;
for (final barcode in barcodes) { for (final barcode in barcodes) {
if (barcode.rawValue != null) { if (barcode.rawValue != null) {
return handleSucces(barcode.rawValue); return handleSuccess(barcode.rawValue);
} }
} }
} catch (e) { } catch (e) {

View File

@ -48,3 +48,4 @@ flutter:
- assets/finish.mp3 - assets/finish.mp3
- assets/group1.json - assets/group1.json
- assets/group3.json - assets/group3.json
- assets/ZI_logo.png