fix(chat): 修复会话列表中标题显示异常问题
This commit is contained in:
parent
319ed953a7
commit
f40ed4d7fb
|
|
@ -16,6 +16,7 @@ import 'package:tencent_cloud_chat_uikit/ui/widgets/unread_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
|
import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
|
||||||
|
|
||||||
typedef LastMessageBuilder = Widget? Function(V2TimMessage? lastMsg, List<V2TimGroupAtInfo?> groupAtInfoList);
|
typedef LastMessageBuilder = Widget? Function(V2TimMessage? lastMsg, List<V2TimGroupAtInfo?> groupAtInfoList);
|
||||||
|
|
||||||
|
|
@ -53,13 +54,20 @@ class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
|
|
||||||
Widget _getShowMsgWidget(BuildContext context) {
|
Widget _getShowMsgWidget(BuildContext context) {
|
||||||
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
|
final isAndroid = PlatformUtils().isAndroid;
|
||||||
|
|
||||||
|
// 针对安卓设备的字体大小调整
|
||||||
|
final msgFontSize = isDesktopScreen
|
||||||
|
? 12.0
|
||||||
|
: (isAndroid ? 13.0 : 14.0); // 安卓设备使用稍小的字体
|
||||||
|
|
||||||
if (lastMsg != null && lastMessageBuilder != null && lastMessageBuilder!(lastMsg, groupAtInfoList) != null) {
|
if (lastMsg != null && lastMessageBuilder != null && lastMessageBuilder!(lastMsg, groupAtInfoList) != null) {
|
||||||
return lastMessageBuilder!(lastMsg, groupAtInfoList)!;
|
return lastMessageBuilder!(lastMsg, groupAtInfoList)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMsg != null || (draftText != null && draftText != "")) {
|
if (lastMsg != null || (draftText != null && draftText != "")) {
|
||||||
return TIMUIKitLastMsg(
|
return TIMUIKitLastMsg(
|
||||||
fontSize: isDesktopScreen ? 12 : 14,
|
fontSize: msgFontSize,
|
||||||
groupAtInfoList: groupAtInfoList,
|
groupAtInfoList: groupAtInfoList,
|
||||||
lastMsg: lastMsg,
|
lastMsg: lastMsg,
|
||||||
isDisturb: isDisturb,
|
isDisturb: isDisturb,
|
||||||
|
|
@ -102,6 +110,13 @@ class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final TUITheme theme = value.theme;
|
final TUITheme theme = value.theme;
|
||||||
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
|
final isAndroid = PlatformUtils().isAndroid;
|
||||||
|
|
||||||
|
// 针对安卓设备的字体大小调整
|
||||||
|
final titleFontSize = isDesktopScreen
|
||||||
|
? 14.0
|
||||||
|
: (isAndroid ? 16.0 : 18.0); // 安卓设备使用稍小的字体
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.only(top: 6, bottom: 6, left: 16, right: 16),
|
padding: const EdgeInsets.only(top: 6, bottom: 6, left: 16, right: 16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
@ -150,8 +165,10 @@ class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Flexible(
|
||||||
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
nickName,
|
nickName,
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
|
|
@ -161,11 +178,17 @@ class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
height: 1,
|
height: 1,
|
||||||
color: theme.conversationItemTitleTextColor,
|
color: theme.conversationItemTitleTextColor,
|
||||||
fontSize: isDesktopScreen ? 14 : 18,
|
fontSize: titleFontSize,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
_getTimeStringForChatWidget(context, theme),
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(left: 8),
|
||||||
|
child: _getTimeStringForChatWidget(context, theme),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (isHaveSecondLine())
|
if (isHaveSecondLine())
|
||||||
|
|
@ -175,15 +198,25 @@ class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: _getShowMsgWidget(context)),
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
minHeight: 20,
|
||||||
|
),
|
||||||
|
child: _getShowMsgWidget(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
if (isDisturb)
|
if (isDisturb)
|
||||||
SizedBox(
|
Container(
|
||||||
width: 18,
|
margin: const EdgeInsets.only(left: 8),
|
||||||
height: 18,
|
child: SizedBox(
|
||||||
child: Icon(
|
width: 18,
|
||||||
Icons.notifications_off,
|
height: 18,
|
||||||
color: theme.conversationItemNoNotificationIconColor,
|
child: Icon(
|
||||||
size: isDesktopScreen ? 14 : 16.0,
|
Icons.notifications_off,
|
||||||
|
color: theme.conversationItemNoNotificationIconColor,
|
||||||
|
size: isDesktopScreen ? 14 : 16.0,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/message.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
|
import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/special_text/DefaultSpecialTextSpanBuilder.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
||||||
|
|
@ -210,6 +211,7 @@ class _TIMUIKitLastMsgState extends TIMUIKitState<TIMUIKitLastMsg> {
|
||||||
String disturbUnreadCountInfo = _getDisturbUnreadCountInfo();
|
String disturbUnreadCountInfo = _getDisturbUnreadCountInfo();
|
||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
if (icon != null)
|
if (icon != null)
|
||||||
Container(
|
Container(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue