diff --git a/assets/group1.json b/assets/group1.json index eadf04c..4e2de76 100644 --- a/assets/group1.json +++ b/assets/group1.json @@ -1,5 +1,5 @@ { - "group": "Gruppe 1", + "group": 1, "HITT_time": 35, "relapse_categories": ["App stresst mich", "langeweile", "lunge braucht es"], "mood_query": { diff --git a/assets/group3.json b/assets/group3.json index 6e1d75c..623ffc8 100644 --- a/assets/group3.json +++ b/assets/group3.json @@ -1,5 +1,5 @@ { - "group": "Gruppe 3", + "group": 3, "HITT_time": 35, "chess_time": { "hours": 8, diff --git a/lib/models/settings.dart b/lib/models/settings.dart index 359338f..6691e91 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -1,7 +1,7 @@ import 'package:smoke_cess_app/service/json_service.dart'; class Settings { - final String group; + final int group; final List? relapseCategories; final QueryConfig moodQuery; final QueryConfig sleepQuery; @@ -11,7 +11,7 @@ class Settings { this.chessTime); Settings.fromJson(Map json) - : group = json['group'] as String, + : group = json['group'] as int, relapseCategories = jsonPropertyAsList(json['relapse_categories']), moodQuery = QueryConfig.fromJson(json['mood_query']), sleepQuery = QueryConfig.fromJson(json['sleep_query']), diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index 76cec46..db4ff27 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -16,6 +16,7 @@ class MyHomePage extends StatefulWidget { class MyHomePageState extends State { int _selectedIndex = 4; + int? _gruppe; final List _titles = [ 'Stimmung', @@ -33,8 +34,8 @@ class MyHomePageState extends State { ]; Future _onItemTapped(int index) async { - bool isConfigured = (await getGroup()) != null; - print('Gruppe: ${await getGroup()}, isConfigured: $isConfigured'); + _gruppe = await getGroup(); + bool isConfigured = _gruppe != null; setState(() { isConfigured ? _selectedIndex = index @@ -52,7 +53,9 @@ class MyHomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text(_titles[_selectedIndex])), + appBar: AppBar( + title: Text( + '${_titles[_selectedIndex]} ${_gruppe != null ? "Gruppe $_gruppe" : ""}')), body: _widgetOptions.elementAt(_selectedIndex), bottomNavigationBar: NavigationBar( onDestinationSelected: _onItemTapped, diff --git a/lib/pages/scanner_page.dart b/lib/pages/scanner_page.dart index 9ce6301..fcd2c30 100644 --- a/lib/pages/scanner_page.dart +++ b/lib/pages/scanner_page.dart @@ -30,6 +30,7 @@ class ScannerPageState extends State { detectionTimeoutMs: 2000, ), onDetect: (capture) { + //TODO Errorhandling!! final List barcodes = capture.barcodes; for (final barcode in barcodes) { if (barcode.rawValue != null) { diff --git a/lib/service/settings_service.dart b/lib/service/settings_service.dart index f83c979..dca2839 100644 --- a/lib/service/settings_service.dart +++ b/lib/service/settings_service.dart @@ -3,7 +3,7 @@ import 'package:smoke_cess_app/models/settings.dart'; import 'package:smoke_cess_app/service/json_service.dart'; //access group setting which was saved in local storage -Future getGroup() => _getStringSetting('group'); +Future getGroup() => _getIntSetting('group'); Future?> getRelapseCategories() => _getStringListSetting('relapse_categories'); @@ -52,7 +52,7 @@ Future loadSettingsFromLocalJSON() async { } void saveSettings(Settings settings) { - _setStringSetting('group', settings.group); + _setIntSetting('group', settings.group); _setStringListSetting('relapse_categories', settings.relapseCategories!); _setStringListSetting('mood_query_days', settings.moodQuery.days!); _setIntSetting('mood_query_hours', settings.moodQuery.hours);