change group to int, show group in appbar if configured
parent
5393590687
commit
6d4a958d8c
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"group": "Gruppe 1",
|
||||
"group": 1,
|
||||
"HITT_time": 35,
|
||||
"relapse_categories": ["App stresst mich", "langeweile", "lunge braucht es"],
|
||||
"mood_query": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"group": "Gruppe 3",
|
||||
"group": 3,
|
||||
"HITT_time": 35,
|
||||
"chess_time": {
|
||||
"hours": 8,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:smoke_cess_app/service/json_service.dart';
|
||||
|
||||
class Settings {
|
||||
final String group;
|
||||
final int group;
|
||||
final List<String>? relapseCategories;
|
||||
final QueryConfig moodQuery;
|
||||
final QueryConfig sleepQuery;
|
||||
|
@ -11,7 +11,7 @@ class Settings {
|
|||
this.chessTime);
|
||||
|
||||
Settings.fromJson(Map<String, dynamic> 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']),
|
||||
|
|
|
@ -16,6 +16,7 @@ class MyHomePage extends StatefulWidget {
|
|||
|
||||
class MyHomePageState extends State<MyHomePage> {
|
||||
int _selectedIndex = 4;
|
||||
int? _gruppe;
|
||||
|
||||
final List<String> _titles = [
|
||||
'Stimmung',
|
||||
|
@ -33,8 +34,8 @@ class MyHomePageState extends State<MyHomePage> {
|
|||
];
|
||||
|
||||
Future<void> _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<MyHomePage> {
|
|||
@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,
|
||||
|
|
|
@ -30,6 +30,7 @@ class ScannerPageState extends State<ScannerPage> {
|
|||
detectionTimeoutMs: 2000,
|
||||
),
|
||||
onDetect: (capture) {
|
||||
//TODO Errorhandling!!
|
||||
final List<Barcode> barcodes = capture.barcodes;
|
||||
for (final barcode in barcodes) {
|
||||
if (barcode.rawValue != null) {
|
||||
|
|
|
@ -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<String?> getGroup() => _getStringSetting('group');
|
||||
Future<int?> getGroup() => _getIntSetting('group');
|
||||
|
||||
Future<List<String>?> getRelapseCategories() =>
|
||||
_getStringListSetting('relapse_categories');
|
||||
|
@ -52,7 +52,7 @@ Future<void> 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);
|
||||
|
|
Loading…
Reference in New Issue