showInfoTranslate method
Implementation
String showInfoTranslate(BuildContext context, {bool needShowName = false}) {
String? title;
if (needShowName) {
if (chatType == ChatType.GroupChat) {
String? showName =
ChatUIKitProvider.instance.getProfileById(from!)?.contactShowName;
if (nickname?.isNotEmpty == true) {
showName ??= nickname;
}
title = "${showName ?? from ?? ""}: ";
}
}
String? str;
switch (body.type) {
case MessageType.TXT:
str = (body as TextMessageBody).content;
break;
case MessageType.IMAGE:
str =
'${[ChatUIKitLocal.messageCellCombineImage.localString(context)]}';
break;
case MessageType.VIDEO:
str =
'${[ChatUIKitLocal.messageCellCombineVideo.localString(context)]}';
break;
case MessageType.VOICE:
str =
'${[ChatUIKitLocal.messageCellCombineVoice.localString(context)]}';
break;
case MessageType.LOCATION:
str = '${[
ChatUIKitLocal.messageCellCombineLocation.localString(context)
]}';
break;
case MessageType.COMBINE:
str = '${[
ChatUIKitLocal.messageCellCombineCombine.localString(context)
]}';
break;
case MessageType.FILE:
str = '${[ChatUIKitLocal.messageCellCombineFile.localString(context)]}';
break;
case MessageType.CUSTOM:
if (isCardMessage) {
str = '${[
ChatUIKitLocal.messageCellCombineContact.localString(context)
]}';
} else {
Map<String, String>? map = (body as CustomMessageBody).params;
String? operator = map?[alertOperatorIdKey];
String? showName;
if (ChatUIKit.instance.currentUserId == operator) {
showName = ChatUIKitLocal.alertYou.localString(context);
} else {
if (operator?.isNotEmpty == true) {
ChatUIKitProfile profile = ChatUIKitProvider.instance.getProfile(
ChatUIKitProfile.contact(id: operator!),
);
showName = profile.contactShowName;
}
showName ??= '';
}
if (isRecallAlert) {
return '$showName${ChatUIKitLocal.alertRecallInfo.localString(context)}';
}
if (isCreateGroupAlert) {
return '$showName${ChatUIKitLocal.messagesViewAlertGroupInfoTitle.localString(context)}';
}
if (isCreateThreadAlert) {
return '$showName${ChatUIKitLocal.messagesViewAlertThreadInfoTitle.localString(context)}';
}
if (isDestroyGroupAlert) {
return ChatUIKitLocal.alertDestroy.localString(context);
}
if (isLeaveGroupAlert) {
return '$showName${ChatUIKitLocal.alertLeave.localString(context)}';
}
if (isKickedGroupAlert) {
return '$showName${ChatUIKitLocal.alertKickedInfo.localString(context)}';
}
if (isNewContactAlert) {
return '${ChatUIKitLocal.alertYou.localString(context)}${ChatUIKitLocal.alertAlreadyAdd.localString(context)}$showName${ChatUIKitLocal.alertAsContact.localString(context)}';
}
if (isPinAlert) {
return '$showName${ChatUIKitLocal.alertPinTitle.localString(context)}';
}
if (isUnPinAlert) {
return '$showName${ChatUIKitLocal.alertUnpinTitle.localString(context)}';
}
str = '[Custom]';
}
break;
default:
}
if (title?.isNotEmpty == true) {
str = '$title$str';
}
return str ?? '';
}