Browse Source

no message

master
ZHR007 2 months ago
parent
commit
3846f9c421
5 changed files with 36 additions and 29 deletions
  1. 3
      lib/controller/discover/svga_player_manager.dart
  2. 34
      lib/controller/message/chat_controller.dart
  3. 5
      lib/pages/message/chat_page.dart
  4. 15
      lib/widget/message/gift_item.dart
  5. 8
      lib/widget/message/message_item.dart

3
lib/controller/discover/svga_player_manager.dart

@ -52,7 +52,7 @@ class SvgaPlayerManager extends GetxController {
///
void onAnimationFinished() {
print('✅ SVGA 动画播放完成');
print('✅ SVGA 动画播放完成55');
isPlaying.value = false;
currentItem.value = null;
//
@ -78,6 +78,7 @@ class SvgaPlayerManager extends GetxController {
void clearQueue() {
stop();
_animationQueue.clear();
Get.log('clearQueue>>>81');
}
///

34
lib/controller/message/chat_controller.dart

@ -913,21 +913,7 @@ class ChatController extends GetxController {
_refreshConversationList();
if(_isGiftMessage(message) && Get.currentRoute == '/ChatPage'){
Get.log('message915: $message');
final giftInfo = _parseGiftInfo(message);
var svgaFile = '', giftProductId = '';
if (giftInfo != null) {
svgaFile = giftInfo['svgaFile']?.toString() ?? '';
giftProductId = giftInfo['giftProductId']?.toString() ?? '';
}
if(svgaFile.isNotEmpty){
final svgaManager = SvgaPlayerManager.instance;
svgaManager.addToQueue(
SvgaAnimationItem(
svgaFile: svgaFile,
giftProductId: giftProductId,
),
);
}
playSvga(message);
}
if (Get.isLogEnable) {
Get.log('收到新消息并添加到列表: ${message.msgId}');
@ -1184,6 +1170,24 @@ class ChatController extends GetxController {
}
}
playSvga(EMMessage message){
final giftInfo = _parseGiftInfo(message);
var svgaFile = '', giftProductId = '';
if (giftInfo != null) {
svgaFile = giftInfo['svgaFile']?.toString() ?? '';
giftProductId = giftInfo['giftProductId']?.toString() ?? '';
}
if(svgaFile.isNotEmpty){
final svgaManager = SvgaPlayerManager.instance;
svgaManager.addToQueue(
SvgaAnimationItem(
svgaFile: svgaFile,
giftProductId: giftProductId,
),
);
}
}
///
Future<bool> resendMessage(EMMessage failedMessage) async {
try {

5
lib/pages/message/chat_page.dart

@ -1,3 +1,4 @@
import 'package:dating_touchme_app/controller/discover/svga_player_manager.dart';
import 'package:dating_touchme_app/extension/ex_widget.dart';
import 'package:dating_touchme_app/widget/live/svga_player_widget.dart';
import 'package:flutter/material.dart';
@ -243,6 +244,8 @@ class _ChatPageState extends State<ChatPage> {
}
await VoicePlayerManager.instance.stop();
if (!didPop) {
final svgaManager = SvgaPlayerManager.instance;
svgaManager.clearQueue();
Get.back();
}
},
@ -414,7 +417,7 @@ class _ChatPageState extends State<ChatPage> {
),
),
),
const SvgaPlayerWidget(),
SvgaPlayerWidget(),
],
),

15
lib/widget/message/gift_item.dart

@ -16,6 +16,7 @@ class GiftItem extends StatelessWidget {
final bool showTime;
final String formattedTime;
final VoidCallback? onResend;
final VoidCallback? onSvgaPlay;
const GiftItem({
required this.message,
@ -23,6 +24,7 @@ class GiftItem extends StatelessWidget {
required this.showTime,
required this.formattedTime,
this.onResend,
this.onSvgaPlay,
super.key,
});
@ -230,18 +232,7 @@ class GiftItem extends StatelessWidget {
],
),
).onTap((){
final svgaFile = _getGiftSvga();
Get.log(giftInfo.toString());
Get.log('${message.status}');
if ((message.status == MessageStatus.SUCCESS || message.status == MessageStatus.PROGRESS) && svgaFile.isNotEmpty) {
final svgaManager = SvgaPlayerManager.instance;
svgaManager.addToQueue(
SvgaAnimationItem(
svgaFile: svgaFile,
giftProductId: giftInfo['giftProductId']?.toString() ?? '',
),
);
}
onSvgaPlay?.call();
}),
if (isSentByMe) SizedBox(width: 8.w),
if (isSentByMe) _buildAvatar(),

8
lib/widget/message/message_item.dart

@ -104,6 +104,14 @@ class MessageItem extends StatelessWidget {
print('重发消息失败: $e');
}
},
onSvgaPlay: (){
try {
final controller = chatController ?? Get.find<ChatController>();
controller.playSvga(message);
} catch (e) {
print('重发消息失败: $e');
}
},
);
}

Loading…
Cancel
Save