气泡框修复
This commit is contained in:
parent
ef11d0f01b
commit
7bce08a3b4
@ -21,6 +21,7 @@ import 'package:yumi/shared/tools/sc_date_utils.dart';
|
|||||||
import 'package:yumi/shared/tools/sc_loading_manager.dart';
|
import 'package:yumi/shared/tools/sc_loading_manager.dart';
|
||||||
import 'package:yumi/shared/tools/sc_message_utils.dart';
|
import 'package:yumi/shared/tools/sc_message_utils.dart';
|
||||||
import 'package:yumi/shared/tools/sc_user_id_utils.dart';
|
import 'package:yumi/shared/tools/sc_user_id_utils.dart';
|
||||||
|
import 'package:yumi/shared/tools/sc_chat_bubble_message_utils.dart';
|
||||||
import 'package:yumi/shared/data_sources/sources/repositories/sc_user_repository_impl.dart';
|
import 'package:yumi/shared/data_sources/sources/repositories/sc_user_repository_impl.dart';
|
||||||
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||||
import 'package:yumi/services/audio/rtm_manager.dart';
|
import 'package:yumi/services/audio/rtm_manager.dart';
|
||||||
@ -56,7 +57,6 @@ import 'package:yumi/shared/tools/sc_cp_relation_notice_utils.dart';
|
|||||||
import 'package:yumi/shared/tools/sc_keybord_util.dart';
|
import 'package:yumi/shared/tools/sc_keybord_util.dart';
|
||||||
import 'package:yumi/shared/tools/sc_message_notifier.dart';
|
import 'package:yumi/shared/tools/sc_message_notifier.dart';
|
||||||
import 'package:yumi/shared/tools/sc_path_utils.dart';
|
import 'package:yumi/shared/tools/sc_path_utils.dart';
|
||||||
import 'package:yumi/shared/data_sources/sources/local/data_persistence.dart';
|
|
||||||
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
|
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
|
||||||
import 'package:yumi/services/auth/user_profile_manager.dart';
|
import 'package:yumi/services/auth/user_profile_manager.dart';
|
||||||
import 'package:yumi/modules/index/main_route.dart';
|
import 'package:yumi/modules/index/main_route.dart';
|
||||||
@ -2623,10 +2623,9 @@ class _MessageItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTextBubble(String content) {
|
Widget _buildTextBubble(String content) {
|
||||||
final chatBubble =
|
final chatBubble = scDecodeChatBubbleFromCloudCustomData(
|
||||||
(message.isSelf ?? false)
|
message.cloudCustomData,
|
||||||
? _currentUserChatBubble()
|
);
|
||||||
: _senderProfile()?.getChatBox();
|
|
||||||
final chatBubbleUrl = _resolveChatBubbleImageUrl(chatBubble);
|
final chatBubbleUrl = _resolveChatBubbleImageUrl(chatBubble);
|
||||||
if (chatBubbleUrl.isNotEmpty) {
|
if (chatBubbleUrl.isNotEmpty) {
|
||||||
return _buildVipTextBubble(content: content, imageUrl: chatBubbleUrl);
|
return _buildVipTextBubble(content: content, imageUrl: chatBubbleUrl);
|
||||||
@ -2634,36 +2633,6 @@ class _MessageItem extends StatelessWidget {
|
|||||||
return _buildDefaultTextBubble(content);
|
return _buildDefaultTextBubble(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropsResources? _currentUserChatBubble() {
|
|
||||||
final currentUser = AccountStorage().getCurrentUser();
|
|
||||||
final memoryBubble = currentUser?.userProfile?.getChatBox();
|
|
||||||
if (_resolveChatBubbleImageUrl(memoryBubble).isNotEmpty) {
|
|
||||||
return memoryBubble;
|
|
||||||
}
|
|
||||||
if (currentUser?.userProfile != null) {
|
|
||||||
return memoryBubble;
|
|
||||||
}
|
|
||||||
|
|
||||||
final userJson = DataPersistence.getCurrentUser();
|
|
||||||
if (userJson.isEmpty) {
|
|
||||||
return memoryBubble;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return SocialChatLoginRes.fromJson(
|
|
||||||
jsonDecode(userJson),
|
|
||||||
).userProfile?.getChatBox();
|
|
||||||
} catch (_) {
|
|
||||||
return memoryBubble;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SocialChatUserProfile? _senderProfile() {
|
|
||||||
if (message.isSelf ?? false) {
|
|
||||||
return AccountStorage().getCurrentUser()?.userProfile;
|
|
||||||
}
|
|
||||||
return friend;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildDefaultTextBubble(String content) {
|
Widget _buildDefaultTextBubble(String content) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import 'package:yumi/shared/tools/sc_message_utils.dart';
|
|||||||
import 'package:yumi/shared/tools/sc_path_utils.dart';
|
import 'package:yumi/shared/tools/sc_path_utils.dart';
|
||||||
import 'package:yumi/shared/tools/sc_room_top_layer_guard.dart';
|
import 'package:yumi/shared/tools/sc_room_top_layer_guard.dart';
|
||||||
import 'package:yumi/shared/tools/sc_room_utils.dart';
|
import 'package:yumi/shared/tools/sc_room_utils.dart';
|
||||||
|
import 'package:yumi/shared/tools/sc_chat_bubble_message_utils.dart';
|
||||||
import 'package:yumi/shared/tools/sc_cp_gift_relation_utils.dart';
|
import 'package:yumi/shared/tools/sc_cp_gift_relation_utils.dart';
|
||||||
import 'package:yumi/shared/tools/sc_cp_relation_broadcast_assets.dart';
|
import 'package:yumi/shared/tools/sc_cp_relation_broadcast_assets.dart';
|
||||||
import 'package:yumi/shared/tools/sc_cp_relation_notice_utils.dart';
|
import 'package:yumi/shared/tools/sc_cp_relation_notice_utils.dart';
|
||||||
@ -2643,6 +2644,9 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
if (createTextMessageRes.code == 0) {
|
if (createTextMessageRes.code == 0) {
|
||||||
// 文本信息创建成功
|
// 文本信息创建成功
|
||||||
String id = createTextMessageRes.data!.id!;
|
String id = createTextMessageRes.data!.id!;
|
||||||
|
final chatBubbleCloudCustomData = scEncodeChatBubbleCloudCustomData(
|
||||||
|
AccountStorage().getCurrentUser()?.userProfile?.getChatBox(),
|
||||||
|
);
|
||||||
// 发送文本消息
|
// 发送文本消息
|
||||||
// 在sendMessage时,若只填写receiver则发个人用户单聊消息
|
// 在sendMessage时,若只填写receiver则发个人用户单聊消息
|
||||||
// 若只填写groupID则发群组消息
|
// 若只填写groupID则发群组消息
|
||||||
@ -2656,6 +2660,7 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
receiver: toConversation.userID!, // 接收人id
|
receiver: toConversation.userID!, // 接收人id
|
||||||
needReadReceipt: true,
|
needReadReceipt: true,
|
||||||
groupID: '', // 是否需要已读回执
|
groupID: '', // 是否需要已读回执
|
||||||
|
cloudCustomData: chatBubbleCloudCustomData,
|
||||||
);
|
);
|
||||||
if (sendMessageRes.code == 0) {
|
if (sendMessageRes.code == 0) {
|
||||||
// 发送成功
|
// 发送成功
|
||||||
|
|||||||
50
lib/shared/tools/sc_chat_bubble_message_utils.dart
Normal file
50
lib/shared/tools/sc_chat_bubble_message_utils.dart
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||||
|
|
||||||
|
const String scChatBubbleCloudDataKey = 'scChatBubble';
|
||||||
|
|
||||||
|
String? scEncodeChatBubbleCloudCustomData(PropsResources? chatBubble) {
|
||||||
|
if (!_hasChatBubbleImage(chatBubble)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return jsonEncode(<String, dynamic>{
|
||||||
|
scChatBubbleCloudDataKey: chatBubble!.toJson(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
PropsResources? scDecodeChatBubbleFromCloudCustomData(String? cloudCustomData) {
|
||||||
|
final raw = cloudCustomData?.trim();
|
||||||
|
if (raw == null || raw.isEmpty) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final decoded = jsonDecode(raw);
|
||||||
|
if (decoded is! Map) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final data = decoded[scChatBubbleCloudDataKey];
|
||||||
|
if (data is Map) {
|
||||||
|
return PropsResources.fromJson(data);
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _hasChatBubbleImage(PropsResources? resource) {
|
||||||
|
if (resource == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return <String?>[
|
||||||
|
resource.imSendCoverUrl,
|
||||||
|
resource.imOpenedUrl,
|
||||||
|
resource.imOpenedUrlTwo,
|
||||||
|
resource.imNotOpenedUrl,
|
||||||
|
resource.roomSendCoverUrl,
|
||||||
|
resource.roomOpenedUrl,
|
||||||
|
resource.roomNotOpenedUrl,
|
||||||
|
resource.cover,
|
||||||
|
resource.expand,
|
||||||
|
resource.sourceUrl,
|
||||||
|
].any((value) => (value?.trim() ?? '').isNotEmpty);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user