import 'package:smoke_cess_app/service/settings_service.dart'; import 'package:timezone/timezone.dart'; const int trainingTime = 40; const weekDays = { "Montag": 1, "Dienstag": 2, "Mittwoch": 3, "Donnerstag": 4, "Freitag": 5, "Samstag": 6, "Sonntag": 7, }; Future> getDatesforAll() async { List allDates = []; List moodDates = await getDatesforMood(); List sleepDates = await getDatesforSleep(); allDates.addAll(moodDates); allDates.addAll(sleepDates); return allDates; } Future> getDatesforMood() async { final List? selectedDays = await getMoodQueryDaysCategories(); final int? selectedHours = await getMoodQueryHours(); final int? selectedMinutes = await getMoodQueryMinutes(); return createTZDateTimes(selectedDays, selectedHours, selectedMinutes); } Future> getDatesforSleep() async { final List? selectedDays = await getSleepQueryDaysCategories(); final int? selectedHours = await getSleepQueryHours(); final int? selectedMinutes = await getSleepQueryMinutes(); return createTZDateTimes(selectedDays, selectedHours, selectedMinutes); } List createTZDateTimes( List? selectedDays, int? selectedHours, int? selectedMinutes) { List tzDateTimes = []; if (selectedDays == null || selectedHours == null || selectedMinutes == null) { return tzDateTimes; } final Iterable selectedDaysInt = selectedDays.map((day) => weekDays[day]); for (int i = 0; i < trainingTime; i++) { final DateTime date = DateTime.now().add(Duration(days: i)); if (selectedDaysInt.contains(date.weekday) && date.isAfter(DateTime.now())) { tzDateTimes.add(TZDateTime.local(date.year, date.month, date.day, selectedHours, selectedMinutes, 0, 0, 0)); } } return tzDateTimes; }