change group to int, show group in appbar if configured

main
Julian Gegner 2023-02-20 19:50:09 +01:00
parent 5393590687
commit 6d4a958d8c
6 changed files with 13 additions and 9 deletions

View File

@ -1,5 +1,5 @@
{ {
"group": "Gruppe 1", "group": 1,
"HITT_time": 35, "HITT_time": 35,
"relapse_categories": ["App stresst mich", "langeweile", "lunge braucht es"], "relapse_categories": ["App stresst mich", "langeweile", "lunge braucht es"],
"mood_query": { "mood_query": {

View File

@ -1,5 +1,5 @@
{ {
"group": "Gruppe 3", "group": 3,
"HITT_time": 35, "HITT_time": 35,
"chess_time": { "chess_time": {
"hours": 8, "hours": 8,

View File

@ -1,7 +1,7 @@
import 'package:smoke_cess_app/service/json_service.dart'; import 'package:smoke_cess_app/service/json_service.dart';
class Settings { class Settings {
final String group; final int group;
final List<String>? relapseCategories; final List<String>? relapseCategories;
final QueryConfig moodQuery; final QueryConfig moodQuery;
final QueryConfig sleepQuery; final QueryConfig sleepQuery;
@ -11,7 +11,7 @@ class Settings {
this.chessTime); this.chessTime);
Settings.fromJson(Map<String, dynamic> json) Settings.fromJson(Map<String, dynamic> json)
: group = json['group'] as String, : group = json['group'] as int,
relapseCategories = jsonPropertyAsList(json['relapse_categories']), relapseCategories = jsonPropertyAsList(json['relapse_categories']),
moodQuery = QueryConfig.fromJson(json['mood_query']), moodQuery = QueryConfig.fromJson(json['mood_query']),
sleepQuery = QueryConfig.fromJson(json['sleep_query']), sleepQuery = QueryConfig.fromJson(json['sleep_query']),

View File

@ -16,6 +16,7 @@ class MyHomePage extends StatefulWidget {
class MyHomePageState extends State<MyHomePage> { class MyHomePageState extends State<MyHomePage> {
int _selectedIndex = 4; int _selectedIndex = 4;
int? _gruppe;
final List<String> _titles = [ final List<String> _titles = [
'Stimmung', 'Stimmung',
@ -33,8 +34,8 @@ class MyHomePageState extends State<MyHomePage> {
]; ];
Future<void> _onItemTapped(int index) async { Future<void> _onItemTapped(int index) async {
bool isConfigured = (await getGroup()) != null; _gruppe = await getGroup();
print('Gruppe: ${await getGroup()}, isConfigured: $isConfigured'); bool isConfigured = _gruppe != null;
setState(() { setState(() {
isConfigured isConfigured
? _selectedIndex = index ? _selectedIndex = index
@ -52,7 +53,9 @@ class MyHomePageState extends State<MyHomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(_titles[_selectedIndex])), appBar: AppBar(
title: Text(
'${_titles[_selectedIndex]} ${_gruppe != null ? "Gruppe $_gruppe" : ""}')),
body: _widgetOptions.elementAt(_selectedIndex), body: _widgetOptions.elementAt(_selectedIndex),
bottomNavigationBar: NavigationBar( bottomNavigationBar: NavigationBar(
onDestinationSelected: _onItemTapped, onDestinationSelected: _onItemTapped,

View File

@ -30,6 +30,7 @@ class ScannerPageState extends State<ScannerPage> {
detectionTimeoutMs: 2000, detectionTimeoutMs: 2000,
), ),
onDetect: (capture) { onDetect: (capture) {
//TODO Errorhandling!!
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) {

View File

@ -3,7 +3,7 @@ import 'package:smoke_cess_app/models/settings.dart';
import 'package:smoke_cess_app/service/json_service.dart'; import 'package:smoke_cess_app/service/json_service.dart';
//access group setting which was saved in local storage //access group setting which was saved in local storage
Future<String?> getGroup() => _getStringSetting('group'); Future<int?> getGroup() => _getIntSetting('group');
Future<List<String>?> getRelapseCategories() => Future<List<String>?> getRelapseCategories() =>
_getStringListSetting('relapse_categories'); _getStringListSetting('relapse_categories');
@ -52,7 +52,7 @@ Future<void> loadSettingsFromLocalJSON() async {
} }
void saveSettings(Settings settings) { void saveSettings(Settings settings) {
_setStringSetting('group', settings.group); _setIntSetting('group', settings.group);
_setStringListSetting('relapse_categories', settings.relapseCategories!); _setStringListSetting('relapse_categories', settings.relapseCategories!);
_setStringListSetting('mood_query_days', settings.moodQuery.days!); _setStringListSetting('mood_query_days', settings.moodQuery.days!);
_setIntSetting('mood_query_hours', settings.moodQuery.hours); _setIntSetting('mood_query_hours', settings.moodQuery.hours);