renderCallRecord function
通话记录的文字:按结束原因和本人是否为发起方(消息的发送者)。
Implementation
String renderCallRecord(DRObject message, {required String self, DRLocale locale = zhCN}) {
final c = locale.call;
String t(String key) => c[key] ?? zhCN.call[key] ?? '';
final b = _body(message);
final media = b['media'] == 'video' ? t('video') : t('audio');
final caller = message.raw['sender'] == self;
String completed() => '$media ${formatTemplate(t('duration'), {'duration': _duration(asNum(b['duration_seconds']) ?? 0)})}';
if (b['call_type'] == 'group') return b['result'] == 'completed' ? completed() : t('group_ended');
return switch (b['result']) {
'completed' => completed(),
'canceled' => caller ? t('canceled_caller') : t('canceled_callee'),
'rejected' => caller ? t('rejected_caller') : t('rejected_callee'),
'busy' => caller ? t('busy_caller') : t('missed'),
'no_answer' => caller ? t('no_answer_caller') : t('missed'),
'connection_lost' => t('connection_lost'),
_ => t('ended'),
};
}