Browse Source

convastion list message type show

wr_202303
zsw 4 months ago
parent
commit
d3d7bff8b6
  1. 63
      lib/im/chat_details_page.dart

63
lib/im/chat_details_page.dart

@ -135,15 +135,17 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}
}
SharedPreferences sharedPre;
///
queryUser() async {
final SharedPreferences value = await SharedPreferences.getInstance();
sharedPre = await SharedPreferences.getInstance();
if (apiService == null)
apiService = ApiService(Dio(), context: context, token: value.getString("token"));
if (value.containsKey('user') &&
value.getString('user') != null &&
value.getString('user') != "") {
userInfo = UserInfo.fromJson(jsonDecode(value.getString('user')));
apiService = ApiService(Dio(), context: context, token: sharedPre.getString("token"));
if (sharedPre.containsKey('user') &&
sharedPre.getString('user') != null &&
sharedPre.getString('user') != "") {
userInfo = UserInfo.fromJson(jsonDecode(sharedPre.getString('user')));
if (userInfo.phone?.isNotEmpty ?? false) {
setState(() {});
return;
@ -382,8 +384,17 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
compressSize: 500,
);
if (medias == null) return;
filePath = medias.path;
fileUpload();
String path = medias.path;
String fileUrl = await qiniu.uploadFile(apiService, path);
socketClient.sendMessage(_toUser.mid, fileUrl, attach: path, msgType: 2).then((value) {
Message message = value;
messages.insert(0, message);
chatController.clear();
messageShowTime().then((value) {
refreshState();
jumpToBottom();
});
});
}else{
showCameraTipsAlertDialog(context);
return false;
@ -393,19 +404,6 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
return false;
}
}
String filePath;
///
fileUpload() async {
if (filePath != null && filePath != "" && await File(filePath).exists()) {
BaseData<UploadResult> baseData = await apiService
.upload(File(filePath), 123123123, false)
.catchError((onError) {});
if (baseData != null && baseData.isSuccess) {
UploadResult uploadResult = baseData.data;
}
}
}
///
showCameraTipsAlertDialog(context) async {
@ -1297,11 +1295,28 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}
Size size = Size.zero;
if (sharedPre != null) {
String sizeStr = sharedPre.getString(imageLocalPath);
if (sizeStr != null && sizeStr != "") {
Map<String, double> sizeMap = jsonDecode(sizeStr);
size = Size(sizeMap["width"], sizeMap["height"]);
if (size != Size.zero) {
return size;
}
}
}
Completer<Size> completer = Completer();
Image.file(file).image.resolve(ImageConfiguration())
.addListener(ImageStreamListener((image, synchronousCall) {
size = Size((image.image.width ?? 0).toDouble(), (image.image.height ?? 0).toDouble());
size = resizeImage(size);
Map<String, double> sizeMap = {
"width": size.width,
"height": size.height,
};
sharedPre.setString(imageLocalPath, jsonEncode(sizeMap));
completer.complete(size);
}));
return completer.future;
@ -1399,9 +1414,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
_onMoreTap();
jumpToBottom();
// SmartDialog.showToast("暂不支持", alignment: Alignment.center);
// _onMoreTap();
// jumpToBottom();
SmartDialog.showToast("暂不支持", alignment: Alignment.center);
},
child: Container(
padding: EdgeInsets.only(left: 8.w, right: 19.w),

Loading…
Cancel
Save