update flutter uikit to 1.5.0

This commit is contained in:
anonymous 2023-02-02 15:15:25 +08:00
parent 121e8c295f
commit 78bea5cef9
11 changed files with 1104 additions and 713 deletions

View File

@ -1,8 +1,15 @@
## 1.5.0
* Add: New configuration `defaultAvatarAssetPath` on global `TIMUIKitConfig`, aiming to define the default avatar.
* Add: Supports Flutter 3.7.0.
* Fix: `chatBgColor` configuration.
## 1.4.0
* Add: Text translation. Long press the text messages and choose `Translate`. This function can be turn off by `showTranslation` from `ToolTipsConfig`.
* Optimize: The long press pop-up location.
* Optimize: keyboard pop-up event.
* Optimize: Keyboard pop-up event.
## 1.3.2

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -49,8 +49,8 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
late V2TimAdvancedMsgListener advancedMsgListener;
int _unreadCountForConversation = 0;
// use for generate a new sliver list to show recived messag list
int _recivedNewMessageCount = 0;
// use for generate a new sliver list to show received message list
int _receivedNewMessageCount = 0;
TIMUIKitChatConfig chatConfig = const TIMUIKitChatConfig();
List<V2TimGroupApplication>? _groupApplicationList;
String Function(V2TimMessage message)? _abstractMessageBuilder;
@ -58,7 +58,7 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
Map.from({}); // 0 normal 1 sending
final Map<String, bool> _c2cMessageFromUserActiveMap = Map.from({});
final Map<String, Timer> _c2cMessageActiveTimer = Map.from({});
bool _showC2cMessageEditStaus = true;
bool _showC2cMessageEditStatus = true;
final Map<String, Timer> _c2cMessageStatusShowTimer = Map.from({});
Map<String, List> loadingMessage = {};
@ -73,8 +73,8 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
onRecvNewMessage: (V2TimMessage newMsg) {
_onReceiveNewMsg(newMsg);
},
onSendMessageProgress: (V2TimMessage messagae, int progress) {
_onSendMessageProgress(messagae, progress);
onSendMessageProgress: (V2TimMessage message, int progress) {
_onSendMessageProgress(message, progress);
},
onRecvMessageReadReceipts: (List<V2TimMessageReceipt> receiptList) {
_onReceiveMessageReadReceipts(receiptList);
@ -150,7 +150,7 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
// downloadFile();
}
int getRecevied(msgID) {
int getReceived(msgID) {
return messageListProgressMap[msgID] ?? 0;
}
@ -178,8 +178,8 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
return _totalUnreadCount;
}
int get recivedMessageListCount {
return _recivedNewMessageCount;
int get receivedMessageListCount {
return _receivedNewMessageCount;
}
int get unreadCountForConversation => _unreadCountForConversation;
@ -218,7 +218,7 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
}
setShowC2cEditStatus(bool show) {
_showC2cMessageEditStaus = show;
_showC2cMessageEditStatus = show;
}
/// set edit status from chats
@ -375,14 +375,14 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
_totalUnreadCount = 0;
_groupApplicationList?.clear();
_totalUnreadCount = 0;
_recivedNewMessageCount = 0;
_receivedNewMessageCount = 0;
_messageReadReceiptMap.clear();
_messageListProgressMap.clear();
notifyListeners();
}
clearRecivedNewMessageCount() {
_recivedNewMessageCount = 0;
_receivedNewMessageCount = 0;
}
_preLoadImage(List<V2TimMessage> msgList) {
@ -528,7 +528,7 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
}
sendEditStatusMessage(bool isEditing, String toUser) async {
if (!_showC2cMessageEditStaus) {
if (!_showC2cMessageEditStatus) {
return;
}
if (!(_c2cMessageFromUserActiveMap[toUser] ?? false)) {
@ -602,7 +602,7 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
convID: convID,
convType: currentSelectedConvType!,
);
_recivedNewMessageCount = 0;
_receivedNewMessageCount = 0;
final currentMsg = _messageListMap[convID] ?? [];
_messageListMap[convID] = [newMsg, ...currentMsg];
notifyListeners();
@ -618,7 +618,7 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
} else {
if (convID == currentSelectedConv) {
unreadCountForConversation++;
_recivedNewMessageCount++;
_receivedNewMessageCount++;
final currentMsg = _messageListMap[convID] ?? [];
_messageListMap[convID] = [newMsg, ...currentMsg];
notifyListeners();
@ -880,7 +880,7 @@ class TUIChatGlobalModel extends ChangeNotifier with TIMUIKitClass {
{bool needResetNewMessageCount = true}) {
_messageListMap[conversationID] = messageList;
if (needResetNewMessageCount) {
_recivedNewMessageCount = 0;
_receivedNewMessageCount = 0;
}
notifyListeners();
}

View File

@ -10,7 +10,11 @@ class TIMUIKitConfig {
/// type is `INFO`, while code is 6661403.
final bool isCheckDiskStorageSpace;
/// The asset path of the default avatar image.
final String? defaultAvatarAssetPath;
const TIMUIKitConfig({
this.defaultAvatarAssetPath,
this.isCheckDiskStorageSpace = true,
this.isShowOnlineStatus = true,
});

View File

@ -330,10 +330,10 @@ class _TIMUIKitHistoryMessageListState
final messageList = widget.messageList;
final globalModel = context.read<TUIChatGlobalModel>();
final recivedNewMessageList = globalModel.recivedMessageListCount;
final shouldShowUnreadMessage = recivedNewMessageList > 0;
final unreadMessageList = _getRecivedMessageList(recivedNewMessageList);
final readedMessageList = messageList
final receivedNewMessageList = globalModel.receivedMessageListCount;
final shouldShowUnreadMessage = receivedNewMessageList > 0;
final unreadMessageList = _getRecivedMessageList(receivedNewMessageList);
final readMessageList = messageList
.sublist(unreadMessageList.length, messageList.length)
.toList();
@ -350,144 +350,149 @@ class _TIMUIKitHistoryMessageListState
}
String getMessageIdentifier(V2TimMessage? message, int index) {
return "${message?.msgID} - ${message?.timestamp} - ${message?.seq} - ${message?.id}";
return "${message?.msgID} - ${message?.timestamp} - ${message?.seq}";
}
return Stack(
alignment: Alignment.topCenter,
children: [
CustomScrollView(
center: shouldShowUnreadMessage ? centerKey : null,
key: widget.mainHistoryListConfig?.key,
primary: widget.mainHistoryListConfig?.primary,
physics: (widget.isAllowScroll == false)
? const NeverScrollableScrollPhysics()
: widget.mainHistoryListConfig?.physics,
// padding: widget.mainHistoryListConfig?.padding ?? EdgeInsets.zero,
// itemExtent: widget.mainHistoryListConfig?.itemExtent,
// prototypeItem: widget.mainHistoryListConfig?.prototypeItem,
cacheExtent: widget.mainHistoryListConfig?.cacheExtent ?? 1500,
semanticChildCount: widget.mainHistoryListConfig?.semanticChildCount,
dragStartBehavior: widget.mainHistoryListConfig?.dragStartBehavior ??
DragStartBehavior.start,
keyboardDismissBehavior:
widget.mainHistoryListConfig?.keyboardDismissBehavior ??
ScrollViewKeyboardDismissBehavior.manual,
restorationId: widget.mainHistoryListConfig?.restorationId,
clipBehavior:
widget.mainHistoryListConfig?.clipBehavior ?? Clip.hardEdge,
reverse: true,
shrinkWrap: !shouldShowUnreadMessage,
controller: _autoScrollController,
slivers: [
SliverPadding(
padding: widget.mainHistoryListConfig?.padding ?? EdgeInsets.zero,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final messageItem = unreadMessageList[index];
return AutoScrollTag(
controller: _autoScrollController,
index: -index,
key: ValueKey(
getMessageIdentifier(messageItem, index)),
highlightColor: Colors.black.withOpacity(0.1),
child: KeepAliveWrapper(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16),
child: _getMessageItemBuilder(messageItem))),
);
},
childCount: unreadMessageList.length,
findChildIndexCallback: (Key key) {
final ValueKey<String> valueKey =
key as ValueKey<String>;
final String data = valueKey.value;
final int index = unreadMessageList.indexWhere(
(element) =>
getMessageIdentifier(element, 0) == data);
return index != -1 ? index : null;
})),
),
SliverPadding(
padding: EdgeInsets.zero,
key: centerKey,
),
SliverPadding(
padding: widget.mainHistoryListConfig?.padding ?? EdgeInsets.zero,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final messageItem = readedMessageList[index];
if (index == readedMessageList.length - 1) {
if (widget.model.haveMoreData) {
throteFunction(index);
return Column(
children: [
LoadingAnimationWidget.staggeredDotsWave(
color: theme.weakTextColor ?? Colors.grey,
size: 28,
),
AutoScrollTag(
controller: _autoScrollController,
index: -index,
key: ValueKey(
getMessageIdentifier(messageItem, index)),
highlightColor: Colors.black.withOpacity(0.1),
child: KeepAliveWrapper(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16),
child: _getMessageItemBuilder(
messageItem))),
),
],
);
return Container(
color: theme.chatBgColor,
child: Stack(
alignment: Alignment.topCenter,
children: [
CustomScrollView(
center: shouldShowUnreadMessage ? centerKey : null,
key: widget.mainHistoryListConfig?.key,
primary: widget.mainHistoryListConfig?.primary,
physics: (widget.isAllowScroll == false)
? const NeverScrollableScrollPhysics()
: widget.mainHistoryListConfig?.physics,
// padding: widget.mainHistoryListConfig?.padding ?? EdgeInsets.zero,
// itemExtent: widget.mainHistoryListConfig?.itemExtent,
// prototypeItem: widget.mainHistoryListConfig?.prototypeItem,
cacheExtent: widget.mainHistoryListConfig?.cacheExtent ?? 1500,
semanticChildCount: widget.mainHistoryListConfig?.semanticChildCount,
dragStartBehavior: widget.mainHistoryListConfig?.dragStartBehavior ??
DragStartBehavior.start,
keyboardDismissBehavior:
widget.mainHistoryListConfig?.keyboardDismissBehavior ??
ScrollViewKeyboardDismissBehavior.manual,
restorationId: widget.mainHistoryListConfig?.restorationId,
clipBehavior:
widget.mainHistoryListConfig?.clipBehavior ?? Clip.hardEdge,
reverse: true,
shrinkWrap: !shouldShowUnreadMessage,
controller: _autoScrollController,
slivers: [
SliverPadding(
padding: widget.mainHistoryListConfig?.padding ?? EdgeInsets.zero,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final messageItem = unreadMessageList[index];
return AutoScrollTag(
controller: _autoScrollController,
index: -index,
key: ValueKey(
getMessageIdentifier(messageItem, index)),
highlightColor: Colors.black.withOpacity(0.1),
child: KeepAliveWrapper(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16),
child: _getMessageItemBuilder(messageItem))),
);
},
childCount: unreadMessageList.length,
findChildIndexCallback: (Key key) {
final ValueKey<String> valueKey =
key as ValueKey<String>;
final String data = valueKey.value;
final int index = unreadMessageList.indexWhere(
(element) =>
getMessageIdentifier(element, 0) == data);
return index != -1 ? index : null;
})),
),
SliverPadding(
padding: EdgeInsets.zero,
key: centerKey,
),
SliverPadding(
padding: widget.mainHistoryListConfig?.padding ?? EdgeInsets.zero,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final messageItem = readMessageList[index];
if (index == readMessageList.length - 1) {
if (widget.model.haveMoreData) {
throteFunction(index);
return Column(
children: [
LoadingAnimationWidget.staggeredDotsWave(
color: theme.weakTextColor ?? Colors.grey,
size: 28,
),
AutoScrollTag(
controller: _autoScrollController,
index: -index,
key: ValueKey(
getMessageIdentifier(messageItem, index)),
highlightColor: Colors.black.withOpacity(0.1),
child: KeepAliveWrapper(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16),
child: _getMessageItemBuilder(
messageItem))),
),
],
);
}
}
return AutoScrollTag(
controller: _autoScrollController,
index: -index,
key: ValueKey(
getMessageIdentifier(messageItem, index)),
highlightColor: Colors.black.withOpacity(0.1),
child: KeepAliveWrapper(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16),
child: _getMessageItemBuilder(messageItem))),
);
},
childCount: readMessageList.length,
findChildIndexCallback: (Key key) {
final ValueKey<String> valueKey =
key as ValueKey<String>;
final String data = valueKey.value;
final int index = readMessageList.indexWhere(
(element) =>
getMessageIdentifier(element, 0) == data);
return index > -1 ? index : null;
}
return AutoScrollTag(
controller: _autoScrollController,
index: -index,
key: ValueKey(
getMessageIdentifier(messageItem, index)),
highlightColor: Colors.black.withOpacity(0.1),
child: KeepAliveWrapper(
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16),
child: _getMessageItemBuilder(messageItem))),
);
},
childCount: readedMessageList.length,
findChildIndexCallback: (Key key) {
final ValueKey<String> valueKey =
key as ValueKey<String>;
final String data = valueKey.value;
final int index = readedMessageList.indexWhere(
(element) =>
getMessageIdentifier(element, 0) == data);
return index != -1 ? index : null;
})),
),
],
),
TIMUIKitHistoryMessageListTongueContainer(
model: widget.model,
scrollController: _autoScrollController,
scrollToIndexBySeq: _onScrollToIndexBySeq,
groupAtInfoList: widget.groupAtInfoList,
tongueItemBuilder: widget.tongueItemBuilder,
),
if (loadingPlace == LoadingPlace.top)
Positioned(
top: 8,
child: LoadingAnimationWidget.staggeredDotsWave(
color: theme.weakTextColor ?? Colors.grey,
size: 28,
),
)
),
),
],
),
],
TIMUIKitHistoryMessageListTongueContainer(
model: widget.model,
scrollController: _autoScrollController,
scrollToIndexBySeq: _onScrollToIndexBySeq,
groupAtInfoList: widget.groupAtInfoList,
tongueItemBuilder: widget.tongueItemBuilder,
),
if (loadingPlace == LoadingPlace.top)
Positioned(
top: 8,
child: LoadingAnimationWidget.staggeredDotsWave(
color: theme.weakTextColor ?? Colors.grey,
size: 28,
),
),
],
),
);
}
}

