changes for live activity

live_activities
tahaalam 2 months ago
parent e87fdafd62
commit d232cead63

@ -36,17 +36,17 @@ class CustomLiveActivityManager(context: Context) :
)
private suspend fun updateRemoteViews(data: Map<String, Any>) {
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<String, Any>) {
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(

@ -20,4 +20,5 @@
Geofence requests happened too frequently.
</string>
<string name="mapbox_access_token" translatable="false">pk.eyJ1IjoicndhaWQiLCJhIjoiY2x5cGo4aHNjMGNsbTJyc2djempobGQxaSJ9.RCaC6WrUt4A4YnZNfxnONQ</string>
<string name="welcome_message_for_live_activity"></string>
</resources>

@ -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<String, dynamic> toMap() {
return {
'title': title,
'contentText': contentText,
'nextTicket': nextTicket,
'nextTicket': queueNo,
'currentlyServingStatus': currentlyServingStatus,
'currentlyServing': currentlyServing,
'nextTicketStatus': nextTicketStatus,
'nextTicketBackground': nextTicketBackground,
'nextTicketBackground': callType,
'currentlyServingTitle': currentlyServingTitle,
};
}
}

@ -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<dynamic> 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

Loading…
Cancel
Save