merge changes

pull/11/head
Sikander Saleem 2 months ago
parent 6473ccecb5
commit d385d0362f

@ -4,7 +4,12 @@ import 'dart:io';
import 'dart:ui';
import 'package:device_calendar/device_calendar.dart';
import 'package:flutter/widgets.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/services/permission_service.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();
@ -44,6 +49,94 @@ class CalendarUtils {
// return _completer!.future;
// }
Future<Map<Permission, PermissionStatus>> requestPermissions() async {
var permissionResults = [Permission.calendarFullAccess].request();
return permissionResults;
}
// showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted,
// {required Function() onSuccess, String? title, String? description, Function(int)? onMultiDateSuccess, bool isMultiAllowed = false}) async {
// if (Platform.isAndroid) {
// if (await PermissionService.isCalendarPermissionEnabled()) {
// _showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted,
// onSuccess: onSuccess, title: title, description: description, onMultiDateSuccess: onMultiDateSuccess, isMultiAllowed: isMultiAllowed);
// } else {
// // Utils.showPermissionConsentDialog(context, TranslationBase.of(context).calendarPermission, () async {
// // if (await Permission.calendarFullAccess.request().isGranted) {
// // _showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted,
// // onSuccess: onSuccess, title: title, description: description, onMultiDateSuccess: onMultiDateSuccess, isMultiAllowed: isMultiAllowed);
// // }
// // });
// }
// } else {
// if (await Permission.calendarWriteOnly.request().isGranted) {
// if (await Permission.calendarFullAccess.request().isGranted) {
// _showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted,
// onSuccess: onSuccess, title: title, description: description, onMultiDateSuccess: onMultiDateSuccess, isMultiAllowed: isMultiAllowed);
// }
// }
// }
// }
// Future<void> _showReminderDialog(BuildContext providedContext, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted,
// {required Function onSuccess, String? title, String? description, Function(int)? onMultiDateSuccess, bool? isMultiAllowed}) async {
// return showDialog<void>(
// context: providedContext,
// barrierDismissible: true, // user must tap button!
// builder: (BuildContext context) {
// return Dialog(
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0.0)),
// insetPadding: EdgeInsets.all(21),
// child: ReminderDialog(
// onClick: (int i) async {
// String text = "";
// if (i == 0) {
// // Before 30 mints
// dateTime = Jiffy.parseFromDateTime(dateTime).subtract(minutes: 30).dateTime;
// text = "30 minutes";
// // dateTime.add(new Duration(minutes: -30));
// } else if (i == 1) {
// // Before 1 hour
// // dateTime.add(new Duration(minutes: -60));
// dateTime = Jiffy.parseFromDateTime(dateTime).subtract(hours: 1).dateTime;
// text = "1 hours";
// } else if (i == 2) {
// // Before 1 hour and 30 mints
// // dateTime.add(new Duration(minutes: -90));
// dateTime = Jiffy.parseFromDateTime(dateTime).subtract(hours: 1, minutes: 30).dateTime;
// text = "1 hours 30 minutes";
// } else if (i == 3) {
// // Before 2 hours
// // dateTime.add(new Duration(minutes: -120));
// dateTime = Jiffy.parseFromDateTime(dateTime).subtract(hours: 2).dateTime;
// text = "2 hours";
// }
// if (!isMultiAllowed!) {
// if (onMultiDateSuccess == null) {
// CalendarUtils calendarUtils = await CalendarUtils.getInstance();
// await calendarUtils.createOrUpdateEvent(
// title: title ?? "TranslationBase.of(providedContext).reminderTitle".needTranslation + " " + doctorName,
// description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted,
// scheduleDateTime: dateTime,
// eventId: eventId, location: '');
// onSuccess();
// }
// } else {
// onMultiDateSuccess!(i);
// }
// // await _analytics.logEvent(
// // name: name.trim().toLowerCase(),
// // parameters: safeParameters,
// // );
// // todo @sikander discuss analytics for reminder
// // locator<GAnalytics>().appointment.appointment_reminder_time(reminde_before: text);
// },
// ),
// );
// },
// );
// }
static Future<CalendarUtils> getInstance() async {
tzl.initializeTimeZones();
if (_completer != null) {

@ -13,6 +13,8 @@ extension CapExtension on String {
String get allInCaps => this.toUpperCase();
String get needTranslation => this;
String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : "";
}
@ -230,14 +232,11 @@ extension EmailValidator on String {
style: TextStyle(height: height ?? 23 / 26, color: color ?? AppColors.blackColor, fontSize: 26.fSize, letterSpacing: -1, fontWeight: isBold ? FontWeight.bold : FontWeight.normal),
);
Widget toText28({Color? color, bool isBold = false, double? height, bool isCenter = false}) => Text(
this,
textAlign: isCenter ? TextAlign.center : null,
style: TextStyle(height: height ?? 23 / 28, color: color ?? AppColors.blackColor, fontSize: 28.fSize, letterSpacing: -1, fontWeight: isBold ? FontWeight.bold : FontWeight.normal),
);
this,
textAlign: isCenter ? TextAlign.center : null,
style: TextStyle(height: height ?? 23 / 28, color: color ?? AppColors.blackColor, fontSize: 28.fSize, letterSpacing: -1, fontWeight: isBold ? FontWeight.bold : FontWeight.normal),
);
Widget toText32({Color? color, bool isBold = false, bool isCenter = false}) => Text(
this,

@ -173,10 +173,10 @@ class MedicalFilePage extends StatelessWidget {
activeTextColor: Color(0xffED1C2B),
activeBackgroundColor: Color(0xffED1C2B).withValues(alpha: .1),
tabs: [
CustomTabBarModel(AppAssets.myFilesBottom, "General"),
CustomTabBarModel(AppAssets.insurance, "Insurance"),
CustomTabBarModel(AppAssets.requests, "Requests"),
CustomTabBarModel(AppAssets.more, "More"),
CustomTabBarModel(AppAssets.myFilesBottom, "General".needTranslation),
CustomTabBarModel(AppAssets.insurance, "Insurance".needTranslation),
CustomTabBarModel(AppAssets.requests, "Requests".needTranslation),
CustomTabBarModel(AppAssets.more, "More".needTranslation),
],
onTabChange: (index) {},
),

@ -313,6 +313,7 @@ class _PrescriptionDetailPageState extends State<PrescriptionDetailPage> {
SizedBox(width: 12.h),
Switch(
activeColor: AppColors.successColor,
activeTrackColor: AppColors.successColor.withValues(alpha: .15),
value: prescriptionVM.prescriptionDetailsList[index].hasReminder!,
onChanged: (newValue) {
setState(() {

@ -0,0 +1,92 @@
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
// import 'package:vibration/vibration.dart';
import 'package:geolocator/geolocator.dart' as geo;
class PermissionService {
// final LocalStorage storage = new LocalStorage("permission");
geo.LocationPermission? locationPermission;
// AppGlobal appGlobal = new AppGlobal();
// setVibrationPermission(flag) async {
// storage.setItem('isVibration', flag);
// }
//
// isVibrationEnabled() {
// return (storage.getItem('isVibration') == null) ||
// (storage.getItem('isVibration')) == false
// ? false
// : true;
// }
// vibrate(callback, context) async {
// if (callback == null) return null;
// if (isVibrationEnabled() == true) {
// // if (await Vibration.hasVibrator() !=null) {
// // Vibration.vibrate(duration: 100);
// // callback();
// // }
// } else {
// callback();
// }
// }
// setTheme(flag) async {
// storage.setItem('isTheme', flag);
// }
//
// isThemeEnabled() {
// return storage.getItem('isTheme');
// }
cameraPermission() async {
Map<Permission, PermissionStatus> statuses = await [
Permission.camera,
].request();
}
static isCameraEnabled() async {
return await Permission.camera.isGranted;
}
static isExternalStorageEnabled() async {
return await Permission.storage.isGranted;
}
static isHealthDataPermissionEnabled() async {
return await Permission.sensors.isGranted;
}
static isMicrophonePermissionEnabled() async {
return await Permission.microphone.isGranted;
}
static isCalendarPermissionEnabled() async {
return await Permission.calendarFullAccess.isGranted;
}
setCameraLocationPermission(context) async {
Navigator.pop(context);
openAppSettings();
}
static isLocationEnabled() async {
var permission = await geo.Geolocator.checkPermission();
if (permission == geo.LocationPermission.denied) {
return false;
} else {
return true;
}
}
openSettings() async {
openAppSettings();
}
openAccessbility() {
// OpenSettings.openAppSetting();
}
}

@ -64,6 +64,7 @@ dependencies:
equatable: ^2.0.7
google_api_availability: ^5.0.1
firebase_analytics: ^11.5.1
jiffy: ^6.4.3
web: any
flutter_staggered_animations: ^1.1.1

Loading…
Cancel
Save