outsource loadsettings to settings_service
parent
d46dd3ff7b
commit
21470da038
|
@ -15,24 +15,8 @@ class SettingsProvider extends ChangeNotifier {
|
|||
}
|
||||
|
||||
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,
|
||||
relapseCategories,
|
||||
QueryConfig(moodHours, moodMinutes, moodDays),
|
||||
QueryConfig(sleepHours, sleepMinutes, sleepDays),
|
||||
TimeConfig(chessHours, chessMinutes));
|
||||
_initialized = group != null ? true : false;
|
||||
_settings = await loadSettings();
|
||||
_initialized = _settings != null ? true : false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,3 +65,23 @@ void saveSettings(Settings settings) {
|
|||
_setIntSetting('chess_minutes', settings.chessTime!.minutes!);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Settings> loadSettings() 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();
|
||||
|
||||
return Settings(
|
||||
group,
|
||||
relapseCategories,
|
||||
QueryConfig(moodHours, moodMinutes, moodDays),
|
||||
QueryConfig(sleepHours, sleepMinutes, sleepDays),
|
||||
TimeConfig(chessHours, chessMinutes));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue