|
|
|
|
@ -13,6 +13,7 @@ import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/dialog_service.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/navigation_service.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
|
@ -66,7 +67,6 @@ class Utils {
|
|
|
|
|
hours: isAddHours ? 3 : 0,
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String convertStringToDateTime(String dateTimeString) {
|
|
|
|
|
@ -236,7 +236,8 @@ class Utils {
|
|
|
|
|
showDialog(
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (cxt) => ConfirmDialog(
|
|
|
|
|
builder: (cxt) =>
|
|
|
|
|
ConfirmDialog(
|
|
|
|
|
title: title!,
|
|
|
|
|
message: message!,
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
@ -371,7 +372,9 @@ class Utils {
|
|
|
|
|
static String formatHijriDateToDisplay(String hijriDateString) {
|
|
|
|
|
try {
|
|
|
|
|
// Assuming hijriDateString is in the format yyyy-MM-dd
|
|
|
|
|
final datePart = hijriDateString.split("T").first;
|
|
|
|
|
final datePart = hijriDateString
|
|
|
|
|
.split("T")
|
|
|
|
|
.first;
|
|
|
|
|
final parts = datePart.split('-');
|
|
|
|
|
if (parts.length != 3) return "";
|
|
|
|
|
|
|
|
|
|
@ -429,8 +432,14 @@ class Utils {
|
|
|
|
|
void Function(LottieComposition)? onLoaded,
|
|
|
|
|
}) {
|
|
|
|
|
return Lottie.asset(assetPath,
|
|
|
|
|
height: height ?? MediaQuery.of(context).size.height * 0.26,
|
|
|
|
|
width: width ?? MediaQuery.of(context).size.width,
|
|
|
|
|
height: height ?? MediaQuery
|
|
|
|
|
.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.height * 0.26,
|
|
|
|
|
width: width ?? MediaQuery
|
|
|
|
|
.of(context)
|
|
|
|
|
.size
|
|
|
|
|
.width,
|
|
|
|
|
fit: fit,
|
|
|
|
|
alignment: alignment,
|
|
|
|
|
repeat: repeat,
|
|
|
|
|
@ -487,9 +496,13 @@ class Utils {
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Future<bool> isGoogleServicesAvailable() async {
|
|
|
|
|
GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability();
|
|
|
|
|
String status = availability.toString().split('.').last;
|
|
|
|
|
String status = availability
|
|
|
|
|
.toString()
|
|
|
|
|
.split('.')
|
|
|
|
|
.last;
|
|
|
|
|
if (status == "success") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@ -510,3 +523,26 @@ class Utils {
|
|
|
|
|
return crypto.md5.convert(utf8.encode(input)).toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ValidationUtils {
|
|
|
|
|
static DialogService dialogService = getIt.get<DialogService>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool isValidatePhoneAndId({
|
|
|
|
|
String? nationalId,
|
|
|
|
|
String? phoneNumber
|
|
|
|
|
}) {
|
|
|
|
|
if (nationalId == null || nationalId.isEmpty) {
|
|
|
|
|
dialogService.showErrorDialog(message: "Please enter a valid national ID or file number", onOkPressed: () {});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (phoneNumber == null || phoneNumber.isEmpty) {
|
|
|
|
|
dialogService.showErrorDialog(message: "Please enter a valid phone number", onOkPressed: () {});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|