|
|
@@ -2,7 +2,6 @@ import 'dart:convert'; |
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:chat/chat/group_chat_item.dart';
|
|
|
|
import 'package:chat/data/UserData.dart';
|
|
|
|
import 'package:chat/data/chat_data_mgr.dart';
|
|
|
|
import 'package:chat/data/constants.dart';
|
|
|
|
import 'package:chat/data/group_data_mgr.dart';
|
|
|
@@ -19,12 +18,10 @@ import 'package:chat/utils/MessageMgr.dart'; |
|
|
|
import 'package:chat/utils/analyze_utils.dart';
|
|
|
|
import 'package:chat/utils/msgHandler.dart';
|
|
|
|
import 'package:chat/utils/net_state_widget.dart';
|
|
|
|
import 'package:chat/utils/screen.dart';
|
|
|
|
import 'package:chat/utils/sound_util.dart';
|
|
|
|
import 'package:chat/utils/sp_utils.dart';
|
|
|
|
import 'package:chat/utils/sql_util.dart';
|
|
|
|
import 'package:chat/utils/upload_util.dart';
|
|
|
|
import 'package:chat/utils/white_opacity_anim.dart';
|
|
|
|
import 'package:extended_text/extended_text.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
@@ -396,91 +393,6 @@ class _GroupChatPageState extends State<GroupChatPage> { |
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//更新各个子元素的偏移位置
|
|
|
|
_updateMsgItemOffset() {
|
|
|
|
if (msgList.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var myId = UserData().basicInfo.userId;
|
|
|
|
double offset = 0;
|
|
|
|
for (var i = 0; i < msgList.length; i++) {
|
|
|
|
MsgModel msg = msgList[i];
|
|
|
|
|
|
|
|
double itemHeight = 70;
|
|
|
|
switch (ChatType.valueOf(msg.msgType)) {
|
|
|
|
case ChatType.TextChatType:
|
|
|
|
//if (msg.from == myId) {
|
|
|
|
var text = utf8.decode(msg.msgContent);
|
|
|
|
itemHeight = 21 + _getTextHeight(text);
|
|
|
|
//} else {}
|
|
|
|
break;
|
|
|
|
case ChatType.ShortVoiceChatType:
|
|
|
|
if (msg.from == myId) {
|
|
|
|
itemHeight = 22.5 + 24;
|
|
|
|
} else {}
|
|
|
|
break;
|
|
|
|
case ChatType.ImageChatType:
|
|
|
|
itemHeight = _getImgHeight(msg);
|
|
|
|
break;
|
|
|
|
case ChatType.ShortVideoChatType:
|
|
|
|
itemHeight = _getImgHeight(msg);
|
|
|
|
break;
|
|
|
|
case ChatType.EmoticonType:
|
|
|
|
itemHeight = 40;
|
|
|
|
break;
|
|
|
|
case ChatType.RedWalletChatType:
|
|
|
|
print('红包消息');
|
|
|
|
itemHeight = 70;
|
|
|
|
break;
|
|
|
|
case ChatType.PlaceChatType:
|
|
|
|
itemHeight = 100 + 40.0;
|
|
|
|
break;
|
|
|
|
case ChatType.GroupChatNoticeType:
|
|
|
|
itemHeight = 40;
|
|
|
|
break;
|
|
|
|
case ChatType.GiftChatType:
|
|
|
|
itemHeight = 40;
|
|
|
|
break;
|
|
|
|
case ChatType.FileChatType:
|
|
|
|
itemHeight = 80;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
itemOffsetMap[i] = offset;
|
|
|
|
offset += itemHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double _getTextHeight(String text) {
|
|
|
|
var tp = TextPainter(
|
|
|
|
text: TextSpan(style: TextStyle(fontSize: 15), text: text),
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
textDirection: TextDirection.ltr,
|
|
|
|
textScaleFactor: 1,
|
|
|
|
);
|
|
|
|
|
|
|
|
tp.layout(maxWidth: Screen.width - 140);
|
|
|
|
|
|
|
|
return tp.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
double _getImgHeight(MsgModel msg) {
|
|
|
|
double aspectRatio = msg.extraInfo / 100;
|
|
|
|
|
|
|
|
var maxWidth = Screen.width * 0.65;
|
|
|
|
var maxHeight = Screen.height / 4;
|
|
|
|
|
|
|
|
double height;
|
|
|
|
if (maxWidth / maxHeight > aspectRatio) {
|
|
|
|
height = maxHeight;
|
|
|
|
} else {
|
|
|
|
height = maxWidth / aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildMessageList() {
|
|
|
|
return Container(
|
|
|
|