added longpress to snooze button that allows the user to select the datetime when to snooze to
This commit is contained in:
parent
b01b3d7923
commit
cbbd83fa46
2 changed files with 46 additions and 29 deletions
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
||||
|
@ -89,34 +90,25 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
child: TextButton(
|
||||
child: Text("Snooze 15 minutes", style: TextStyle(color: Colors.white)),
|
||||
onPressed: () async {
|
||||
flutterLocalNotificationsPlugin.cancel(recipeStep.notificationId);
|
||||
|
||||
const androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
||||
"PizzaEventChannel", "PizzaEventChannel", "PizzaPlanner notification channel",
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
ticker: "ticker",
|
||||
fullScreenIntent: true,
|
||||
);
|
||||
const platformChannelSpecific = NotificationDetails(android: androidPlatformChannelSpecifics);
|
||||
|
||||
var newTime = DateTime.now().add(const Duration(minutes: 15));
|
||||
|
||||
await flutterLocalNotificationsPlugin.zonedSchedule(
|
||||
recipeStep.notificationId,
|
||||
recipeStep.name,
|
||||
null,
|
||||
tz.TZDateTime.from(newTime, tz.local),
|
||||
platformChannelSpecific,
|
||||
androidAllowWhileIdle: true,
|
||||
payload: this.widget.payload,
|
||||
uiLocalNotificationDateInterpretation:
|
||||
UILocalNotificationDateInterpretation.absoluteTime
|
||||
);
|
||||
recipeStep.dateTime = newTime;
|
||||
pizzaEvent.save();
|
||||
setRecipeStepNotificatcion(DateTime.now().add(const Duration(minutes: 15)));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
onLongPress: () async {
|
||||
var future5Min = DateTime.now().add(Duration(minutes: 5));
|
||||
DatePicker.showDateTimePicker(context,
|
||||
showTitleActions: true,
|
||||
minTime: future5Min,
|
||||
currentTime: future5Min,
|
||||
maxTime: DateTime.now().add(Duration(days: 365*10)),
|
||||
onConfirm: (newEventTime) {
|
||||
setState((){
|
||||
setRecipeStepNotificatcion(newEventTime);
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -173,5 +165,32 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
|||
]
|
||||
);
|
||||
}
|
||||
|
||||
void setRecipeStepNotificatcion(DateTime newTime) async {
|
||||
flutterLocalNotificationsPlugin.cancel(recipeStep.notificationId);
|
||||
|
||||
const androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
||||
"PizzaEventChannel", "PizzaEventChannel", "PizzaPlanner notification channel",
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
ticker: "ticker",
|
||||
fullScreenIntent: true,
|
||||
);
|
||||
const platformChannelSpecific = NotificationDetails(android: androidPlatformChannelSpecifics);
|
||||
|
||||
await flutterLocalNotificationsPlugin.zonedSchedule(
|
||||
recipeStep.notificationId,
|
||||
recipeStep.name,
|
||||
null,
|
||||
tz.TZDateTime.from(newTime, tz.local),
|
||||
platformChannelSpecific,
|
||||
androidAllowWhileIdle: true,
|
||||
payload: this.widget.payload,
|
||||
uiLocalNotificationDateInterpretation:
|
||||
UILocalNotificationDateInterpretation.absoluteTime
|
||||
);
|
||||
recipeStep.dateTime = newTime;
|
||||
pizzaEvent.save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
4
todo.md
4
todo.md
|
@ -7,6 +7,4 @@
|
|||
|
||||
- add decimals to ingredients table when below a certain % or <5g whatever
|
||||
|
||||
- move ingredients table when adding a pizza event from confirm date dialog to main add pizza page
|
||||
|
||||
- add another button (or longpress) on snooze button with a datetime picker
|
||||
- move ingredients table when adding a pizza event from confirm date dialog to main add pizza page
|
Loading…
Add table
Reference in a new issue