style: format code with line length 120
This commit is contained in:
parent
0d58276ff6
commit
5ccb5adb79
|
|
@ -0,0 +1,26 @@
|
|||
# 这是一个顶级配置文件,停止向父目录查找
|
||||
root = true
|
||||
|
||||
# === 全局通用设置 (所有文件) ===
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# === Dart 文件专用设置 ===
|
||||
[*.dart]
|
||||
# SDK 原始代码使用较长的行宽,设置为 120 以保持一致
|
||||
max_line_length = 120
|
||||
indent_size = 2
|
||||
|
||||
# === YAML/JSON 文件 (配置文件) ===
|
||||
[*.{yaml,yml,json}]
|
||||
indent_size = 2
|
||||
|
||||
# === Markdown 文件 (文档) ===
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
max_line_length = 0
|
||||
|
|
@ -24,17 +24,12 @@ import 'package:tencent_cloud_chat_uikit/data_services/message/message_services.
|
|||
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
||||
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
||||
|
||||
enum KeywordListMatchType {
|
||||
V2TIM_KEYWORD_LIST_MATCH_TYPE_OR,
|
||||
V2TIM_KEYWORD_LIST_MATCH_TYPE_AND
|
||||
}
|
||||
enum KeywordListMatchType { V2TIM_KEYWORD_LIST_MATCH_TYPE_OR, V2TIM_KEYWORD_LIST_MATCH_TYPE_AND }
|
||||
|
||||
class TUISearchViewModel extends ChangeNotifier {
|
||||
final FriendshipServices _friendshipServices =
|
||||
serviceLocator<FriendshipServices>();
|
||||
final FriendshipServices _friendshipServices = serviceLocator<FriendshipServices>();
|
||||
final MessageService _messageService = serviceLocator<MessageService>();
|
||||
final ConversationService _conversationService =
|
||||
serviceLocator<ConversationService>();
|
||||
final ConversationService _conversationService = serviceLocator<ConversationService>();
|
||||
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
||||
|
||||
List<V2TimFriendInfoResult>? friendList = [];
|
||||
|
|
@ -51,8 +46,7 @@ class TUISearchViewModel extends ChangeNotifier {
|
|||
List<V2TimConversation?> conversationList = [];
|
||||
|
||||
Future<List<V2TimConversation?>?> initConversationMsg() async {
|
||||
final conversationResult = await _conversationService.getConversationList(
|
||||
nextSeq: "0", count: 500);
|
||||
final conversationResult = await _conversationService.getConversationList(nextSeq: "0", count: 500);
|
||||
final conversationListData = conversationResult?.conversationList;
|
||||
conversationList = conversationListData ?? [];
|
||||
notifyListeners();
|
||||
|
|
@ -74,8 +68,8 @@ class TUISearchViewModel extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
final searchResult = await _friendshipServices.searchFriends(
|
||||
searchParam: V2TimFriendSearchParam(keywordList: [searchKey]));
|
||||
final searchResult =
|
||||
await _friendshipServices.searchFriends(searchParam: V2TimFriendSearchParam(keywordList: [searchKey]));
|
||||
friendList = searchResult;
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
@ -87,14 +81,13 @@ class TUISearchViewModel extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
final searchResult = await _groupServices.searchGroups(
|
||||
searchParam: V2TimGroupSearchParam(keywordList: [searchKey]));
|
||||
final searchResult =
|
||||
await _groupServices.searchGroups(searchParam: V2TimGroupSearchParam(keywordList: [searchKey]));
|
||||
groupList = searchResult.data ?? [];
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void getMsgForConversation(
|
||||
String keyword, String conversationId, int page) async {
|
||||
void getMsgForConversation(String keyword, String conversationId, int page) async {
|
||||
void clearData() {
|
||||
currentMsgListForConversation = [];
|
||||
totalMsgInConversationCount = 0;
|
||||
|
|
@ -118,9 +111,8 @@ class TUISearchViewModel extends ChangeNotifier {
|
|||
type: KeywordListMatchType.V2TIM_KEYWORD_LIST_MATCH_TYPE_OR.index,
|
||||
));
|
||||
if (searchResult.code == 0 && searchResult.data != null) {
|
||||
final messageSearchResultItems =
|
||||
searchResult.data!.messageSearchResultItems!.firstWhereOrNull(
|
||||
(element) => element.conversationID == conversationId);
|
||||
final messageSearchResultItems = searchResult.data!.messageSearchResultItems!
|
||||
.firstWhereOrNull((element) => element.conversationID == conversationId);
|
||||
totalMsgInConversationCount = messageSearchResultItems?.messageCount ?? 0;
|
||||
currentMsgListForConversation = [
|
||||
...currentMsgListForConversation,
|
||||
|
|
|
|||
|
|
@ -150,8 +150,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
double inputWidth = 900;
|
||||
Map<String, V2TimGroupMemberFullInfo> mentionedMembersMap = {};
|
||||
late TextEditingController textEditingController;
|
||||
final TUIConversationViewModel conversationModel =
|
||||
serviceLocator<TUIConversationViewModel>();
|
||||
final TUIConversationViewModel conversationModel = serviceLocator<TUIConversationViewModel>();
|
||||
final TUISelfInfoViewModel selfModel = serviceLocator<TUISelfInfoViewModel>();
|
||||
MuteStatus muteStatus = MuteStatus.none;
|
||||
bool _isComposingText = false;
|
||||
|
|
@ -163,11 +162,9 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
// Keep using original scheme.
|
||||
return;
|
||||
}
|
||||
final stickerConfig =
|
||||
widget.model.chatConfig.stickerPanelConfig ?? StickerPanelConfig();
|
||||
final stickerConfig = widget.model.chatConfig.stickerPanelConfig ?? StickerPanelConfig();
|
||||
if (stickerConfig.useTencentCloudChatStickerPackage) {
|
||||
final tccEmojiSet = TUIKitStickerConstData.emojiList
|
||||
.firstWhere((element) => element.name == "tcc1");
|
||||
final tccEmojiSet = TUIKitStickerConstData.emojiList.firstWhere((element) => element.name == "tcc1");
|
||||
stickerPackageList.add(CustomStickerPackage(
|
||||
name: tccEmojiSet.name,
|
||||
baseUrl: "assets/custom_face_resource/${tccEmojiSet.name}",
|
||||
|
|
@ -176,8 +173,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
stickerList: tccEmojiSet.list
|
||||
.asMap()
|
||||
.keys
|
||||
.map((idx) =>
|
||||
CustomSticker(index: idx, name: tccEmojiSet.list[idx]))
|
||||
.map((idx) => CustomSticker(index: idx, name: tccEmojiSet.list[idx]))
|
||||
.toList(),
|
||||
menuItem: CustomSticker(
|
||||
index: 0,
|
||||
|
|
@ -186,19 +182,14 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
}
|
||||
|
||||
if (stickerConfig.useQQStickerPackage) {
|
||||
final qqEmojiSet = TUIKitStickerConstData.emojiList
|
||||
.firstWhere((element) => element.name == "4349");
|
||||
final qqEmojiSet = TUIKitStickerConstData.emojiList.firstWhere((element) => element.name == "4349");
|
||||
stickerPackageList.add(CustomStickerPackage(
|
||||
name: qqEmojiSet.name,
|
||||
baseUrl: "assets/custom_face_resource/${qqEmojiSet.name}",
|
||||
isEmoji: qqEmojiSet.isEmoji,
|
||||
isDefaultEmoji: true,
|
||||
stickerList: qqEmojiSet.list
|
||||
.asMap()
|
||||
.keys
|
||||
.map((idx) =>
|
||||
CustomSticker(index: idx, name: qqEmojiSet.list[idx]))
|
||||
.toList(),
|
||||
stickerList:
|
||||
qqEmojiSet.list.asMap().keys.map((idx) => CustomSticker(index: idx, name: qqEmojiSet.list[idx])).toList(),
|
||||
menuItem: CustomSticker(
|
||||
index: 0,
|
||||
name: qqEmojiSet.icon,
|
||||
|
|
@ -206,15 +197,11 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
}
|
||||
|
||||
if (stickerConfig.unicodeEmojiList.isNotEmpty) {
|
||||
final defEmojiList =
|
||||
TUIKitStickerConstData.defaultUnicodeEmojiList.map((emojiItem) {
|
||||
return CustomSticker(
|
||||
index: 0, name: emojiItem.toString(), unicode: emojiItem);
|
||||
final defEmojiList = TUIKitStickerConstData.defaultUnicodeEmojiList.map((emojiItem) {
|
||||
return CustomSticker(index: 0, name: emojiItem.toString(), unicode: emojiItem);
|
||||
}).toList();
|
||||
stickerPackageList.add(CustomStickerPackage(
|
||||
name: "defaultEmoji",
|
||||
stickerList: defEmojiList,
|
||||
menuItem: defEmojiList[0]));
|
||||
stickerPackageList
|
||||
.add(CustomStickerPackage(name: "defaultEmoji", stickerList: defEmojiList, menuItem: defEmojiList[0]));
|
||||
}
|
||||
|
||||
stickerPackageList.addAll(stickerConfig.customStickerPackages);
|
||||
|
|
@ -244,8 +231,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
if (cursorPosition > 0) {
|
||||
final EmojiUtil emojiUtil = EmojiUtil();
|
||||
int removeLength = 1;
|
||||
int openBracketIndex =
|
||||
originalText.lastIndexOf('[', cursorPosition - 1);
|
||||
int openBracketIndex = originalText.lastIndexOf('[', cursorPosition - 1);
|
||||
|
||||
if (openBracketIndex != -1 && originalText[cursorPosition - 1] == ']') {
|
||||
// Small png emoji
|
||||
|
|
@ -254,23 +240,19 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
if (emojiUtil.emojiMap.containsKey(key)) {
|
||||
removeLength = cursorPosition - openBracketIndex;
|
||||
}
|
||||
} else if (cursorPosition > 1 &&
|
||||
isEmoji(
|
||||
originalText.substring(cursorPosition - 2, cursorPosition))) {
|
||||
} else if (cursorPosition > 1 && isEmoji(originalText.substring(cursorPosition - 2, cursorPosition))) {
|
||||
removeLength = 2;
|
||||
}
|
||||
|
||||
text = originalText.substring(0, cursorPosition - removeLength) +
|
||||
originalText.substring(cursorPosition);
|
||||
text = originalText.substring(0, cursorPosition - removeLength) + originalText.substring(cursorPosition);
|
||||
currentCursor = (currentCursor ?? removeLength) - removeLength;
|
||||
}
|
||||
|
||||
textEditingController.text = text;
|
||||
|
||||
if (TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop) {
|
||||
textEditingController.selection = TextSelection.fromPosition(
|
||||
TextPosition(
|
||||
offset: currentCursor ?? textEditingController.text.length));
|
||||
textEditingController.selection =
|
||||
TextSelection.fromPosition(TextPosition(offset: currentCursor ?? textEditingController.text.length));
|
||||
focusNode.requestFocus();
|
||||
}
|
||||
}
|
||||
|
|
@ -290,9 +272,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
|
||||
void _addStickerToText(String sticker) {
|
||||
final currentText = textEditingController.text;
|
||||
if (currentCursor != null &&
|
||||
currentCursor! > -1 &&
|
||||
currentCursor! < currentText.length + 1) {
|
||||
if (currentCursor != null && currentCursor! > -1 && currentCursor! < currentText.length + 1) {
|
||||
final firstString = currentText.substring(0, currentCursor);
|
||||
final secondString = currentText.substring(currentCursor!);
|
||||
currentCursor = currentCursor! + sticker.length;
|
||||
|
|
@ -303,8 +283,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
}
|
||||
|
||||
if (TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop) {
|
||||
textEditingController.selection = TextSelection.fromPosition(TextPosition(
|
||||
offset: currentCursor ?? textEditingController.text.length));
|
||||
textEditingController.selection =
|
||||
TextSelection.fromPosition(TextPosition(offset: currentCursor ?? textEditingController.text.length));
|
||||
focusNode.requestFocus();
|
||||
}
|
||||
}
|
||||
|
|
@ -313,8 +293,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
return text.replaceAll(RegExp(r'\ufeff'), "");
|
||||
}
|
||||
|
||||
Future handleSetDraftText(
|
||||
{String? id, ConvType? convType, String? groupID}) async {
|
||||
Future handleSetDraftText({String? id, ConvType? convType, String? groupID}) async {
|
||||
String text = textEditingController.text;
|
||||
String convID = id ?? widget.conversationID;
|
||||
final isTopic = convID.contains("@TOPIC#");
|
||||
|
|
@ -388,19 +367,11 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
|
||||
if (widget.model.repliedMessage != null) {
|
||||
MessageUtils.handleMessageError(
|
||||
widget.model.sendFaceMessage(
|
||||
index: groupID,
|
||||
data: data,
|
||||
convID: widget.conversationID,
|
||||
convType: convType),
|
||||
widget.model.sendFaceMessage(index: groupID, data: data, convID: widget.conversationID, convType: convType),
|
||||
context);
|
||||
} else {
|
||||
MessageUtils.handleMessageError(
|
||||
widget.model.sendFaceMessage(
|
||||
index: groupID,
|
||||
data: data,
|
||||
convID: widget.conversationID,
|
||||
convType: convType),
|
||||
widget.model.sendFaceMessage(index: groupID, data: data, convID: widget.conversationID, convType: convType),
|
||||
context);
|
||||
}
|
||||
}
|
||||
|
|
@ -436,9 +407,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
atUserList: getUserIdFromMemberInfoMap());
|
||||
} else {
|
||||
MessageUtils.handleMessageError(
|
||||
widget.model.sendTextMessage(
|
||||
text: text, convID: widget.conversationID, convType: convType),
|
||||
context);
|
||||
widget.model.sendTextMessage(text: text, convID: widget.conversationID, convType: convType), context);
|
||||
}
|
||||
textEditingController.clear();
|
||||
currentCursor = null;
|
||||
|
|
@ -451,8 +420,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
}
|
||||
|
||||
void goDownBottom() {
|
||||
if (globalModel.getMessageListPosition(widget.conversationID) ==
|
||||
HistoryMessagePosition.notShowLatest) {
|
||||
if (globalModel.getMessageListPosition(widget.conversationID) == HistoryMessagePosition.notShowLatest) {
|
||||
return;
|
||||
}
|
||||
Future.delayed(const Duration(milliseconds: 50), () {
|
||||
|
|
@ -491,8 +459,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
if (TencentUtils.checkString(userID) == null) {
|
||||
focusNode.requestFocus();
|
||||
} else {
|
||||
final memberInfo = widget.model.groupMemberList
|
||||
?.firstWhereOrNull((element) => element?.userID == userID) ??
|
||||
final memberInfo = widget.model.groupMemberList?.firstWhereOrNull((element) => element?.userID == userID) ??
|
||||
V2TimGroupMemberFullInfo(
|
||||
userID: userID ?? "",
|
||||
nickName: nickName,
|
||||
|
|
@ -503,8 +470,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
//please do not delete space
|
||||
focusNode.requestFocus();
|
||||
textEditingController.text = text;
|
||||
textEditingController.selection =
|
||||
TextSelection.fromPosition(TextPosition(offset: text.length));
|
||||
textEditingController.selection = TextSelection.fromPosition(TextPosition(offset: text.length));
|
||||
lastText = text;
|
||||
_isComposingText = false;
|
||||
narrowTextFieldKey.currentState?.showKeyboard = true;
|
||||
|
|
@ -532,16 +498,10 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
maxLines: null,
|
||||
);
|
||||
textPainter.layout(maxWidth: inputWidth);
|
||||
final TextPosition lastLineOffset = textPainter
|
||||
.getPositionForOffset(Offset(textPainter.width, textPainter.height));
|
||||
final Offset caretPosition =
|
||||
textPainter.getOffsetForCaret(lastLineOffset, Rect.zero);
|
||||
final TextPosition lastLineOffset = textPainter.getPositionForOffset(Offset(textPainter.width, textPainter.height));
|
||||
final Offset caretPosition = textPainter.getOffsetForCaret(lastLineOffset, Rect.zero);
|
||||
final dx = min(inputWidth - 180, caretPosition.dx + 16);
|
||||
final dy = max(
|
||||
24,
|
||||
21 * widget.model.chatConfig.desktopMessageInputFieldLines -
|
||||
caretPosition.dy)
|
||||
.toDouble();
|
||||
final dy = max(24, 21 * widget.model.chatConfig.desktopMessageInputFieldLines - caretPosition.dy).toDouble();
|
||||
|
||||
return Offset(dx, dy);
|
||||
}
|
||||
|
|
@ -578,19 +538,13 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
mentionedMembersMap = map;
|
||||
}
|
||||
|
||||
(int, String, bool)? findChangedCharacter(
|
||||
String originalString, String newString) {
|
||||
(int, String, bool)? findChangedCharacter(String originalString, String newString) {
|
||||
if (newString.length < originalString.length) {
|
||||
final originalStringLength = originalString.length;
|
||||
final newStringLength = newString.length;
|
||||
for (int i = 0; i < newString.length; ++i) {
|
||||
if (originalString[originalStringLength - i - 1] !=
|
||||
newString[newStringLength - i - 1]) {
|
||||
return (
|
||||
newStringLength - i,
|
||||
originalString[originalStringLength - i - 1],
|
||||
false
|
||||
);
|
||||
if (originalString[originalStringLength - i - 1] != newString[newStringLength - i - 1]) {
|
||||
return (newStringLength - i, originalString[originalStringLength - i - 1], false);
|
||||
}
|
||||
}
|
||||
return (newString.length, originalString[newString.length], false);
|
||||
|
|
@ -609,11 +563,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
_handleAtText(String text, TUIChatSeparateViewModel model) async {
|
||||
final text = textEditingController.text;
|
||||
final String originalText = lastText;
|
||||
String? groupID = widget.conversationType == ConvType.group
|
||||
? widget.conversationID
|
||||
: null;
|
||||
final isDesktopScreen =
|
||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||
String? groupID = widget.conversationType == ConvType.group ? widget.conversationID : null;
|
||||
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||
|
||||
if (groupID == null) {
|
||||
lastText = text;
|
||||
|
|
@ -633,11 +584,9 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
String atTag = originalText.substring(atIndex, spaceIndex);
|
||||
String deletedChar = originalText[diffIndex];
|
||||
if (shouldRemoveAtTag(atTag, deletedChar)) {
|
||||
final newText = originalText.substring(0, atIndex) +
|
||||
originalText.substring(spaceIndex + 1);
|
||||
final newText = originalText.substring(0, atIndex) + originalText.substring(spaceIndex + 1);
|
||||
textEditingController.text = newText;
|
||||
textEditingController.selection =
|
||||
TextSelection.collapsed(offset: atIndex);
|
||||
textEditingController.selection = TextSelection.collapsed(offset: atIndex);
|
||||
lastText = newText;
|
||||
updateMentionedMap();
|
||||
return;
|
||||
|
|
@ -653,8 +602,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER);
|
||||
|
||||
if (isDesktopScreen) {
|
||||
(int, String, bool)? changedCharacterRecord =
|
||||
findChangedCharacter(originalText, text);
|
||||
(int, String, bool)? changedCharacterRecord = findChangedCharacter(originalText, text);
|
||||
int? changedTextPosition = changedCharacterRecord?.$1;
|
||||
String? changedCharacter = changedCharacterRecord?.$2;
|
||||
bool isAdded = changedCharacterRecord?.$3 ?? false;
|
||||
|
|
@ -663,13 +611,10 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
int? atPlace;
|
||||
|
||||
if (changedTextPosition != null) {
|
||||
subText = isAdded == true
|
||||
? text.substring(0, changedTextPosition + 1)
|
||||
: text.substring(0, changedTextPosition);
|
||||
subText = isAdded == true ? text.substring(0, changedTextPosition + 1) : text.substring(0, changedTextPosition);
|
||||
atPlace = subText.lastIndexOf('@');
|
||||
if (atPlace != -1) {
|
||||
keyword = text.substring(
|
||||
atPlace + 1, changedTextPosition + (isAdded ? 1 : 0));
|
||||
keyword = text.substring(atPlace + 1, changedTextPosition + (isAdded ? 1 : 0));
|
||||
}
|
||||
} else {
|
||||
atPlace = -1;
|
||||
|
|
@ -682,12 +627,9 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
model.atPositionY = atPosition.dy;
|
||||
isAddingAtSearchWords = true;
|
||||
}
|
||||
List<V2TimGroupMemberFullInfo> showAtMemberList = (model
|
||||
.groupMemberList ??
|
||||
[])
|
||||
List<V2TimGroupMemberFullInfo> showAtMemberList = (model.groupMemberList ?? [])
|
||||
.where((element) {
|
||||
final showName = (TencentUtils.checkStringWithoutSpace(
|
||||
element?.friendRemark) ??
|
||||
final showName = (TencentUtils.checkStringWithoutSpace(element?.friendRemark) ??
|
||||
TencentUtils.checkStringWithoutSpace(element?.nameCard) ??
|
||||
TencentUtils.checkStringWithoutSpace(element?.nickName) ??
|
||||
TencentUtils.checkStringWithoutSpace(element?.userID) ??
|
||||
|
|
@ -702,8 +644,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
.whereType<V2TimGroupMemberFullInfo>()
|
||||
.toList();
|
||||
|
||||
showAtMemberList.sort(
|
||||
(V2TimGroupMemberFullInfo userA, V2TimGroupMemberFullInfo userB) {
|
||||
showAtMemberList.sort((V2TimGroupMemberFullInfo userA, V2TimGroupMemberFullInfo userB) {
|
||||
final isUserAIsGroupAdmin = userA.role == 300;
|
||||
final isUserAIsGroupOwner = userA.role == 400;
|
||||
|
||||
|
|
@ -727,8 +668,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
keyword ??= "";
|
||||
if (canAtAll && showAtMemberList.isNotEmpty && keyword!.isEmpty) {
|
||||
showAtMemberList = [
|
||||
V2TimGroupMemberFullInfo(
|
||||
userID: "__kImSDK_MesssageAtALL__", nickName: TIM_t("所有人")),
|
||||
V2TimGroupMemberFullInfo(userID: "__kImSDK_MesssageAtALL__", nickName: TIM_t("所有人")),
|
||||
...showAtMemberList
|
||||
];
|
||||
}
|
||||
|
|
@ -742,12 +682,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
model.showAtMemberList = [];
|
||||
isAddingAtSearchWords = false;
|
||||
}
|
||||
} else if (textLength > 0 &&
|
||||
text[textLength - 1] == "@" &&
|
||||
lastText.length < textLength) {
|
||||
// 用户点击返回时 Navigator.push 可能返回 null
|
||||
List<V2TimGroupMemberFullInfo>? selectedAtMemberList =
|
||||
await Navigator.push(
|
||||
} else if (textLength > 0 && text[textLength - 1] == "@" && lastText.length < textLength) {
|
||||
List<V2TimGroupMemberFullInfo>? selectedAtMemberList = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AtText(
|
||||
|
|
@ -759,43 +695,35 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
),
|
||||
);
|
||||
|
||||
// 如果用户取消选择(点击返回),selectedAtMemberList 为 null
|
||||
if (selectedAtMemberList != null) {
|
||||
if (selectedAtMemberList == null) return;
|
||||
for (int i = 0; i < selectedAtMemberList.length; ++i) {
|
||||
V2TimGroupMemberFullInfo memberInfo = selectedAtMemberList[i];
|
||||
final showName = _getShowName(memberInfo);
|
||||
if (memberInfo != null) {
|
||||
mentionedMembersMap["@$showName"] = memberInfo;
|
||||
String addAtCharacter = i == 0 ? "" : "@";
|
||||
textEditingController.text =
|
||||
"${textEditingController.text}$addAtCharacter$showName ";
|
||||
textEditingController.text = "${textEditingController.text}$addAtCharacter$showName ";
|
||||
lastText = "${textEditingController.text}$addAtCharacter$showName ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastText = textEditingController.text;
|
||||
}
|
||||
|
||||
void replaceAtTag(String selectedMember) {
|
||||
int cursorPosition = textEditingController.selection.baseOffset;
|
||||
int atIndex =
|
||||
textEditingController.text.lastIndexOf('@', cursorPosition - 1);
|
||||
int atIndex = textEditingController.text.lastIndexOf('@', cursorPosition - 1);
|
||||
if (atIndex >= 0) {
|
||||
String beforeAt = textEditingController.text.substring(0, atIndex);
|
||||
String afterAt = textEditingController.text.substring(cursorPosition);
|
||||
textEditingController.text =
|
||||
beforeAt + '@' + selectedMember + ' ' + afterAt;
|
||||
textEditingController.selection =
|
||||
TextSelection.collapsed(offset: atIndex + selectedMember.length + 2);
|
||||
textEditingController.text = beforeAt + '@' + selectedMember + ' ' + afterAt;
|
||||
textEditingController.selection = TextSelection.collapsed(offset: atIndex + selectedMember.length + 2);
|
||||
lastText = beforeAt + '@' + selectedMember + ' ' + afterAt;
|
||||
}
|
||||
}
|
||||
|
||||
void handleAtMember(
|
||||
{V2TimGroupMemberFullInfo? memberInfo,
|
||||
bool? isAddToCursorPosition = false}) {
|
||||
void handleAtMember({V2TimGroupMemberFullInfo? memberInfo, bool? isAddToCursorPosition = false}) {
|
||||
if (memberInfo != null) {
|
||||
final String showName = _getShowName(memberInfo);
|
||||
mentionedMembersMap["@$showName"] = memberInfo;
|
||||
|
|
@ -809,24 +737,19 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
KeyEventResult handleDesktopKeyEvent(FocusNode node, RawKeyEvent event) {
|
||||
final activeIndex = widget.model.activeAtIndex;
|
||||
final showMemberList = widget.model.showAtMemberList;
|
||||
final isPressEnter = (event.physicalKey == PhysicalKeyboardKey.enter) ||
|
||||
(event.physicalKey == PhysicalKeyboardKey.numpadEnter);
|
||||
final isPressEnter =
|
||||
(event.physicalKey == PhysicalKeyboardKey.enter) || (event.physicalKey == PhysicalKeyboardKey.numpadEnter);
|
||||
if (event.runtimeType == RawKeyDownEvent) {
|
||||
if (event.physicalKey == PhysicalKeyboardKey.backspace) {
|
||||
if (textEditingController.text.isEmpty && lastText.isEmpty) {
|
||||
widget.model.repliedMessage = null;
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
} else if ((event.isShiftPressed ||
|
||||
event.isAltPressed ||
|
||||
event.isControlPressed ||
|
||||
event.isMetaPressed) &&
|
||||
} else if ((event.isShiftPressed || event.isAltPressed || event.isControlPressed || event.isMetaPressed) &&
|
||||
isPressEnter) {
|
||||
final offset = textEditingController.selection.baseOffset;
|
||||
textEditingController.text =
|
||||
'${lastText.substring(0, offset)}\n${lastText.substring(offset)}';
|
||||
textEditingController.selection =
|
||||
TextSelection.fromPosition(TextPosition(offset: offset + 1));
|
||||
textEditingController.text = '${lastText.substring(0, offset)}\n${lastText.substring(offset)}';
|
||||
textEditingController.selection = TextSelection.fromPosition(TextPosition(offset: offset + 1));
|
||||
lastText = textEditingController.text;
|
||||
|
||||
return KeyEventResult.handled;
|
||||
|
|
@ -836,34 +759,26 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
onSubmitted();
|
||||
} else {
|
||||
isAddingAtSearchWords = false;
|
||||
final V2TimGroupMemberFullInfo? memberInfo =
|
||||
showMemberList[activeIndex];
|
||||
final V2TimGroupMemberFullInfo? memberInfo = showMemberList[activeIndex];
|
||||
if (memberInfo != null) {
|
||||
handleAtMember(
|
||||
memberInfo: memberInfo, isAddToCursorPosition: true);
|
||||
handleAtMember(memberInfo: memberInfo, isAddToCursorPosition: true);
|
||||
}
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isKeyPressed(LogicalKeyboardKey.arrowUp) &&
|
||||
isAddingAtSearchWords &&
|
||||
showMemberList.isNotEmpty) {
|
||||
if (event.isKeyPressed(LogicalKeyboardKey.arrowUp) && isAddingAtSearchWords && showMemberList.isNotEmpty) {
|
||||
final newIndex = max(activeIndex - 1, 0);
|
||||
widget.model.activeAtIndex = newIndex;
|
||||
widget.atMemberPanelScroll?.scrollToIndex(newIndex,
|
||||
preferPosition: AutoScrollPosition.middle);
|
||||
widget.atMemberPanelScroll?.scrollToIndex(newIndex, preferPosition: AutoScrollPosition.middle);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
if (event.isKeyPressed(LogicalKeyboardKey.arrowDown) &&
|
||||
isAddingAtSearchWords &&
|
||||
showMemberList.isNotEmpty) {
|
||||
if (event.isKeyPressed(LogicalKeyboardKey.arrowDown) && isAddingAtSearchWords && showMemberList.isNotEmpty) {
|
||||
final newIndex = min(activeIndex + 1, showMemberList.length - 1);
|
||||
widget.model.activeAtIndex = newIndex;
|
||||
widget.atMemberPanelScroll?.scrollToIndex(newIndex,
|
||||
preferPosition: AutoScrollPosition.middle);
|
||||
widget.atMemberPanelScroll?.scrollToIndex(newIndex, preferPosition: AutoScrollPosition.middle);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
}
|
||||
|
|
@ -881,8 +796,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
} else {
|
||||
focusNode = FocusNode();
|
||||
}
|
||||
textEditingController =
|
||||
widget.controller?.textEditingController ?? TextEditingController();
|
||||
textEditingController = widget.controller?.textEditingController ?? TextEditingController();
|
||||
if (widget.initText != null) {
|
||||
textEditingController.text = widget.initText!;
|
||||
}
|
||||
|
|
@ -890,10 +804,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
widget.controller?.addListener(controllerHandler);
|
||||
}
|
||||
final AppLocale appLocale = I18nUtils.findDeviceLocale(null);
|
||||
languageType =
|
||||
(appLocale == AppLocale.zhHans || appLocale == AppLocale.zhHant)
|
||||
? 'zh'
|
||||
: 'en';
|
||||
languageType = (appLocale == AppLocale.zhHans || appLocale == AppLocale.zhHant) ? 'zh' : 'en';
|
||||
textEditingController.addListener(() {
|
||||
_isComposingText = textEditingController.value.composing.start != -1;
|
||||
});
|
||||
|
|
@ -903,13 +814,12 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
controllerHandler() {
|
||||
final actionType = widget.controller?.actionType;
|
||||
if (actionType == ActionType.longPressToAt) {
|
||||
mentionMemberInMessage(
|
||||
widget.controller?.atUserID, widget.controller?.atUserName);
|
||||
mentionMemberInMessage(widget.controller?.atUserID, widget.controller?.atUserName);
|
||||
} else if (actionType == ActionType.setTextField) {
|
||||
final newText = widget.controller?.inputText ?? "";
|
||||
textEditingController.text = newText;
|
||||
textEditingController.selection = TextSelection.fromPosition(
|
||||
TextPosition(offset: textEditingController.text.length));
|
||||
textEditingController.selection =
|
||||
TextSelection.fromPosition(TextPosition(offset: textEditingController.text.length));
|
||||
lastText = textEditingController.text;
|
||||
focusNode.requestFocus();
|
||||
return;
|
||||
|
|
@ -928,17 +838,14 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
if (widget.conversationID != oldWidget.conversationID) {
|
||||
mentionedMembersMap.clear();
|
||||
handleSetDraftText(
|
||||
id: oldWidget.conversationID,
|
||||
convType: oldWidget.conversationType,
|
||||
groupID: oldWidget.groupID);
|
||||
id: oldWidget.conversationID, convType: oldWidget.conversationType, groupID: oldWidget.groupID);
|
||||
if (oldWidget.initText != widget.initText) {
|
||||
textEditingController.text = widget.initText ?? "";
|
||||
} else {
|
||||
textEditingController.clear();
|
||||
}
|
||||
}
|
||||
if (widget.initText != oldWidget.initText &&
|
||||
TencentUtils.checkString(widget.initText) != null) {
|
||||
if (widget.initText != oldWidget.initText && TencentUtils.checkString(widget.initText) != null) {
|
||||
textEditingController.text = widget.initText!;
|
||||
focusNode.requestFocus();
|
||||
}
|
||||
|
|
@ -956,12 +863,9 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
|
||||
Future<bool> getMemberMuteStatus(String userID) async {
|
||||
// Get the mute state of the members recursively
|
||||
if (widget.model.groupMemberList?.any((item) => (item?.userID == userID)) ??
|
||||
false) {
|
||||
final int muteUntil = widget.model.groupMemberList
|
||||
?.firstWhere((item) => (item?.userID == userID))
|
||||
?.muteUntil ??
|
||||
0;
|
||||
if (widget.model.groupMemberList?.any((item) => (item?.userID == userID)) ?? false) {
|
||||
final int muteUntil =
|
||||
widget.model.groupMemberList?.firstWhere((item) => (item?.userID == userID))?.muteUntil ?? 0;
|
||||
return muteUntil * 1000 > DateTime.now().millisecondsSinceEpoch;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -974,13 +878,11 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
}
|
||||
|
||||
final int selfRole = widget.model.selfMemberInfo?.role ?? 0;
|
||||
final bool willNotBeenMuted =
|
||||
(selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN ||
|
||||
final bool willNotBeenMuted = (selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN ||
|
||||
selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER);
|
||||
|
||||
if (widget.conversationType == ConvType.group && !willNotBeenMuted) {
|
||||
if ((model.groupInfo?.isAllMuted ?? false) &&
|
||||
muteStatus != MuteStatus.all) {
|
||||
if ((model.groupInfo?.isAllMuted ?? false) && muteStatus != MuteStatus.all) {
|
||||
Future.delayed(const Duration(seconds: 0), () {
|
||||
setState(() {
|
||||
muteStatus = MuteStatus.all;
|
||||
|
|
@ -995,8 +897,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
});
|
||||
});
|
||||
} else if (!(model.groupInfo?.isAllMuted ?? false) &&
|
||||
!(selfModel.loginInfo?.userID != null &&
|
||||
await getMemberMuteStatus(selfModel.loginInfo!.userID!)) &&
|
||||
!(selfModel.loginInfo?.userID != null && await getMemberMuteStatus(selfModel.loginInfo!.userID!)) &&
|
||||
muteStatus != MuteStatus.none) {
|
||||
Future.delayed(const Duration(seconds: 0), () {
|
||||
setState(() {
|
||||
|
|
@ -1026,8 +927,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
@override
|
||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||
final theme = value.theme;
|
||||
final TUIChatSeparateViewModel model =
|
||||
Provider.of<TUIChatSeparateViewModel>(context);
|
||||
final TUIChatSeparateViewModel model = Provider.of<TUIChatSeparateViewModel>(context);
|
||||
|
||||
_getMuteType(model);
|
||||
|
||||
|
|
@ -1047,8 +947,7 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
|||
}
|
||||
|
||||
final forbiddenText = getForbiddenText();
|
||||
return LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||
inputWidth = constraints.maxWidth;
|
||||
return TUIKitScreenUtils.getDeviceWidget(
|
||||
context: context,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ class TUIKitColumnMenu extends StatefulWidget {
|
|||
}
|
||||
|
||||
class TUIKitColumnMenuState extends TIMUIKitState<TUIKitColumnMenu> {
|
||||
|
||||
List<Widget> renderMenuItems(TUITheme theme) {
|
||||
return widget.data
|
||||
.map(
|
||||
|
|
@ -39,7 +38,8 @@ class TUIKitColumnMenuState extends TIMUIKitState<TUIKitColumnMenu> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (item.icon != null) item.icon!,
|
||||
if (item.icon != null) const SizedBox(
|
||||
if (item.icon != null)
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
width: 6,
|
||||
),
|
||||
|
|
@ -73,18 +73,11 @@ class TUIKitColumnMenuState extends TIMUIKitState<TUIKitColumnMenu> {
|
|||
constraints: BoxConstraints(
|
||||
maxWidth: min(MediaQuery.of(context).size.width * 0.7, 350),
|
||||
),
|
||||
child: Table(
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
child: Table(columnWidths: const <int, TableColumnWidth>{
|
||||
0: IntrinsicColumnWidth(),
|
||||
},
|
||||
children: <TableRow>[
|
||||
...renderMenuItems(theme).map((e) => TableRow(
|
||||
children: <Widget>[
|
||||
e
|
||||
]
|
||||
))
|
||||
]
|
||||
),
|
||||
}, children: <TableRow>[
|
||||
...renderMenuItems(theme).map((e) => TableRow(children: <Widget>[e]))
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ import 'package:video_player/video_player.dart';
|
|||
import 'center_play_button.dart';
|
||||
|
||||
class VideoCustomControls extends StatefulWidget {
|
||||
const VideoCustomControls({required this.downloadFn, Key? key}) : super(key: key);
|
||||
const VideoCustomControls({required this.downloadFn, Key? key})
|
||||
: super(key: key);
|
||||
final Future<void> Function() downloadFn;
|
||||
|
||||
@override
|
||||
|
|
@ -25,7 +26,8 @@ class VideoCustomControls extends StatefulWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class _VideoCustomControlsState extends TIMUIKitState<VideoCustomControls> with SingleTickerProviderStateMixin {
|
||||
class _VideoCustomControlsState extends TIMUIKitState<VideoCustomControls>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late VideoPlayerValue _latestValue;
|
||||
bool _hideStuff = true;
|
||||
Timer? _hideTimer;
|
||||
|
|
@ -74,11 +76,18 @@ class _VideoCustomControlsState extends TIMUIKitState<VideoCustomControls> with
|
|||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: <Widget>[
|
||||
if (_latestValue.isBuffering) const Center(child: CircularProgressIndicator(color: Colors.white)) else _buildHitArea(),
|
||||
if (_latestValue.isBuffering)
|
||||
const Center(
|
||||
child: CircularProgressIndicator(color: Colors.white))
|
||||
else
|
||||
_buildHitArea(),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Column(children: [_buildVideoControlBar(context), _buildBottomBar()]),
|
||||
child: Column(children: [
|
||||
_buildVideoControlBar(context),
|
||||
_buildBottomBar()
|
||||
]),
|
||||
),
|
||||
if (isLoading)
|
||||
Container(
|
||||
|
|
@ -198,8 +207,14 @@ class _VideoCustomControlsState extends TIMUIKitState<VideoCustomControls> with
|
|||
child: Row(
|
||||
children: <Widget>[
|
||||
_buildPlayPause(controller, iconColor),
|
||||
if (chewieController.isLive) const Expanded(child: Text('LIVE')) else _buildPositionStart(iconColor),
|
||||
if (chewieController.isLive) const SizedBox() else _buildProgressBar(),
|
||||
if (chewieController.isLive)
|
||||
const Expanded(child: Text('LIVE'))
|
||||
else
|
||||
_buildPositionStart(iconColor),
|
||||
if (chewieController.isLive)
|
||||
const SizedBox()
|
||||
else
|
||||
_buildProgressBar(),
|
||||
if (!chewieController.isLive) _buildPositionEnd(iconColor),
|
||||
],
|
||||
),
|
||||
|
|
@ -235,7 +250,8 @@ class _VideoCustomControlsState extends TIMUIKitState<VideoCustomControls> with
|
|||
));
|
||||
}
|
||||
|
||||
GestureDetector _buildPlayPause(VideoPlayerController controller, Color color) {
|
||||
GestureDetector _buildPlayPause(
|
||||
VideoPlayerController controller, Color color) {
|
||||
return GestureDetector(
|
||||
onTap: _playPause,
|
||||
child: Container(
|
||||
|
|
@ -311,7 +327,8 @@ class _VideoCustomControlsState extends TIMUIKitState<VideoCustomControls> with
|
|||
_hideStuff = true;
|
||||
|
||||
chewieController.toggleFullScreen();
|
||||
_showAfterExpandCollapseTimer = Timer(const Duration(milliseconds: 300), () {
|
||||
_showAfterExpandCollapseTimer =
|
||||
Timer(const Duration(milliseconds: 300), () {
|
||||
setState(() {
|
||||
_cancelAndRestartTimer();
|
||||
});
|
||||
|
|
@ -379,7 +396,12 @@ class _VideoCustomControlsState extends TIMUIKitState<VideoCustomControls> with
|
|||
|
||||
_startHideTimer();
|
||||
},
|
||||
colors: chewieController.materialProgressColors ?? ChewieProgressColors(playedColor: Colors.white, handleColor: Colors.white, bufferedColor: Colors.white38, backgroundColor: Colors.white24),
|
||||
colors: chewieController.materialProgressColors ??
|
||||
ChewieProgressColors(
|
||||
playedColor: Colors.white,
|
||||
handleColor: Colors.white,
|
||||
bufferedColor: Colors.white38,
|
||||
backgroundColor: Colors.white24),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -402,7 +424,8 @@ class _PlaybackSpeedDialog extends TIMUIKitStatelessWidget {
|
|||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||
final TUITheme theme = value.theme;
|
||||
|
||||
final Color selectedColor = theme.primaryColor ?? Theme.of(context).primaryColor;
|
||||
final Color selectedColor =
|
||||
theme.primaryColor ?? Theme.of(context).primaryColor;
|
||||
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue