From c77c24e56292d53773aecd8b6a8669ac9d614e66 Mon Sep 17 00:00:00 2001 From: anonymous Date: Mon, 13 Feb 2023 12:37:04 +0800 Subject: [PATCH] update flutter uikit to 1.6.1 --- CHANGELOG.md | 4 + .../tui_group_profile_model.dart | 5 +- .../widgets/tim_uikit_group_manage.dart | 83 ++++++++++++------- pubspec.yaml | 2 +- 4 files changed, 60 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc53430..9158297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.6.1 + +* Fix: A bug of muting someone in a group. +* Fix: A bug on Flutter 3.7.0. ## 1.6.0 diff --git a/lib/business_logic/separate_models/tui_group_profile_model.dart b/lib/business_logic/separate_models/tui_group_profile_model.dart index 8613e1d..47c11de 100644 --- a/lib/business_logic/separate_models/tui_group_profile_model.dart +++ b/lib/business_logic/separate_models/tui_group_profile_model.dart @@ -325,8 +325,9 @@ class TUIGroupProfileModel extends ChangeNotifier { return null; } - Future muteGroupMember(String userID, bool isMute) async { - const muteTime = 31556926 * 10; + Future muteGroupMember( + String userID, bool isMute, int? serverTime) async { + final muteTime = serverTime != null ? serverTime + 9999 : 51556926 * 10; final res = await _groupServices.muteGroupMember( groupID: _groupID, userID: userID, seconds: isMute ? muteTime : 0); if (res.code == 0) { diff --git a/lib/ui/views/TIMUIKitGroupProfile/widgets/tim_uikit_group_manage.dart b/lib/ui/views/TIMUIKitGroupProfile/widgets/tim_uikit_group_manage.dart index 64588eb..dc9919a 100644 --- a/lib/ui/views/TIMUIKitGroupProfile/widgets/tim_uikit_group_manage.dart +++ b/lib/ui/views/TIMUIKitGroupProfile/widgets/tim_uikit_group_manage.dart @@ -70,9 +70,19 @@ class GroupProfileGroupManagePage extends StatefulWidget { class _GroupProfileGroupManagePageState extends TIMUIKitState { + int? serverTime; + @override void initState() { super.initState(); + getServerTime(); + } + + void getServerTime() async { + final res = await TencentImSDKPlugin.v2TIMManager.getServerTime(); + setState(() { + serverTime = res.data; + }); } @override @@ -228,7 +238,10 @@ class _GroupProfileGroupManagePageState builder: (context) => GroupProfileAddAdmin( appbarTitle: TIM_t("设置禁言"), memberList: memberList.where((element) { - final isMute = element?.muteUntil != 0; + final isMute = (serverTime != null + ? (element?.muteUntil ?? 0) > + serverTime! + : false); final isMember = element!.role == GroupMemberRoleType .V2TIM_GROUP_MEMBER_ROLE_MEMBER; @@ -240,7 +253,7 @@ class _GroupProfileGroupManagePageState for (var member in selectedMember) { final userID = member!.userID; widget.model - .muteGroupMember(userID, true); + .muteGroupMember(userID, true, serverTime); } } }, @@ -249,14 +262,16 @@ class _GroupProfileGroupManagePageState ), if (!isAllMuted) ...memberList - .where((element) => element?.muteUntil != 0) + .where((element) => (serverTime != null + ? (element?.muteUntil ?? 0) > serverTime! + : false)) .map((e) => _buildListItem( context, e!, ActionPane(motion: const DrawerMotion(), children: [ SlidableAction( onPressed: (_) { - widget.model.muteGroupMember(e.userID, false); + widget.model.muteGroupMember(e.userID, false, serverTime); }, flex: 1, backgroundColor: theme.cautionColor ?? @@ -292,35 +307,41 @@ Widget _buildListItem(BuildContext context, V2TimGroupMemberFullInfo memberInfo, final theme = Provider.of(context).theme; return Container( color: Colors.white, - child: Slidable( - endActionPane: endActionPane, - child: Column(children: [ - ListTile( - tileColor: Colors.black, - leading: SizedBox( - width: 36, - height: 36, - child: Avatar( - faceUrl: memberInfo.faceUrl ?? "", - showName: _getShowName(memberInfo), - type: 2, + child: ListView.builder( + itemCount: 1, + shrinkWrap: true, + itemBuilder: (context, index){ + return Slidable( + endActionPane: endActionPane, + child: Column(children: [ + ListTile( + tileColor: Colors.black, + leading: SizedBox( + width: 36, + height: 36, + child: Avatar( + faceUrl: memberInfo.faceUrl ?? "", + showName: _getShowName(memberInfo), + type: 2, + ), ), + title: Row( + children: [ + Text(_getShowName(memberInfo), + style: const TextStyle(fontSize: 16)), + ], + ), + onTap: () {}, ), - title: Row( - children: [ - Text(_getShowName(memberInfo), - style: const TextStyle(fontSize: 16)), - ], - ), - onTap: () {}, - ), - Divider( - thickness: 1, - indent: 74, - endIndent: 0, - color: theme.weakDividerColor, - height: 0) - ]))); + Divider( + thickness: 1, + indent: 74, + endIndent: 0, + color: theme.weakDividerColor, + height: 0) + ])); + }) + ); } /// 选择管理员 diff --git a/pubspec.yaml b/pubspec.yaml index 2cf752b..a5fc6ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: tencent_cloud_chat_uikit description: Chat UI components library and basic chat business logic for Tencent Cloud Chat, helping you build In-APP Chat module easily. -version: 1.6.0 +version: 1.6.1 homepage: https://www.tencentcloud.com/products/im?from=pub repository: https://github.com/TencentCloud/chat-uikit-flutter documentation: https://comm.qq.com/im/doc/flutter/en/TUIKit/readme.html