Parricc35 2023-02-25 15:52:07 +01:00
parent 09d5e51377
commit a975a44f4e
4 changed files with 13 additions and 6 deletions

View File

@ -13,7 +13,7 @@
},
"sleep_query": {
"days": ["Dienstag", "Samstag"],
"hours": 11,
"minutes": 30
"hours": 15,
"minutes": 42
}
}

View File

@ -68,7 +68,7 @@ class ScannerPageState extends State<ScannerPage> {
textStyle: const TextStyle(fontSize: 20)),
onPressed: () {
loadSettingsFromLocalJSON();
NotificationService().showNotification();
NotificationService().setAllNotifications();
},
child: const Text('Read JSON'),
)

View File

@ -47,7 +47,10 @@ List<TZDateTime> createTZDateTimes(
final Iterable<int?> selectedDaysInt =
selectedDays.map((day) => weekDays[day]);
for (int i = 0; i < trainingTime; i++) {
final DateTime date = DateTime.now().add(Duration(days: i));
final DateTime now = DateTime.now();
final DateTime date = DateTime(now.year, now.month, now.day, selectedHours,
selectedMinutes, 0, 0, 0)
.add(Duration(days: i));
if (selectedDaysInt.contains(date.weekday) &&
date.isAfter(DateTime.now())) {
tzDateTimes.add(TZDateTime.local(date.year, date.month, date.day,

View File

@ -64,13 +64,17 @@ class NotificationService {
Future<void> setAllNotifications() async {
List<TZDateTime> moodDates = await getDatesforMood();
List<TZDateTime> sleepDates = await getDatesforSleep();
int index = 0;
for (var date in moodDates) {
setNotification(1, "Mood", "Evaluate your mood", date);
setNotification(index, "Mood", "Evaluate your mood", date);
print("mood");
index++;
}
for (var date in sleepDates) {
setNotification(1, "Sleep", "Evaluate your sleep", date);
setNotification(index, "Sleep", "Evaluate your sleep", date);
print("sleep");
print(date);
index++;
}
}