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;
|
2023-02-27 11:08:38 +01:00
|
|
|
bool _initialized = false;
|
2023-02-27 02:27:42 +01:00
|
|
|
|
|
|
|
Settings? get settings => _settings;
|
2023-02-27 11:08:38 +01:00
|
|
|
bool get initialized => _initialized;
|
2023-02-27 02:27:42 +01:00
|
|
|
|
|
|
|
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(
|
2023-02-27 11:19:56 +01:00
|
|
|
group,
|
2023-02-27 02:27:42 +01:00
|
|
|
relapseCategories,
|
2023-02-27 11:19:56 +01:00
|
|
|
QueryConfig(moodHours, moodMinutes, moodDays),
|
|
|
|
QueryConfig(sleepHours, sleepMinutes, sleepDays),
|
|
|
|
TimeConfig(chessHours, chessMinutes));
|
|
|
|
_initialized = group != null ? true : false;
|
2023-02-27 02:27:42 +01:00
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|