diff --git a/lib/entities/PizzaEvent.dart b/lib/entities/PizzaEvent.dart index 3188ac9..4acd0eb 100644 --- a/lib/entities/PizzaEvent.dart +++ b/lib/entities/PizzaEvent.dart @@ -5,6 +5,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart'; import 'package:pizzaplanner/main.dart'; import 'package:timezone/timezone.dart' as tz; +import 'dart:math'; part 'PizzaEvent.g.dart'; @@ -49,9 +50,12 @@ class PizzaEvent extends HiveObject{ .fold(0, (a, b) => a+b)); stepTime = stepTime.subtract(durationToFirstStep); + final List pendingNotificationRequests = await flutterLocalNotificationsPlugin.pendingNotificationRequests(); + int notificationId = pendingNotificationRequests.map((pendingNotification) => pendingNotification.id).fold(0, max); + for (var recipeStep in this.recipe.recipeSteps) { await flutterLocalNotificationsPlugin.zonedSchedule( - "${name}_${recipeStep.name}_${dateTime.millisecondsSinceEpoch}".hashCode, + notificationId, recipeStep.name, null, stepTime, @@ -60,7 +64,9 @@ class PizzaEvent extends HiveObject{ uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime ); + recipeStep.notificationId = notificationId; stepTime = stepTime.add(Duration(seconds: recipeStep.getCurrentWaitInSeconds())); + notificationId++; } } } \ No newline at end of file diff --git a/lib/entities/PizzaRecipe/RecipeStep.dart b/lib/entities/PizzaRecipe/RecipeStep.dart index dc9e7a2..197a469 100644 --- a/lib/entities/PizzaRecipe/RecipeStep.dart +++ b/lib/entities/PizzaRecipe/RecipeStep.dart @@ -34,9 +34,11 @@ class RecipeStep extends HiveObject { @HiveField(8) DateTime? completedOn; - bool get completed => _completed(); + @HiveField(9) + int notificationId = -1; + RecipeStep(this.name, this.description, this.waitDescription, this.waitUnit, this.waitMin, this.waitMax, this.subSteps) { waitValue = waitMin; } diff --git a/lib/pages/AddPizzaEventPage.dart b/lib/pages/AddPizzaEventPage.dart index fa866ea..4107ad4 100644 --- a/lib/pages/AddPizzaEventPage.dart +++ b/lib/pages/AddPizzaEventPage.dart @@ -6,6 +6,7 @@ import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:pizzaplanner/entities/PizzaEvent.dart'; import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart'; +import 'package:pizzaplanner/main.dart'; import 'package:pizzaplanner/util.dart'; import 'package:hive/hive.dart'; @@ -151,6 +152,7 @@ class AddPizzaEventPageState extends State { child: TextButton( child: Text("Review", style: TextStyle(color: Colors.white)), onPressed: () async { + if (this.name.length == 0){ setState(() { this.nameValidation = true; }); return;