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 { queryUser() async {
final SharedPreferences value = await SharedPreferences.getInstance(); sharedPre = await SharedPreferences.getInstance();
if (apiService == null) if (apiService == null)
apiService = ApiService(Dio(), context: context, token: value.getString("token")); apiService = ApiService(Dio(), context: context, token: sharedPre.getString("token"));
if (value.containsKey('user') && if (sharedPre.containsKey('user') &&
value.getString('user') != null && sharedPre.getString('user') != null &&
value.getString('user') != "") { sharedPre.getString('user') != "") {
userInfo = UserInfo.fromJson(jsonDecode(value.getString('user'))); userInfo = UserInfo.fromJson(jsonDecode(sharedPre.getString('user')));
if (userInfo.phone?.isNotEmpty ?? false) { if (userInfo.phone?.isNotEmpty ?? false) {
setState(() {}); setState(() {});
return; return;
@ -382,8 +384,17 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
compressSize: 500, compressSize: 500,
); );
if (medias == null) return; if (medias == null) return;
filePath = medias.path; String path = medias.path;
fileUpload(); 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{ }else{
showCameraTipsAlertDialog(context); showCameraTipsAlertDialog(context);
return false; return false;
@ -393,19 +404,6 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
return false; 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 { showCameraTipsAlertDialog(context) async {
@ -1297,11 +1295,28 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
} }
Size size = Size.zero; 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(); Completer<Size> completer = Completer();
Image.file(file).image.resolve(ImageConfiguration()) Image.file(file).image.resolve(ImageConfiguration())
.addListener(ImageStreamListener((image, synchronousCall) { .addListener(ImageStreamListener((image, synchronousCall) {
size = Size((image.image.width ?? 0).toDouble(), (image.image.height ?? 0).toDouble()); size = Size((image.image.width ?? 0).toDouble(), (image.image.height ?? 0).toDouble());
size = resizeImage(size); size = resizeImage(size);
Map<String, double> sizeMap = {
"width": size.width,
"height": size.height,
};
sharedPre.setString(imageLocalPath, jsonEncode(sizeMap));
completer.complete(size); completer.complete(size);
})); }));
return completer.future; return completer.future;
@ -1399,9 +1414,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
_onMoreTap(); // _onMoreTap();
jumpToBottom(); // jumpToBottom();
// SmartDialog.showToast("暂不支持", alignment: Alignment.center); SmartDialog.showToast("暂不支持", alignment: Alignment.center);
}, },
child: Container( child: Container(
padding: EdgeInsets.only(left: 8.w, right: 19.w), padding: EdgeInsets.only(left: 8.w, right: 19.w),

Loading…
Cancel
Save