added archiving/deleting of events
This commit is contained in:
parent
2888504b4d
commit
215365847f
3 changed files with 84 additions and 7 deletions
|
@ -79,4 +79,10 @@ class PizzaEvent extends HiveObject{
|
|||
stepId++;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> cancelNotifications() async {
|
||||
for(final recipeStep in recipe.recipeSteps){
|
||||
flutterLocalNotificationsPlugin.cancel(recipeStep.notificationId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,15 +22,88 @@ class PizzaEventsState extends State<PizzaEventsPage> {
|
|||
title: const Text("Pizza Events"),
|
||||
body: ValueListenableBuilder(
|
||||
valueListenable: Hive.box<PizzaEvent>("PizzaEvents").listenable(),
|
||||
builder: (context, Box<PizzaEvent> box, widget) {
|
||||
if (box.isEmpty){
|
||||
builder: (context, Box<PizzaEvent> pizzaEventBox, widget) {
|
||||
if (pizzaEventBox.isEmpty){
|
||||
return Container();
|
||||
}
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: box.length,
|
||||
itemBuilder: (BuildContext context, int i) => PizzaEventWidget(box.getAt(i)!),
|
||||
separatorBuilder: (BuildContext context, int i) => const Divider(),
|
||||
itemCount: pizzaEventBox.length,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
final pizzaEvent = pizzaEventBox.get(i);
|
||||
if (pizzaEvent == null || pizzaEvent.archived || pizzaEvent.deleted){
|
||||
return const SizedBox();
|
||||
}
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, "/event/view", arguments: pizzaEvent);
|
||||
},
|
||||
onLongPress: () {
|
||||
showDialog(context: context, builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(pizzaEvent.name),
|
||||
content: const Text("What do you want to do?"),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, "/event/view", arguments: pizzaEvent);
|
||||
},
|
||||
child: const Text("View"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
pizzaEvent.archived = true;
|
||||
pizzaEvent.save();
|
||||
},
|
||||
child: const Text("Archive"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showDialog(context: context, builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Delete?"),
|
||||
content: const Text("Are you sure?"),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Back"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (pizzaEvent.isInBox){
|
||||
pizzaEvent.cancelNotifications();
|
||||
pizzaEvent.deleted = true;
|
||||
pizzaEvent.save();
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Delete", style: TextStyle(color: Colors.redAccent)),
|
||||
),
|
||||
]
|
||||
);
|
||||
});
|
||||
},
|
||||
child: const Text("Delete", style: TextStyle(color: Colors.redAccent)),
|
||||
),
|
||||
]
|
||||
);
|
||||
});
|
||||
},
|
||||
child: PizzaEventWidget(pizzaEvent),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int i) {
|
||||
final pizzaEvent = pizzaEventBox.get(i);
|
||||
if (pizzaEvent == null || pizzaEvent.archived || pizzaEvent.deleted){
|
||||
return const SizedBox();
|
||||
}
|
||||
return const Divider();
|
||||
},
|
||||
);
|
||||
}
|
||||
),
|
||||
|
|
2
todo.md
2
todo.md
|
@ -9,8 +9,6 @@
|
|||
- add settings page
|
||||
- option for type of notification, full screen or just in the appbar
|
||||
- pick alarm sound
|
||||
- deleting scheduled pizza events
|
||||
- archiving past pizza events
|
||||
- foto mode for pizza event
|
||||
- push to instagram ?
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue