groupTipsMessageAbstract static method
Future<String>
groupTipsMessageAbstract(
- V2TimGroupTipsElem groupTipsElem,
- List<
V2TimGroupMemberFullInfo?> groupMemberList
Implementation
static Future<String> groupTipsMessageAbstract(
V2TimGroupTipsElem groupTipsElem,
List<V2TimGroupMemberFullInfo?> groupMemberList) async {
String displayMessage;
final operationType = groupTipsElem.type;
final operationMember = groupTipsElem.opMember;
final memberList = groupTipsElem.memberList;
final opUserNickName = _getOpUserNick(operationMember);
switch (operationType) {
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_GROUP_INFO_CHANGE:
final String? option7 = opUserNickName ?? "";
final groupChangeInfoList = groupTipsElem.groupChangeInfoList ?? [];
String changedInfoString = "";
bool changedValue = false;
for (V2TimGroupChangeInfo? element in groupChangeInfoList) {
final newText = await _getGroupChangeType(element!, groupMemberList);
changedInfoString +=
(changedInfoString.isEmpty ? "" : " / ") + newText;
changedValue = element!.boolValue ?? false;
}
if (changedInfoString.isEmpty) {
changedInfoString = TIM_t("群资料");
}
if (changedInfoString == TIM_t("全员禁言状态")) {
changedInfoString = TIM_t("全员禁言");
displayMessage = changedValue == false ? TIM_t_para("{{option7}} 取消", "$option7 取消")(option7: option7) +
changedInfoString : TIM_t_para("{{option7}} 开启", "$option7 开启")(option7: option7) +
changedInfoString;
} else {
displayMessage =
TIM_t_para("{{option7}}修改", "$option7修改")(option7: option7) +
changedInfoString;
}
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_QUIT:
final String? option6 = opUserNickName ?? "";
displayMessage =
TIM_t_para("{{option6}}退出群聊", "$option6退出群聊")(option6: option6);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_INVITE:
final option5 =
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
final inviteUser = _getOpUserNick(operationMember);
displayMessage = '$inviteUser' +
TIM_t_para("邀请{{option5}}加入群组", "邀请$option5加入群组")(option5: option5);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_KICKED:
final option4 =
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
final kickUser = _getOpUserNick(operationMember);
displayMessage = '$kickUser' +
TIM_t_para("将{{option4}}踢出群组", "将$option4踢出群组")(option4: option4);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_JOIN:
final option3 =
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
displayMessage = TIM_t_para("用户{{option3}}加入了群聊", "用户$option3加入了群聊")(
option3: option3);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_MEMBER_INFO_CHANGE:
displayMessage = groupTipsElem.memberList!.map((e) {
final changedMember = groupTipsElem.memberChangeInfoList!
.firstWhere((element) => element!.userID == e!.userID);
final isMute = changedMember!.muteTime != 0;
final option2 = _getMemberNickName(e!);
final displayMessage = isMute ? TIM_t("禁言") : TIM_t("解除禁言");
return TIM_t_para("{{option2}} 被", "$option2 被")(option2: option2) +
displayMessage;
}).join("、");
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_SET_ADMIN:
final adminMember =
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
final opMember = _getOpUserNick(operationMember);
final option1 = adminMember;
displayMessage = '$opMember' +
TIM_t_para("将 {{option1}} 设置为管理员", "将 $option1 设置为管理员")(
option1: option1);
break;
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_CANCEL_ADMIN:
final adminMember =
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
final opMember = _getOpUserNick(operationMember);
final option1 = adminMember;
displayMessage = '$opMember' +
TIM_t_para("将 {{option1}} 取消管理员", "将 $option1 取消管理员")(
option1: option1);
break;
default:
final String option2 = operationType.toString();
displayMessage =
TIM_t_para("系统消息 {{option2}}", "系统消息 $option2")(option2: option2);
break;
}
return displayMessage;
}