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/cupertino.dart';
|
||||||
import 'package:flutter/material.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:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
||||||
|
@ -89,34 +90,25 @@ class PizzaEventNotificationState extends State<PizzaEventNotificationPage> {
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
child: Text("Snooze 15 minutes", style: TextStyle(color: Colors.white)),
|
child: Text("Snooze 15 minutes", style: TextStyle(color: Colors.white)),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
flutterLocalNotificationsPlugin.cancel(recipeStep.notificationId);
|
setRecipeStepNotificatcion(DateTime.now().add(const Duration(minutes: 15)));
|
||||||
|
|
||||||
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();
|
|
||||||
Navigator.pop(context);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
todo.md
2
todo.md
|
@ -8,5 +8,3 @@
|
||||||
- add decimals to ingredients table when below a certain % or <5g whatever
|
- 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
|
- 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
|
|
Loading…
Add table
Reference in a new issue