Merge branch 'development_new_design_2.0' into haroon-new-design

merge-update-with-lab-changes
haroon amjad 4 years ago
commit ff0e878bf2

@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers';
const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items';
const PACKAGES_ORDERS = '/api/orders';
const PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara';
// const BASE_URL = 'https://uat.hmgwebservices.com/';
const BASE_URL = 'https://hmgwebservices.com/';
const BASE_URL = 'https://uat.hmgwebservices.com/';
// const BASE_URL = 'https://hmgwebservices.com/';
// Pharmacy UAT URLs
// const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/';

@ -14,13 +14,15 @@ Future<Map<Permission, PermissionStatus>> requestPermissions() async {
}
showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted,
{Function onSuccess, String title, String description}) async {
{Function onSuccess, String title, String description, Function(int) onMultiDateSuccess}) async {
if (await Permission.calendar.request().isGranted) {
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, onSuccess: onSuccess, title: title, description: description);
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted,
onSuccess: onSuccess, title: title, description: description, onMultiDateSuccess: onMultiDateSuccess);
} else {
requestPermissions().then((results) {
if (results[Permission.calendar].isGranted) {
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, onSuccess: onSuccess, title: title, description: description);
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted,
onSuccess: onSuccess, title: title, description: description, onMultiDateSuccess: onMultiDateSuccess);
}
});
}
@ -29,7 +31,7 @@ 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, String title, String description}) async {
{Function onSuccess, String title, String description, Function(int) onMultiDateSuccess}) async {
return showDialog<void>(
context: context,
barrierDismissible: true, // user must tap button!
@ -56,16 +58,20 @@ Future<void> _showReminderDialog(BuildContext context, DateTime dateTime, String
// dateTime.add(new Duration(minutes: -120));
dateTime = Jiffy(dateTime).subtract(hours: 2);
}
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
calendarUtils
.createOrUpdateEvent(
title: title ?? TranslationBase.of(context).reminderTitle + " " + doctorName,
description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted,
scheduleDateTime: dateTime,
eventId: eventId)
.then((value) {});
if (onMultiDateSuccess == null) {
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
calendarUtils
.createOrUpdateEvent(
title: title ?? TranslationBase.of(context).reminderTitle + " " + doctorName,
description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted,
scheduleDateTime: dateTime,
eventId: eventId)
.then((value) {});
onSuccess();
onSuccess();
} else {
onMultiDateSuccess(i);
}
},
),
);
@ -144,12 +150,14 @@ class _ReminderDialogState extends State<ReminderDialog> {
});
},
),
Text(TranslationBase.of(context).appoReminder30,
Text(
TranslationBase.of(context).appoReminder30,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),),
),
),
],
),
Row(
@ -163,12 +171,14 @@ class _ReminderDialogState extends State<ReminderDialog> {
});
},
),
Text(TranslationBase.of(context).appoReminder60,
Text(
TranslationBase.of(context).appoReminder60,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),),
),
),
],
),
Row(
@ -182,12 +192,14 @@ class _ReminderDialogState extends State<ReminderDialog> {
});
},
),
Text(TranslationBase.of(context).appoReminder90,
Text(
TranslationBase.of(context).appoReminder90,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),),
),
),
],
),
Row(

@ -6,6 +6,8 @@ import 'package:diplomaticquarterapp/models/header_model.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/reminder_dialog.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/reminder_dialog_prescription.dart';
import 'package:diplomaticquarterapp/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart';
import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart';
import 'package:diplomaticquarterapp/uitl/LocalNotification.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -18,6 +20,7 @@ import 'package:diplomaticquarterapp/widgets/show_zoom_image_dialog.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import 'package:provider/provider.dart';
class PrescriptionDetailsPage extends StatelessWidget {
@ -32,7 +35,6 @@ class PrescriptionDetailsPage extends StatelessWidget {
return AppScaffold(
isShowAppBar: true,
showNewAppBar: true,
backgroundColor: Color(0xffF8F8F8),
showNewAppBarTitle: true,
appBarTitle: TranslationBase.of(context).prescriptions,
body: Column(
@ -212,34 +214,11 @@ class PrescriptionDetailsPage extends StatelessWidget {
onSuccess: () {
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
},
onMultiDateSuccess: (int selectedIndex) {
setCalender(context, prescriptionReport.itemID.toString(), selectedIndex);
},
);
return;
showGeneralDialog(
barrierColor: Colors.black.withOpacity(0.5),
transitionBuilder: (context, a1, a2, widget) {
final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0;
return Transform(
transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0),
child: Opacity(
opacity: a1.value,
child: PrescriptionReminderDialog(
eventId: prescriptionReport.itemID.toString(),
title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ",
startDate: startDate,
endDate: endDate,
location: prescriptionReport.remarks,
days: 1,
),
),
);
},
transitionDuration: Duration(milliseconds: 500),
barrierDismissible: true,
barrierLabel: '',
context: context,
pageBuilder: (context, animation1, animation2) {});
},
iconData: Icons.notifications_active,
color: Color(0xffD02127),
@ -253,4 +232,75 @@ class PrescriptionDetailsPage extends StatelessWidget {
),
);
}
setCalender(BuildContext context, String eventId, int reminderIndex) async {
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
DateTime startDate = DateUtil.convertStringToDate(prescriptionReport.startDate);
DateTime actualDate = DateTime(startDate.year, startDate.month, startDate.day, 8, 0); //Time will start at 8:00 AM from starting date
if (prescriptionReport?.frequencyNumber == null) prescriptionReport.frequencyNumber = 2; //Some time frequency number is null so by default will be 2
for (int i = 0; i < prescriptionReport.days; i++) {
//event for number of days.
for (int j = 0; j < prescriptionReport.frequencyNumber ?? 2; j++) {
// event for number of times per day.
if (j != 0) {
actualDate.add(new Duration(hours: 8)); // 8 hours addition for daily dose.
}
//Time subtraction from actual reminder time. like before 30, or 1 hour.
if (reminderIndex == 0) {
// Before 30 mints
actualDate = Jiffy(actualDate).subtract(minutes: 30);
// dateTime.add(new Duration(minutes: -30));
} else if (reminderIndex == 1) {
// Before 1 hour
// dateTime.add(new Duration(minutes: -60));
actualDate = Jiffy(actualDate).subtract(hours: 1);
} else if (reminderIndex == 2) {
// Before 1 hour and 30 mints
// dateTime.add(new Duration(minutes: -90));
actualDate = Jiffy(actualDate).subtract(hours: 1, minutes: 30);
} else if (reminderIndex == 3) {
// Before 2 hours
// dateTime.add(new Duration(minutes: -120));
actualDate = Jiffy(actualDate).subtract(hours: 2);
}
calendarUtils
.createOrUpdateEvent(
title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ",
scheduleDateTime: actualDate,
eventId: eventId + (i.toString() + j.toString()), //event id with varitions
)
.then(
(value) {},
);
}
actualDate.add(new Duration(days: i + 1));
}
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
}
//schedual local notifications
// setTheNotificatoin(BuildContext context) {
// DateTime startDate = DateUtil.convertStringToDate(prescriptionReport.startDate);
// DateTime actualDate = DateTime(startDate.year, startDate.month, startDate.day, 8, 0);
// if (prescriptionReport?.frequencyNumber == null) prescriptionReport.frequencyNumber = 2;
//
// for (int i = 0; i < prescriptionReport.days; i++) {
// for (int j = 0; j < prescriptionReport.frequencyNumber ?? 2; j++) {
// if (j != 0) {
// actualDate.add(new Duration(hours: 8));
// }
// LocalNotification.getInstance().scheduleNotification(
// scheduledNotificationDateTime: actualDate,
// title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
// description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ");
// }
// actualDate.add(new Duration(days: i + 1));
// }
// AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
// }
}

