|
|
@ -12,9 +12,12 @@ import 'package:huixiang/im/database/message.dart'; |
|
|
|
import 'package:huixiang/main.dart'; |
|
|
|
import 'package:huixiang/main.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/im_user.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/im_user.dart'; |
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/view_widget/my_footer.dart'; |
|
|
|
import 'package:image_pickers/image_pickers.dart'; |
|
|
|
import 'package:image_pickers/image_pickers.dart'; |
|
|
|
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
import '../../community/release_dynamic.dart'; |
|
|
|
import '../../community/release_dynamic.dart'; |
|
|
|
import '../../generated/l10n.dart'; |
|
|
|
import '../../generated/l10n.dart'; |
|
|
@ -69,7 +72,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
// SmartDialog.showToast("聊天 $txt", alignment: Alignment.center); |
|
|
|
// SmartDialog.showToast("聊天 $txt", alignment: Alignment.center); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RefreshController refreshController = RefreshController(); |
|
|
|
List<Message> messages = []; |
|
|
|
List<Message> messages = []; |
|
|
|
|
|
|
|
int page = 0; |
|
|
|
|
|
|
|
|
|
|
|
loadMessageList() async { |
|
|
|
loadMessageList() async { |
|
|
|
ImUser imUser = await hxDatabase.queryImUserById(_toUser.mid); |
|
|
|
ImUser imUser = await hxDatabase.queryImUserById(_toUser.mid); |
|
|
@ -80,7 +85,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
selfUserId = (await SharedPreferences.getInstance()).getString("userId"); |
|
|
|
selfUserId = (await SharedPreferences.getInstance()).getString("userId"); |
|
|
|
// unread msg 2 read state |
|
|
|
// unread msg 2 read state |
|
|
|
await hxDatabase.readMessage(selfUserId, _toUser.mid); |
|
|
|
await hxDatabase.readMessage(selfUserId, _toUser.mid); |
|
|
|
messages = await hxDatabase.queryUList(_toUser.mid, pageSize: 100); |
|
|
|
await refresh(); |
|
|
|
|
|
|
|
|
|
|
|
socketClient.addCallback(_toUser.mid, (Message message) { |
|
|
|
socketClient.addCallback(_toUser.mid, (Message message) { |
|
|
|
messages.insert(0, message); |
|
|
|
messages.insert(0, message); |
|
|
@ -119,6 +124,18 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refresh() async { |
|
|
|
|
|
|
|
page += 1; |
|
|
|
|
|
|
|
List<Message> messagePage = await hxDatabase.queryUList(_toUser.mid, page: page, pageSize: 10); |
|
|
|
|
|
|
|
if (page == 1) { |
|
|
|
|
|
|
|
messages = messagePage; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
messages.addAll(messagePage); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///查询个人信息 |
|
|
|
///查询个人信息 |
|
|
|
queryUser() async { |
|
|
|
queryUser() async { |
|
|
|
final SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
final SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|