View File

@ -71,7 +71,7 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
right: 10,
),
decoration: const BoxDecoration(
color: Color(0x198a8a8a),
color: Color(0x19727271),
borderRadius: BorderRadius.all(Radius.circular(20)),
),
child: Row(

View File

@ -50,15 +50,19 @@ class _TIMUIKitLastMsgState extends TIMUIKitState<TIMUIKitLastMsg> {
final option1 = isSelf
? TIM_t("")
: widget.lastMsg!.nickName ?? widget.lastMsg?.sender;
setState(() {
groupTipsAbstractText = TIM_t_para(
"{{option1}}撤回了一条消息", "$option1撤回了一条消息")(option1: option1);
});
if(mounted){
setState(() {
groupTipsAbstractText = TIM_t_para(
"{{option1}}撤回了一条消息", "$option1撤回了一条消息")(option1: option1);
});
}
} else {
final newText = await _getLastMsgShowText(widget.lastMsg, widget.context);
setState(() {
groupTipsAbstractText = newText;
});
if(mounted){
setState(() {
groupTipsAbstractText = newText;
});
}
}
}

View File

@ -1,5 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
import 'package:tencent_cloud_chat_uikit/ui/widgets/image_screen.dart';
import 'package:tencent_im_base/tencent_im_base.dart';
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
@ -16,6 +18,8 @@ class Avatar extends TIMUIKitStatelessWidget {
final V2TimUserStatus? onlineStatus;
final int? type; // 1 c2c 2 group
final bool isShowBigWhenClick;
final TUISelfInfoViewModel selfInfoViewModel =
serviceLocator<TUISelfInfoViewModel>();
Avatar(
{Key? key,
@ -31,11 +35,23 @@ class Avatar extends TIMUIKitStatelessWidget {
Widget getImageWidget(BuildContext context, TUITheme theme) {
Widget defaultAvatar() {
if (type == 1) {
return Image.asset('images/default_c2c_head.png',
package: 'tencent_cloud_chat_uikit');
return Image.asset(
TencentUtils.checkString(
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath) ??
'images/default_c2c_head.png',
package:
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath != null
? null
: 'tencent_cloud_chat_uikit');
} else {
return Image.asset('images/default_group_head.png',
package: 'tencent_cloud_chat_uikit');
return Image.asset(
TencentUtils.checkString(
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath) ??
'images/default_group_head.png',
package:
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath != null
? null
: 'tencent_cloud_chat_uikit');
}
}
@ -59,12 +75,26 @@ class Avatar extends TIMUIKitStatelessWidget {
ImageProvider getImageProvider() {
ImageProvider defaultAvatar() {
if (type == 1) {
return Image.asset('images/default_c2c_head.png',
package: 'tencent_cloud_chat_uikit')
return Image.asset(
TencentUtils.checkString(selfInfoViewModel
.globalConfig?.defaultAvatarAssetPath) ??
'images/default_c2c_head.png',
package:
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath !=
null
? null
: 'tencent_cloud_chat_uikit')
.image;
} else {
return Image.asset('images/default_group_head.png',
package: 'tencent_cloud_chat_uikit')
return Image.asset(
TencentUtils.checkString(selfInfoViewModel
.globalConfig?.defaultAvatarAssetPath) ??
'images/default_group_head.png',
package:
selfInfoViewModel.globalConfig?.defaultAvatarAssetPath !=
null
? null
: 'tencent_cloud_chat_uikit')
.image;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
name: tencent_cloud_chat_uikit
description: UI components library and basic chat business logic for Tencent Cloud Chat service, helping you build In-APP Chat module easily.
version: 1.4.0
description: Chat UI components library and basic chat business logic for Tencent Cloud Chat, helping you build In-APP Chat module easily.
version: 1.5.0
homepage: https://www.tencentcloud.com/products/im?from=pub
repository: https://github.com/TencentCloud/tc-chat-uikit-flutter
repository: https://github.com/TencentCloud/chat-uikit-flutter
documentation: https://comm.qq.com/im/doc/flutter/en/TUIKit/readme.html
# publish_to: none
platforms:
@ -62,7 +62,7 @@ dependencies:
url_launcher: ^6.1.4
universal_html: ^2.0.8
link_preview_generator: ^1.2.0
tencent_im_base: ^1.0.19
tencent_im_base: ^1.0.20
disk_space: ^0.2.1
http: ^0.13.5
crypto: ^3.0.2