@ -10,15 +10,17 @@ final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterL
class LocalNotification {
Function(String payload) _onNotificationClick;
static LocalNotification _instance;
static LocalNotification getInstance(){
static LocalNotification getInstance() {
return _instance;
}
static init({Function(String payload) onNotificationClick}){
if(_instance == null){
static init({Function(String payload) onNotificationClick}) {
if (_instance == null) {
_instance = LocalNotification();
_instance._onNotificationClick = onNotificationClick;
_instance._initialize();
}else{
} else {
// assert(false,(){
// //TODO fix it
// "LocalNotification Already Initialized";
@ -26,7 +28,7 @@ class LocalNotification {
}
}
_initialize(){
_initialize() {
var initializationSettingsAndroid = new AndroidInitializationSettings('app_icon');
var initializationSettingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: null);
var initializationSettings = InitializationSettings(initializationSettingsAndroid, initializationSettingsIOS);
@ -34,11 +36,12 @@ class LocalNotification {
}
var _random = new Random();
_randomNumber({int from = 100000}){
_randomNumber({int from = 100000}) {
return _random.nextInt(from);
}
_vibrationPattern(){
_vibrationPattern() {
var vibrationPattern = Int64List(4);
vibrationPattern[0] = 0;
vibrationPattern[1] = 1000;
@ -50,10 +53,11 @@ class LocalNotification {
Future showNow({@required String title, @required String subtitle, String payload}) {
Future.delayed(Duration(seconds: 1)).then((result) async {
var androidPlatformChannelSpecifics = AndroidNotificationDetails('com.hmg.local_notification', 'HMG', 'HMG', importance: Importance.Max, priority: Priority.High, ticker: 'ticker', vibrationPattern: _vibrationPattern());
var androidPlatformChannelSpecifics =
AndroidNotificationDetails('com.hmg.local_notification', 'HMG', 'HMG', importance: Importance.Max, priority: Priority.High, ticker: 'ticker', vibrationPattern: _vibrationPattern());
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(_randomNumber(), title, subtitle, platformChannelSpecifics, payload: payload).catchError((err){
await flutterLocalNotificationsPlugin.show(_randomNumber(), title, subtitle, platformChannelSpecifics, payload: payload).catchError((err) {
print(err);
});
});
@ -81,11 +85,9 @@ class LocalNotification {
ledOffMs: 500);
var iOSPlatformChannelSpecifics = IOSNotificationDetails(sound: 'slow_spring_board.aiff');
///change it to be as ionic
// var platformChannelSpecifics = NotificationDetails(
// androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
// await flutterLocalNotificationsPlugin.schedule(0, title, description,
// scheduledNotificationDateTime, platformChannelSpecifics);
// /change it to be as ionic
var platformChannelSpecifics = NotificationDetails(androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.schedule(0, title, description, scheduledNotificationDateTime, platformChannelSpecifics);
}
///Repeat notification every day at approximately 10:00:00 am

Loading…
Cancel
Save