getCallStatus static method
Returns the call status message: the text of a call action bubble, after a leading space.
Each status reads as its outcome. The direction only counts for the statuses the caller sends:
| Status | Caller | Callee |
|---|---|---|
| initiated | Outgoing Call | Incoming Call |
| ongoing | Call accepted | Call accepted |
| ended | Call ended | Call ended |
| cancelled | Call cancelled | Missed voice call / Missed video call |
| unanswered | Call unanswered | Missed voice call / Missed video call |
| rejected | Call rejected | Call rejected |
| busy | Call busy | Call busy |
Any other status reads "Voice call" or "Video call". A message that is not a Call gives just the space.
Implementation
static String getCallStatus(
BuildContext context,
BaseMessage baseMessage,
User? loggedInUser,
) {
if (baseMessage is! Call) return " ";
final call = baseMessage;
final translations = Translations.of(context);
final video = isVideoCall(call);
if (_isMissedForMe(call, loggedInUser)) {
return video
? " ${translations.missedVideoCall}"
: " ${translations.missedVoiceCall}";
}
final String callMessageText;
switch (call.callStatus) {
case CallStatusConstants.initiated:
callMessageText = _startedBy(call, loggedInUser)
? translations.outgoingCall
: translations.incomingCall;
case CallStatusConstants.ongoing:
callMessageText = translations.callAccepted;
case CallStatusConstants.ended:
callMessageText = translations.callEnded;
case CallStatusConstants.cancelled:
callMessageText = translations.callCancelled;
case CallStatusConstants.unanswered:
callMessageText = translations.callUnanswered;
case CallStatusConstants.rejected:
callMessageText = translations.callRejected;
case CallStatusConstants.busy:
callMessageText = translations.callBusy;
default:
callMessageText = video
? translations.videoCall
: translations.voiceCall;
}
return " $callMessageText";
}