diff --git a/assets/images/jpg/report.jpg b/assets/images/jpg/report.jpg
new file mode 100644
index 00000000..5846cd53
Binary files /dev/null and b/assets/images/jpg/report.jpg differ
diff --git a/assets/images/svg/blood_pressure_icon.svg b/assets/images/svg/blood_pressure_icon.svg
new file mode 100644
index 00000000..0b027ad6
--- /dev/null
+++ b/assets/images/svg/blood_pressure_icon.svg
@@ -0,0 +1,4 @@
+
diff --git a/assets/images/svg/blood_sugar_only_icon.svg b/assets/images/svg/blood_sugar_only_icon.svg
new file mode 100644
index 00000000..f81cee8a
--- /dev/null
+++ b/assets/images/svg/blood_sugar_only_icon.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/images/svg/low_indicator_icon.svg b/assets/images/svg/low_indicator_icon.svg
new file mode 100644
index 00000000..f2ca09fc
--- /dev/null
+++ b/assets/images/svg/low_indicator_icon.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/images/svg/normal_status_green_icon.svg b/assets/images/svg/normal_status_green_icon.svg
new file mode 100644
index 00000000..b3f2619c
--- /dev/null
+++ b/assets/images/svg/normal_status_green_icon.svg
@@ -0,0 +1,7 @@
+
diff --git a/assets/images/svg/send_email_icon.svg b/assets/images/svg/send_email_icon.svg
new file mode 100644
index 00000000..eb8684ab
--- /dev/null
+++ b/assets/images/svg/send_email_icon.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/images/svg/weight_icon.svg b/assets/images/svg/weight_icon.svg
new file mode 100644
index 00000000..f93c6626
--- /dev/null
+++ b/assets/images/svg/weight_icon.svg
@@ -0,0 +1,3 @@
+
diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart
index f3663294..039787b8 100644
--- a/lib/core/api/api_client.dart
+++ b/lib/core/api/api_client.dart
@@ -210,7 +210,7 @@ class ApiClientImp implements ApiClient {
final int statusCode = response.statusCode;
log("uri: ${Uri.parse(url.trim())}");
log("body: ${json.encode(body)}");
- // log("response.body: ${response.body}");
+ log("response.body: ${response.body}");
if (statusCode < 200 || statusCode >= 400) {
onFailure('Error While Fetching data', statusCode, failureType: StatusCodeFailure("Error While Fetching data"));
logApiEndpointError(endPoint, 'Error While Fetching data', statusCode);
diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart
index c103291a..fe0b4d58 100644
--- a/lib/core/api_consts.dart
+++ b/lib/core/api_consts.dart
@@ -207,7 +207,7 @@ var GET_APPOINTMENT_DETAILS_BY_NO = 'Services/MobileNotifications.svc/REST/GetAp
var NEW_RATE_APPOINTMENT_URL = "Services/Doctors.svc/REST/AppointmentsRating_InsertAppointmentRate";
var NEW_RATE_DOCTOR_URL = "Services/Doctors.svc/REST/DoctorsRating_InsertDoctorRate";
-var GET_QR_PARKING = 'Services/SWP.svc/REST/GetQRParkingByID';
+//var GET_QR_PARKING = 'Services/SWP.svc/REST/GetQRParkingByID';
//URL to get clinic list
var GET_CLINICS_LIST_URL = "Services/lists.svc/REST/GetClinicCentralized";
@@ -398,19 +398,6 @@ var GET_COVID_DRIVETHRU_PROCEDURES_LIST = 'Services/Doctors.svc/REST/COVID19_Get
var GET_PATIENT_LAST_RECORD = 'Services/Patients.svc/REST/Med_GetPatientLastRecord';
var INSERT_PATIENT_HEALTH_DATA = 'Services/Patients.svc/REST/Med_InsertTransactions';
-///My Trackers
-var GET_DIABETIC_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetDiabeticResultAverage';
-var GET_DIABTEC_RESULT = 'Services/Patients.svc/REST/Patient_GetDiabtecResults';
-var ADD_DIABTEC_RESULT = 'Services/Patients.svc/REST/Patient_AddDiabtecResult';
-
-var GET_BLOOD_PRESSURE_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetBloodPressureResultAverage';
-var GET_BLOOD_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_GetBloodPressureResult';
-var ADD_BLOOD_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_AddBloodPressureResult';
-
-var GET_WEIGHT_PRESSURE_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResultAverage';
-var GET_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResult';
-var ADD_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_AddWeightMeasurementResult';
-
var ADD_ACTIVE_PRESCRIPTIONS_REPORT_BY_PATIENT_ID = 'Services/Patients.svc/Rest/GetActivePrescriptionReportByPatientID';
var GET_CALL_INFO_HOURS_RESULT = 'Services/Doctors.svc/REST/GetCallInfoHoursResult';
@@ -420,7 +407,6 @@ var GET_QUESTION_TYPES = 'Services/OUTPs.svc/REST/getQuestionsTypes';
var UPDATE_DIABETIC_RESULT = 'Services/Patients.svc/REST/Patient_UpdateDiabeticResult';
-var SEND_AVERAGE_BLOOD_SUGAR_REPORT = 'Services/Notifications.svc/REST/SendAverageBloodSugarReport';
var DEACTIVATE_DIABETIC_STATUS = 'services/Patients.svc/REST/Patient_DeactivateDiabeticStatus';
var DEACTIVATE_BLOOD_PRESSURES_STATUS = 'services/Patients.svc/REST/Patient_DeactivateBloodPressureStatus';
@@ -799,6 +785,11 @@ class ApiConsts {
static final String getAllSharedRecordsByStatus = 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatus';
static final String removeFileFromFamilyMembers = 'Services/Authentication.svc/REST/ActiveDeactive_PatientFile';
static final String acceptAndRejectFamilyFile = 'Services/Authentication.svc/REST/Update_FileStatus';
+ static final String getActivePrescriptionsDetails = 'Services/Patients.svc/Rest/GetActivePrescriptionReportByPatientID';
+ static final String getTermsConditions = 'Services/Patients.svc/Rest/GetUserTermsAndConditions';
+ static final String getMonthlyReports = 'Services/Patients.svc/Rest/UpdatePateintHealthSummaryReport';
+ static final String updatePatientEmail = 'Services/Patients.svc/Rest/UpdatePateintEmail';
+ static final String getQrParkingDetails = 'Services/SWP.svc/REST/GetQRParkingByID';
// Ancillary Order Apis
static final String getOnlineAncillaryOrderList = 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderList';
@@ -825,11 +816,12 @@ class ApiConsts {
static final String updateHHCOrder = 'api/hhc/update';
static final String addHHCOrder = 'api/HHC/add';
- // SYMPTOMS CHECKER
+ // SYMPTOMS CHECKER API
+ static final String symptomsUserLogin = '$symptomsCheckerApi/user_login';
static final String getBodySymptomsByName = '$symptomsCheckerApi/GetBodySymptomsByName';
static final String getRiskFactors = '$symptomsCheckerApi/GetRiskFactors';
static final String getSuggestions = '$symptomsCheckerApi/GetSuggestion';
- static final String diagnosis = '$symptomsCheckerApi/diagnosis';
+ static final String diagnosis = '$symptomsCheckerApi/GetDiagnosis';
static final String explain = '$symptomsCheckerApi/explain';
//E-REFERRAL SERVICES
@@ -848,6 +840,31 @@ class ApiConsts {
static String h2oUpdateUserDetail = "Services/H2ORemainder.svc/REST/H2O_UpdateUserDetails_New";
static String h2oUndoUserActivity = "Services/H2ORemainder.svc/REST/H2o_UndoUserActivity";
+ // HEALTH TRACKERS
+ // Blood Sugar (Diabetic)
+ static String getDiabeticResultAverage = 'Services/Patients.svc/REST/Patient_GetDiabeticResultAverage';
+ static String getDiabeticResult = 'Services/Patients.svc/REST/Patient_GetDiabtecResults';
+ static String addDiabeticResult = 'Services/Patients.svc/REST/Patient_AddDiabtecResult';
+ static String updateDiabeticResult = 'Services/Patients.svc/REST/Patient_UpdateDiabtecResult';
+ static String deactivateDiabeticStatus = 'Services/Patients.svc/REST/Patient_DeactivateDiabeticStatus';
+ static String sendAverageBloodSugarReport = 'Services/Notifications.svc/REST/SendAverageBloodSugarReport';
+
+ // Blood Pressure
+ static String getBloodPressureResultAverage = 'Services/Patients.svc/REST/Patient_GetBloodPressureResultAverage';
+ static String getBloodPressureResult = 'Services/Patients.svc/REST/Patient_GetBloodPressureResult';
+ static String addBloodPressureResult = 'Services/Patients.svc/REST/Patient_AddBloodPressureResult';
+ static String updateBloodPressureResult = 'Services/Patients.svc/REST/Patient_UpdateBloodPressureResult';
+ static String deactivateBloodPressureStatus = 'Services/Patients.svc/REST/Patient_DeactivateBloodPressureStatus';
+ static String sendAverageBloodPressureReport = 'Services/Notifications.svc/REST/SendAverageBloodPressureReport';
+
+ // Weight Measurement
+ static String getWeightMeasurementResultAverage = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResultAverage';
+ static String getWeightMeasurementResult = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResult';
+ static String addWeightMeasurementResult = 'Services/Patients.svc/REST/Patient_AddWeightMeasurementResult';
+ static String updateWeightMeasurementResult = 'Services/Patients.svc/REST/Patient_UpdateWeightMeasurementResult';
+ static String deactivateWeightMeasurementStatus = 'Services/Patients.svc/REST/Patient_DeactivateWeightMeasurementStatus';
+ static String sendAverageBodyWeightReport = 'Services/Notifications.svc/REST/SendAverageBodyWeightReport';
+
//Blood Donation
static String bloodGroupUpdate = "Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType";
static String userAgreementForBloodGroupUpdate = "Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation";
diff --git a/lib/core/app_assets.dart b/lib/core/app_assets.dart
index 97637589..d378c78f 100644
--- a/lib/core/app_assets.dart
+++ b/lib/core/app_assets.dart
@@ -270,16 +270,21 @@ class AppAssets {
static const String yellowArrowDownIcon = '$svgBasePath/yellow_arrow_down_icon.svg';
static const String greenTickIcon = '$svgBasePath/green_tick_icon.svg';
- // PNGS
-
-
static const String bloodSugar = '$svgBasePath/bloodsugar.svg';
static const String bloodCholestrol = '$svgBasePath/bloodcholestrol.svg';
static const String triglycerides = '$svgBasePath/triglycerides.svg';
static const String bulb = '$svgBasePath/bulb.svg';
static const String switchBtn = '$svgBasePath/switch.svg';
+ //Health Trackers
+ static const String bloodPressureIcon = '$svgBasePath/blood_pressure_icon.svg';
+ static const String bloodSugarOnlyIcon = '$svgBasePath/blood_sugar_only_icon.svg';
+ static const String weightIcon = '$svgBasePath/weight_icon.svg';
+ static const String normalStatusGreenIcon = '$svgBasePath/normal_status_green_icon.svg';
+ static const String sendEmailIcon = '$svgBasePath/send_email_icon.svg';
+ static const String lowIndicatorIcon = '$svgBasePath/low_indicator_icon.svg';
+ // Health Calculators
static const String ovulationAccordion = '$svgBasePath/approximate_ovulation_accordion.svg';
static const String nextPeriodAccordion = '$svgBasePath/next_period_accordion.svg';
static const String fertileAccordion = '$svgBasePath/fertile_window_accordion.svg';
@@ -288,9 +293,7 @@ class AppAssets {
static const String covid19icon = '$svgBasePath/covid_19.svg';
-
//vital sign
-
static const String heartRate = '$svgBasePath/heart_rate.svg';
static const String respRate = '$svgBasePath/resp_rate.svg';
static const String weightVital = '$svgBasePath/weight_2.svg';
@@ -299,8 +302,6 @@ class AppAssets {
static const String bloodPressure = '$svgBasePath/blood_pressure.svg';
static const String temperature = '$svgBasePath/temperature.svg';
-
-
// PNGS //
static const String hmgLogo = '$pngBasePath/hmg_logo.png';
static const String liveCareService = '$pngBasePath/livecare_service.png';
@@ -327,8 +328,6 @@ class AppAssets {
static const String fullBodyFront = '$pngBasePath/full_body_front.png';
static const String fullBodyBack = '$pngBasePath/full_body_back.png';
static const String bmiFullBody = '$pngBasePath/bmi_image_1.png';
-
-
}
class AppAnimations {
@@ -349,6 +348,5 @@ class AppAnimations {
static const String ambulance = '$lottieBasePath/ambulance.json';
static const String ambulanceAlert = '$lottieBasePath/ambulance_alert.json';
static const String rrtAmbulance = '$lottieBasePath/rrt_ambulance.json';
-
-
}
+
diff --git a/lib/core/dependencies.dart b/lib/core/dependencies.dart
index 7db5d414..e8d30713 100644
--- a/lib/core/dependencies.dart
+++ b/lib/core/dependencies.dart
@@ -10,6 +10,8 @@ import 'package:hmg_patient_app_new/features/blood_donation/blood_donation_repo.
import 'package:hmg_patient_app_new/features/blood_donation/blood_donation_view_model.dart';
import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_repo.dart';
import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_view_model.dart';
+import 'package:hmg_patient_app_new/features/active_prescriptions/active_prescriptions_view_model.dart';
+import 'package:hmg_patient_app_new/features/active_prescriptions/models/active_prescriptions_response_model.dart';
import 'package:hmg_patient_app_new/features/common/common_repo.dart';
import 'package:hmg_patient_app_new/features/contact_us/contact_us_repo.dart';
import 'package:hmg_patient_app_new/features/contact_us/contact_us_view_model.dart';
@@ -18,6 +20,7 @@ import 'package:hmg_patient_app_new/features/emergency_services/emergency_servic
import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_repo.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
+import 'package:hmg_patient_app_new/features/health_trackers/health_trackers_repo.dart';
import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_repo.dart';
import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart';
import 'package:hmg_patient_app_new/features/immediate_livecare/immediate_livecare_repo.dart';
@@ -43,6 +46,7 @@ import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart';
import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_repo.dart';
import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart';
import 'package:hmg_patient_app_new/features/profile_settings/profile_settings_view_model.dart';
+import 'package:hmg_patient_app_new/features/qr_parking/qr_parking_repo.dart';
import 'package:hmg_patient_app_new/features/radiology/radiology_repo.dart';
import 'package:hmg_patient_app_new/features/radiology/radiology_view_model.dart';
import 'package:hmg_patient_app_new/features/smartwatch_health_data/health_provider.dart';
@@ -52,7 +56,9 @@ import 'package:hmg_patient_app_new/features/todo_section/todo_section_repo.dart
import 'package:hmg_patient_app_new/features/todo_section/todo_section_view_model.dart';
import 'package:hmg_patient_app_new/features/water_monitor/water_monitor_repo.dart';
import 'package:hmg_patient_app_new/features/water_monitor/water_monitor_view_model.dart';
+import 'package:hmg_patient_app_new/presentation/health_trackers/health_trackers_view_model.dart';
import 'package:hmg_patient_app_new/services/analytics/analytics_service.dart';
+import 'package:hmg_patient_app_new/presentation/monthly_reports/monthly_reports_page.dart';
import 'package:hmg_patient_app_new/services/cache_service.dart';
import 'package:hmg_patient_app_new/services/dialog_service.dart';
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
@@ -66,8 +72,13 @@ import 'package:local_auth/local_auth.dart';
import 'package:logger/web.dart';
import 'package:shared_preferences/shared_preferences.dart';
+import '../features/qr_parking/qr_parking_view_model.dart';
import '../presentation/health_calculators_and_converts/health_calculator_view_model.dart';
+import '../features/active_prescriptions/active_prescriptions_repo.dart';
+import '../features/monthly_reports/terms_conditions_repo.dart';
+import '../features/monthly_reports/terms_conditions_view_model.dart';
+
GetIt getIt = GetIt.instance;
class AppDependencies {
@@ -143,7 +154,21 @@ class AppDependencies {
getIt.registerLazySingleton(() => BloodDonationRepoImp(loggerService: getIt(), apiClient: getIt()));
getIt.registerLazySingleton(() => WaterMonitorRepoImp(loggerService: getIt(), apiClient: getIt()));
getIt.registerLazySingleton(() => MyInvoicesRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerLazySingleton(() => HealthTrackersRepoImp(loggerService: getIt(), apiClient: getIt()));
getIt.registerLazySingleton(() => MonthlyReportRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerLazySingleton(() => ActivePrescriptionsRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerLazySingleton(() => TermsConditionsRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerFactory(() => TermsConditionsViewModel(termsConditionsRepo: getIt(), errorHandlerService: getIt(),
+ ),);
+ getIt.registerLazySingleton(() => MonthlyReportsRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerLazySingleton(() => QrParkingRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerFactory(
+ () => QrParkingViewModel(
+ qrParkingRepo: getIt(),
+ errorHandlerService: getIt(),
+ cacheService: getIt(),
+ ),
+ );
// ViewModels
// Global/shared VMs → LazySingleton
@@ -260,10 +285,30 @@ class AppDependencies {
getIt.registerLazySingleton(() => HealthProvider());
- getIt.registerLazySingleton(() => WaterMonitorViewModel(waterMonitorRepo: getIt()));
+ getIt.registerLazySingleton(() => WaterMonitorViewModel(waterMonitorRepo: getIt(), errorHandlerService: getIt()));
getIt.registerLazySingleton(() => MyInvoicesViewModel(myInvoicesRepo: getIt(), errorHandlerService: getIt(), navServices: getIt()));
getIt.registerLazySingleton(() => MonthlyReportViewModel(errorHandlerService: getIt(), monthlyReportRepo: getIt()));
+ getIt.registerLazySingleton(() => MyInvoicesViewModel(
+ myInvoicesRepo: getIt(),
+ errorHandlerService: getIt(),
+ navServices: getIt(),
+ ));
+ getIt.registerLazySingleton(() => HealthTrackersViewModel(healthTrackersRepo: getIt(), errorHandlerService: getIt()));
+ getIt.registerLazySingleton(
+ () => ActivePrescriptionsViewModel(
+ errorHandlerService: getIt(),
+ activePrescriptionsRepo: getIt()
+ ),
+ );
+ getIt.registerFactory(
+ () => QrParkingViewModel(
+ qrParkingRepo: getIt(),
+ errorHandlerService: getIt(),
+ cacheService: getIt(),
+ ),
+ );
+
}
}
diff --git a/lib/core/enums.dart b/lib/core/enums.dart
index 8fd4818c..6dc3bf68 100644
--- a/lib/core/enums.dart
+++ b/lib/core/enums.dart
@@ -16,7 +16,7 @@ enum CountryEnum { saudiArabia, unitedArabEmirates }
enum CalenderEnum { gregorian, hijri }
-enum SelectionTypeEnum { dropdown, calendar, search }
+enum SelectionTypeEnum { dropdown, calendar, search, time }
enum GenderTypeEnum { male, female }
@@ -38,7 +38,19 @@ enum HealthCalConEnum { calculator, converter }
enum HealthCalculatorEnum { general, women }
-enum HealthCalculatorsTypeEnum { bmi, calories, bmr, idealBodyWeight, bodyFat, crabsProteinFat, ovulation, deliveryDueDate, bloodSugar, bloodCholesterol, triglycerides }
+enum HealthCalculatorsTypeEnum {
+ bmi,
+ calories,
+ bmr,
+ idealBodyWeight,
+ bodyFat,
+ crabsProteinFat,
+ ovulation,
+ deliveryDueDate,
+ bloodSugar,
+ bloodCholesterol,
+ triglycerides
+}
extension HealthCalculatorExtenshion on HealthCalculatorsTypeEnum {
String get displayName {
@@ -297,3 +309,5 @@ extension ServiceTypeEnumExt on ServiceTypeEnum {
// SymptomsChecker
enum PossibleConditionsSeverityEnum { seekMedicalAdvice, monitorOnly, emergency }
+
+enum HealthTrackerTypeEnum { bloodSugar, bloodPressure, weightTracker }
diff --git a/lib/core/utils/calendar_utils.dart b/lib/core/utils/calendar_utils.dart
new file mode 100644
index 00000000..8c0db187
--- /dev/null
+++ b/lib/core/utils/calendar_utils.dart
@@ -0,0 +1,316 @@
+import 'dart:async';
+import 'dart:collection';
+import 'dart:convert';
+import 'dart:io';
+import 'dart:ui';
+
+import 'package:device_calendar/device_calendar.dart';
+import 'package:flutter/widgets.dart';
+import 'package:hmg_patient_app_new/core/dependencies.dart';
+import 'package:hmg_patient_app_new/core/utils/date_util.dart';
+import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
+import 'package:hmg_patient_app_new/presentation/prescriptions/prescription_reminder_view.dart';
+import 'package:hmg_patient_app_new/services/dialog_service.dart';
+import 'package:hmg_patient_app_new/services/permission_service.dart';
+import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
+import 'package:jiffy/jiffy.dart';
+import 'package:manage_calendar_events/manage_calendar_events.dart' as ios;
+import 'package:permission_handler/permission_handler.dart';
+import 'package:timezone/data/latest.dart' as tzl;
+
+final DeviceCalendarPlugin deviceCalendarPlugin = DeviceCalendarPlugin();
+final ios.CalendarPlugin _myPlugin = ios.CalendarPlugin();
+
+class CalendarUtils {
+ static Completer? _completer;
+
+ dynamic get writableCalendars => calendars.firstWhere((c) => !c.isReadOnly!);
+ dynamic calendars;
+
+ CalendarUtils._(this.calendars);
+
+ // static Future getInstance() async {
+ // if (_completer == null) {
+ // _completer = Completer();
+ // print(_completer!.isCompleted);
+ // try {
+ // final dynamic calendarsResult;
+ // if (Platform.isIOS) {
+ // calendarsResult = await _myPlugin.getCalendars();
+ // if (!_completer!.isCompleted) {
+ // _completer?.complete(CalendarUtils._(await calendarsResult!));
+ // }
+ // } else {
+ // calendarsResult = await deviceCalendarPlugin.retrieveCalendars();
+ // if (!_completer!.isCompleted) {
+ // _completer?.complete(CalendarUtils._(await calendarsResult.data!));
+ // }
+ // }
+ // } on Exception catch (e) {
+ // if (!_completer!.isCompleted) {
+ // _completer!.completeError(e);
+ // }
+ // }
+ // }
+ // return _completer!.future;
+ // }
+
+ static Future getInstance() async {
+ tzl.initializeTimeZones();
+ if (_completer != null) {
+ return _completer!.future;
+ }
+ _completer = Completer();
+ try {
+ final dynamic calendarsResult;
+ if (Platform.isIOS) {
+ calendarsResult = await _myPlugin.getCalendars();
+ _completer!.complete(CalendarUtils._(calendarsResult));
+ } else {
+ calendarsResult = await deviceCalendarPlugin.retrieveCalendars();
+ _completer!.complete(CalendarUtils._(calendarsResult.data));
+ }
+ } catch (e) {
+ _completer!.completeError(e);
+ }
+
+ return _completer!.future;
+ }
+
+ Future createOrUpdateEvents({List? scheduleList, String? title, String? description, List? scheduleDateTime, List? daysOfWeek}) async {
+ tzl.initializeTimeZones();
+ List events = [];
+ Location _currentLocation;
+ if (DateTime.now().timeZoneName == "+04")
+ _currentLocation = getLocation('Asia/Dubai');
+ else
+ _currentLocation = getLocation('Asia/Riyadh');
+
+ scheduleDateTime!.forEach((element) {
+ RecurrenceRule recurrenceRule = RecurrenceRule(
+ // RecurrenceFrequency.Daily,
+ // daysOfWeek: daysOfWeek,
+ // endDate: element,
+ until: element, frequency: Frequency.daily,
+ );
+ //added byAamir Tz Time
+ Event event = Event(writableCalendars!.id,
+ recurrenceRule: recurrenceRule,
+ start: TZDateTime.from(element, _currentLocation),
+ end: TZDateTime.from(element.add(Duration(minutes: 30)), _currentLocation),
+ title: title,
+ description: description);
+ events.add(event);
+ });
+
+ events.forEach((element) {
+ deviceCalendarPlugin.createOrUpdateEvent(element);
+ });
+ }
+
+ Future createOrUpdateEvent({required String title, required String description, required String location, DateTime? scheduleDateTime, String? eventId}) async {
+ RecurrenceRule recurrenceRule = RecurrenceRule(
+ // RecurrenceFrequency.Daily,
+ // daysOfWeek: daysOfWeek,
+ // endDate: scheduleDateTime,
+ until: scheduleDateTime, frequency: Frequency.daily,
+ );
+
+ Location _currentLocation;
+ // if (DateTime.now().timeZoneName == "+04")
+ // _currentLocation = getLocation('Asia/Dubai');
+ // else
+ _currentLocation = getLocation('Asia/Riyadh');
+
+ TZDateTime scheduleDateTimeUTZ = TZDateTime.from(scheduleDateTime!, _currentLocation);
+
+ print("writableCalendars-name: " + writableCalendars.name);
+ print("writableCalendars-Id: " + writableCalendars.id);
+ print("writableCalendarsToString: " + writableCalendars.toString());
+ print("writableCalendarsToString: " + writableCalendars!.id!);
+ Event event = Event(
+ writableCalendars!.id,
+ start: scheduleDateTimeUTZ,
+ end: scheduleDateTimeUTZ.add(Duration(minutes: 30)),
+ title: title,
+ description: description,
+ );
+
+ ios.CalendarEvent iosCalEvent =
+ ios.CalendarEvent(location: location, startDate: scheduleDateTimeUTZ, endDate: scheduleDateTimeUTZ.add(Duration(minutes: 30)), title: title, description: description, isAllDay: false);
+
+ if (Platform.isAndroid) {
+ Result result = await deviceCalendarPlugin.hasPermissions();
+ print(result);
+ await deviceCalendarPlugin.createOrUpdateEvent(event).catchError((e) {
+ print("catchError " + e.toString());
+ }).whenComplete(() {
+ print("whenComplete Calender ID " + eventId!);
+ });
+ } else {
+ await _myPlugin.createEvent(calendarId: writableCalendars.id!, event: iosCalEvent).catchError((e) {
+ print("catchError " + e.toString());
+ }).whenComplete(() {
+ print("whenComplete Calender ID iOS " + eventId!);
+ });
+ }
+ }
+
+ deleteEvent(String _calendarId, String _eventId) async {
+ if (Platform.isIOS) {
+ await _myPlugin.deleteEvent(calendarId: _calendarId, eventId: _eventId);
+ } else {
+ await deviceCalendarPlugin.deleteEvent(_calendarId, _eventId);
+ }
+ }
+
+ Future retrieveEvents(
+ String calendarId,
+ RetrieveEventsParams retrieveEventsParams,
+ ) async {
+ if (Platform.isIOS) {
+ return await _myPlugin.getEvents(calendarId: calendarId);
+ } else {
+ return await deviceCalendarPlugin.retrieveEvents(calendarId, retrieveEventsParams);
+ }
+ }
+
+ Future createCalendar(
+ String calendarName, {
+ Color? calendarColor,
+ String? localAccountName,
+ }) async {
+ return await deviceCalendarPlugin.createCalendar(calendarName, calendarColor: calendarColor, localAccountName: localAccountName);
+ }
+}
+
+Future