getCallStatus static method
Returns the call status message.
Implementation
static String getCallStatus(
BuildContext context, BaseMessage baseMessage, User? loggedInUser) {
String callMessageText = "";
//check if the message is a call message and the receiver type is user
if (baseMessage is Call) {
Call call = baseMessage;
User initiator = call.callInitiator as User;
//check if the call is initiated
if (call.callStatus == CallStatusConstants.initiated) {
//check if the logged in user is the initiator
if (!isLoggedInUser(initiator, loggedInUser)) {
callMessageText = Translations.of(context).incomingCall;
} else {
callMessageText = Translations.of(context).outgoingCall;
}
} else if (call.callStatus == CallStatusConstants.ongoing) {
callMessageText = Translations.of(context).callAccepted;
} else if (call.callStatus == CallStatusConstants.ended) {
callMessageText = Translations.of(context).callEnded;
} else if (call.callStatus == CallStatusConstants.unanswered) {
if (isLoggedInUser(initiator, loggedInUser)) {
callMessageText = Translations.of(context).callUnanswered;
} else {
callMessageText = Translations.of(context).missedCall;
}
} else if (call.callStatus == CallStatusConstants.cancelled) {
if (isLoggedInUser(initiator, loggedInUser)) {
callMessageText = Translations.of(context).callCancelled;
} else {
callMessageText = Translations.of(context).missedCall;
}
} else if (call.callStatus == CallStatusConstants.rejected) {
if (isLoggedInUser(initiator, loggedInUser)) {
callMessageText = Translations.of(context).callRejected;
} else {
callMessageText = Translations.of(context).missedCall;
}
} else if (call.callStatus == CallStatusConstants.busy) {
if (isLoggedInUser(initiator, loggedInUser)) {
callMessageText = Translations.of(context).callBusy;
} else {
callMessageText = Translations.of(context).missedCall;
}
}
}
return " $callMessageText";
}