|
|
|
|
@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:jiffy/jiffy.dart';
|
|
|
|
|
import 'package:manage_calendar_events/manage_calendar_events.dart';
|
|
|
|
|
@ -12,29 +13,14 @@ Future<Map<Permission, PermissionStatus>> requestPermissions() async {
|
|
|
|
|
return permissionResults;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, {Function onSuccess}) async {
|
|
|
|
|
showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted,
|
|
|
|
|
{Function onSuccess, String title, String description}) async {
|
|
|
|
|
if (await Permission.calendar.request().isGranted) {
|
|
|
|
|
_showReminderDialog(
|
|
|
|
|
context,
|
|
|
|
|
dateTime,
|
|
|
|
|
doctorName,
|
|
|
|
|
eventId,
|
|
|
|
|
appoDateFormatted,
|
|
|
|
|
appoTimeFormatted,
|
|
|
|
|
onSuccess: onSuccess,
|
|
|
|
|
);
|
|
|
|
|
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, onSuccess: onSuccess, title: title, description: description);
|
|
|
|
|
} else {
|
|
|
|
|
requestPermissions().then((results) {
|
|
|
|
|
if (results[Permission.calendar].isGranted) {
|
|
|
|
|
_showReminderDialog(
|
|
|
|
|
context,
|
|
|
|
|
dateTime,
|
|
|
|
|
doctorName,
|
|
|
|
|
eventId,
|
|
|
|
|
appoDateFormatted,
|
|
|
|
|
appoTimeFormatted,
|
|
|
|
|
onSuccess: onSuccess,
|
|
|
|
|
);
|
|
|
|
|
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, onSuccess: onSuccess, title: title, description: description);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -42,13 +28,15 @@ showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, S
|
|
|
|
|
|
|
|
|
|
final CalendarPlugin _myPlugin = CalendarPlugin();
|
|
|
|
|
|
|
|
|
|
Future<void> _showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, {Function onSuccess}) async {
|
|
|
|
|
Future<void> _showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted,
|
|
|
|
|
{Function onSuccess, String title, String description}) async {
|
|
|
|
|
return showDialog<void>(
|
|
|
|
|
context: context,
|
|
|
|
|
barrierDismissible: true, // user must tap button!
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return Dialog(
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), //this right here
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0.0)),
|
|
|
|
|
insetPadding: EdgeInsets.all(21),
|
|
|
|
|
child: ReminderDialog(
|
|
|
|
|
onClick: (int i) async {
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
@ -71,7 +59,10 @@ Future<void> _showReminderDialog(BuildContext context, DateTime dateTime, String
|
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
|
calendarUtils
|
|
|
|
|
.createOrUpdateEvent(
|
|
|
|
|
title: TranslationBase.of(context).reminderTitle + " " + doctorName, description: "At " + appoDateFormatted + " " + appoTimeFormatted, scheduleDateTime: dateTime, eventId: eventId)
|
|
|
|
|
title: title ?? TranslationBase.of(context).reminderTitle + " " + doctorName,
|
|
|
|
|
description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted,
|
|
|
|
|
scheduleDateTime: dateTime,
|
|
|
|
|
eventId: eventId)
|
|
|
|
|
.then((value) {});
|
|
|
|
|
|
|
|
|
|
onSuccess();
|
|
|
|
|
@ -97,7 +88,7 @@ class _ReminderDialogState extends State<ReminderDialog> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width / 0.8,
|
|
|
|
|
//width: MediaQuery.of(context).size.width / 0.8,
|
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
@ -106,13 +97,16 @@ class _ReminderDialogState extends State<ReminderDialog> {
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.notifications_active,
|
|
|
|
|
color: Color(0xff2B353E),
|
|
|
|
|
size: 50,
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.clear),
|
|
|
|
|
color: Color(0xff2B353E),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
@ -124,6 +118,7 @@ class _ReminderDialogState extends State<ReminderDialog> {
|
|
|
|
|
"When would you like to set a reminder for this appointment?",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
color: Color(0xff2B353E),
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
@ -133,6 +128,7 @@ class _ReminderDialogState extends State<ReminderDialog> {
|
|
|
|
|
"Please select from below options:",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: Color(0xff2B353E),
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
),
|
|
|
|
|
@ -190,28 +186,14 @@ class _ReminderDialogState extends State<ReminderDialog> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
mHeight(12),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
DefaultButton(
|
|
|
|
|
TranslationBase.of(context).save,
|
|
|
|
|
() {
|
|
|
|
|
widget.onClick(i);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 45,
|
|
|
|
|
decoration: containerRadius(CustomColors.green, 12),
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Text(
|
|
|
|
|
"Save",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
letterSpacing: -0.48,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
color: CustomColors.green,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|