From d232cead63c041c482ea1f7c654f437cdf6544fe Mon Sep 17 00:00:00 2001 From: tahaalam Date: Mon, 12 Jan 2026 11:18:36 +0300 Subject: [PATCH] changes for live activity --- .../ejada/hmg/live_activity/CustomActiviy.kt | 12 ++++++------ android/app/src/main/res/values/strings.xml | 1 + lib/core/common_models/patient_queue.dart | 18 +++++++----------- lib/core/utils/push_notification_handler.dart | 7 +++---- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/android/app/src/main/kotlin/com/ejada/hmg/live_activity/CustomActiviy.kt b/android/app/src/main/kotlin/com/ejada/hmg/live_activity/CustomActiviy.kt index bd604be1..f648cb16 100644 --- a/android/app/src/main/kotlin/com/ejada/hmg/live_activity/CustomActiviy.kt +++ b/android/app/src/main/kotlin/com/ejada/hmg/live_activity/CustomActiviy.kt @@ -36,17 +36,17 @@ class CustomLiveActivityManager(context: Context) : ) private suspend fun updateRemoteViews(data: Map) { - val (background, textColor, containerBackground) = when (data["nextTicketBackground"] as? Int) { - 0 -> Triple(R. drawable.grey_rounded_corner_widget, R.color.text_color, R.drawable.whitebg_yellow_border_rounded_corner_widget) + val (nextStepButtonBackground, textColor, containerBackground) = when (data["callType"] as? Int) { + 0 -> Triple(R.drawable.grey_rounded_corner_widget, R.color.text_color, R.drawable.whitebg_yellow_border_rounded_corner_widget) 1 -> Triple(R.drawable.dark_red_rounded_corner_widget, R.color.colorWhite, R.drawable.whitebg_red_border_rounded_corner_widget) 2 -> Triple(R.drawable.green_rounded_corner_widget, R. color.colorWhite, R. drawable.whitebg_green_border_rounded_corner_widget) else -> Triple(R. drawable.grey_rounded_corner_widget, R.color.text_color, R.drawable.whitebg_yellow_border_rounded_corner_widget) } - remoteViews.setInt(R.id.nextStep, "setBackgroundResource", background) + remoteViews.setInt(R.id.nextStep, "setBackgroundResource", nextStepButtonBackground) remoteViews.setInt(R.id.container, "setBackgroundResource", containerBackground) remoteViews.setTextColor(R.id.nextStep, ContextCompat.getColor(context, textColor)) - remoteViews.setTextViewText(R.id.countvalue, data["nextTicket"] as? String ?: "") + remoteViews.setTextViewText(R.id.countvalue, data["queueNo"] as? String ?: "") remoteViews.setTextViewText(R.id.status, data["currentlyServingStatus"] as? String ?: "") remoteViews.setTextViewText(R. id.currentlyserving, data["currentlyServing"] as? String ?: "") remoteViews.setTextViewText(R.id.nextStep, data["nextTicketStatus"] as? String ?: "") @@ -55,14 +55,14 @@ class CustomLiveActivityManager(context: Context) : private suspend fun updateCollapsedView(data: Map) { Log.d("updateCollapsedView", "current ticket is ${data["currentTicket"] as? String ?: ""}") - val containerBackground = when (data["nextStepBackground"] as? Int) { + val containerBackground = when (data["callType"] as? Int) { 0 -> R.drawable.whitebg_yellow_border_rounded_corner_widget 1 -> R. drawable.whitebg_red_border_rounded_corner_widget 2 -> R.drawable. whitebg_green_border_rounded_corner_widget else -> R.drawable.whitebg_yellow_border_rounded_corner_widget } collapesView.setInt(R.id.container, "setBackgroundResource", containerBackground) - collapesView.setTextViewText(R.id.countvalue_collapsed, data["currentTicket"] as? String ?: "") + collapesView.setTextViewText(R.id.countvalue_collapsed, data["queueNo"] as? String ?: "") } override suspend fun buildNotification( diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 2d103337..4a6602a0 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -20,4 +20,5 @@ Geofence requests happened too frequently. pk.eyJ1IjoicndhaWQiLCJhIjoiY2x5cGo4aHNjMGNsbTJyc2djempobGQxaSJ9.RCaC6WrUt4A4YnZNfxnONQ + diff --git a/lib/core/common_models/patient_queue.dart b/lib/core/common_models/patient_queue.dart index 8b14d688..4ed0c725 100644 --- a/lib/core/common_models/patient_queue.dart +++ b/lib/core/common_models/patient_queue.dart @@ -1,26 +1,22 @@ class PatientQueue { - final String? title; // for title of the notification - final String? contentText; // for the content of the notification - final String? nextTicket; + final String? queueNo; final String? currentlyServingStatus; - final String? currentlyServing; + final String? currentlyServingTitle; final String? nextTicketStatus; - final int? nextTicketBackground;// background will be same as of the [Utils.getCardButtonColor] + final int? callType;// background will be same as of the [Utils.getCardButtonColor] - const PatientQueue({this.title, this.contentText, this.nextTicket, this.currentlyServingStatus, this.currentlyServing, this.nextTicketStatus, this.nextTicketBackground}); + const PatientQueue({ this.queueNo, this.currentlyServingStatus, this.nextTicketStatus, this.callType, this.currentlyServingTitle, }); /// Converts this PatientQueue object to a map. /// This is used for passing data to the native side for Live Activities. Map toMap() { return { - 'title': title, - 'contentText': contentText, - 'nextTicket': nextTicket, + 'nextTicket': queueNo, 'currentlyServingStatus': currentlyServingStatus, - 'currentlyServing': currentlyServing, 'nextTicketStatus': nextTicketStatus, - 'nextTicketBackground': nextTicketBackground, + 'nextTicketBackground': callType, + 'currentlyServingTitle': currentlyServingTitle, }; } } \ No newline at end of file diff --git a/lib/core/utils/push_notification_handler.dart b/lib/core/utils/push_notification_handler.dart index ff0bc00b..7b19050d 100644 --- a/lib/core/utils/push_notification_handler.dart +++ b/lib/core/utils/push_notification_handler.dart @@ -18,6 +18,7 @@ import 'package:flutter_ios_voip_kit_karmm/flutter_ios_voip_kit.dart'; import 'package:hmg_patient_app_new/core/common_models/patient_queue.dart'; import 'package:hmg_patient_app_new/core/cache_consts.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; +import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/services/cache_service.dart'; import 'package:live_activities/live_activities.dart' show LiveActivities; import 'package:permission_handler/permission_handler.dart'; @@ -45,10 +46,8 @@ Future backgroundMessageHandler(dynamic message) async { await Permission.notification.request(); PatientQueue _patientQueue = PatientQueue( - title: message.data['title']??"HMG", - contentText: message.data['contentText']??"HMG Queue line", - nextTicket: message.data['nextTicket']??"IME-1", - currentlyServingStatus: message.data['currentlyServingStatus']??"Call for vital signs", + queueNo: message.data['queueNo']??"IME-1", + currentlyServingStatus: (message.data['callType']??0) == 1 ? "Call for vital signs".needTranslation : "Call for Doctor".needTranslation, currentlyServing: message.data['currentlyServing']??"IME-3", nextTicketStatus: message.data['nextTicketStatus']??"Please wait! you will be called for vital signs", nextTicketBackground: message.data['nextTicketBackground']??2