|
|
|
@ -15,8 +15,11 @@ import 'package:get_it/get_it.dart';
|
|
|
|
import 'package:google_api_availability/google_api_availability.dart';
|
|
|
|
import 'package:google_api_availability/google_api_availability.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/core/cache_consts.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/core/common_models/patient_queue.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/live_activty_helper_channel.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.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/extensions/widget_extensions.dart';
|
|
|
|
@ -30,6 +33,7 @@ import 'package:hmg_patient_app_new/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/loading_dialog.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/loading_dialog.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/accessibility/preserve_image_colors.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/accessibility/preserve_image_colors.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/accessibility/preserve_svg_colors.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/accessibility/preserve_svg_colors.dart';
|
|
|
|
|
|
|
|
import 'package:live_activities/live_activities.dart';
|
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
@ -1172,4 +1176,51 @@ class Utils {
|
|
|
|
|
|
|
|
|
|
|
|
return normalized;
|
|
|
|
return normalized;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static addLiveNotification(dynamic data, {bool isBackgroundMessage = false}) async {
|
|
|
|
|
|
|
|
var liveActivity = LiveActivities();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
liveActivity.init(appGroupId: "group.alhabib.patientApp");
|
|
|
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
|
|
|
LiveActivityHelperChannel.removeData();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var queueNoForWhichActivityIdCreated = await Utils.getStringFromPrefs(CacheConst.patientQueueNoForLiveActivity);
|
|
|
|
|
|
|
|
var activityId = await Utils.getStringFromPrefs(data.data['queueNo'] ?? "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var buttonText = Utils.getCardButtonText(int.parse(data.data['callType'] ?? "1"), data.data['roomNo']);
|
|
|
|
|
|
|
|
PatientQueue _patientQueue = PatientQueue(
|
|
|
|
|
|
|
|
queueNo: data.data['queueNo'] ?? "IME-1",
|
|
|
|
|
|
|
|
currentlyServingStatus: (data.data['servingCallType'] ?? 0) == "1" ? LocaleKeys.callForVitalSign.tr() : LocaleKeys.callForDoctor.tr(),
|
|
|
|
|
|
|
|
currentlyServingToken: data.data['servingQueueNo'] ?? "IME-3",
|
|
|
|
|
|
|
|
nextTicketStatus: buttonText,
|
|
|
|
|
|
|
|
callType: int.parse(data.data['callType'] ?? "1"),
|
|
|
|
|
|
|
|
currentlyServingCallType: int.parse(data.data['servingCallType'] ?? "1"),
|
|
|
|
|
|
|
|
yourTicketHeader: LocaleKeys.yourQueueNumber.tr(),
|
|
|
|
|
|
|
|
currentlyServingTitle: LocaleKeys.currentServing.tr());
|
|
|
|
|
|
|
|
if ((queueNoForWhichActivityIdCreated ?? "") != (_patientQueue.queueNo ?? "")) {
|
|
|
|
|
|
|
|
liveActivity.endActivity(activityId);
|
|
|
|
|
|
|
|
activityId = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (activityId == "") {
|
|
|
|
|
|
|
|
String? id = await liveActivity.createActivity(
|
|
|
|
|
|
|
|
DateTime.now().millisecondsSinceEpoch.toString(),
|
|
|
|
|
|
|
|
_patientQueue.toMap(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await Utils.saveStringFromPrefs(_patientQueue.queueNo ?? "", id ?? "");
|
|
|
|
|
|
|
|
await Utils.saveStringFromPrefs(CacheConst.patientQueueNoForLiveActivity ?? "", _patientQueue.queueNo ?? "");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
|
|
|
await liveActivity.createOrUpdateActivity(
|
|
|
|
|
|
|
|
activityId,
|
|
|
|
|
|
|
|
_patientQueue.toMap(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
await liveActivity.updateActivity(
|
|
|
|
|
|
|
|
activityId,
|
|
|
|
|
|
|
|
_patientQueue.toMap(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|