cpd_2022_zi/lib/providers/settings_provider.dart

36 lines
1.1 KiB
Dart
Raw Normal View History

2023-02-27 02:27:42 +01:00
import 'package:flutter/material.dart';
import 'package:smoke_cess_app/services/settings_service.dart';
import '../models/settings.dart';
class SettingsProvider extends ChangeNotifier {
Settings? _settings;
Settings? get settings => _settings;
SettingsProvider() {
initSettings();
}
void initSettings() async {
int? group = await getGroup();
List<String>? relapseCategories = await getRelapseCategories();
int? moodHours = await getMoodQueryHours();
int? moodMinutes = await getMoodQueryMinutes();
List<String>? moodDays = await getMoodQueryDaysCategories();
int? sleepHours = await getSleepQueryHours();
int? sleepMinutes = await getSleepQueryMinutes();
List<String>? sleepDays = await getSleepQueryDaysCategories();
int? chessHours = await getChessHours();
int? chessMinutes = await getChessMinutes();
_settings = Settings(
group ?? 0,
relapseCategories,
QueryConfig(moodHours ?? 0, moodMinutes ?? 0, moodDays),
QueryConfig(sleepHours ?? 0, sleepMinutes ?? 0, sleepDays),
TimeConfig(chessHours ?? 0, chessMinutes ?? 0));
notifyListeners();
}
}