buildGroupTipsText static method
Implementation
static String buildGroupTipsText(V2TimGroupTipsElem? tips) {
String res = "";
if (tips != null) {
int type = tips.type;
List<V2TimGroupChangeInfo?> groupChangeInfoList = tips.groupChangeInfoList ?? [];
List<V2TimGroupMemberChangeInfo?> memberChangeInfoList = (tips.memberChangeInfoList ?? []);
List<V2TimGroupMemberInfo?> memberList = (tips.memberList ?? []);
V2TimGroupMemberInfo opMember = tips.opMember;
String membersDisplayText = memberList
.map((e) => TencentCloudChatUtils.getDisplayNameByV2TimGroupMemberInfo(
TencentCloudChatUtils.v2TimGroupMemberInfo2V2TimGroupMemberFullInfo(e)))
.join(",");
String opMemberDisplayText = TencentCloudChatUtils.getDisplayNameByV2TimGroupMemberInfo(
TencentCloudChatUtils.v2TimGroupMemberInfo2V2TimGroupMemberFullInfo(opMember));
switch (type) {
case 0:
res = tL10n.unknownGroupTips;
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_JOIN:
res = tL10n.memberJoinedGroup(membersDisplayText);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_INVITE:
res = tL10n.opInvitedToGroup(membersDisplayText, opMemberDisplayText);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_QUIT:
res = tL10n.memberLeftGroup(membersDisplayText);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_KICKED:
res = tL10n.opRemovedFromGroup(membersDisplayText, opMemberDisplayText);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_SET_ADMIN:
res = tL10n.opPromotedToAdmin(membersDisplayText, opMemberDisplayText);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_CANCEL_ADMIN:
res = tL10n.opRevokedAdmin(membersDisplayText, opMemberDisplayText);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_GROUP_INFO_CHANGE:
res = opMemberDisplayText + groupChangeInfoList.map((e) => buildGroupChangeInfoText(e)).join(",");
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_MEMBER_INFO_CHANGE:
if (memberChangeInfoList.isNotEmpty) {
V2TimGroupMemberChangeInfo? memberChangeInfo = memberChangeInfoList[0];
int muteTime = memberChangeInfo?.muteTime ?? 0;
if (muteTime > 0) {
res = tL10n.banned(membersDisplayText, TencentCloudChatIntl.formatSeconds(muteTime));
} else {
res = tL10n.cancelBanned(membersDisplayText);
}
}
break;
case 9:
res = "topic info change";
break;
case 10:
res = "group info change";
break;
case 11:
res = "pinned message";
break;
default:
res = "unpinned message";
break;
}
}
return res;
}