|
|
|
@ -88,7 +88,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
|
|
|
|
|
await refresh(); |
|
|
|
|
|
|
|
|
|
socketClient.addCallback(_toUser.mid, (Message message) { |
|
|
|
|
messages.insert(0, message); |
|
|
|
|
messages.insert(0, message..state = 1); |
|
|
|
|
refreshState(); |
|
|
|
|
jumpToBottom(); |
|
|
|
|
}); |
|
|
|
@ -96,16 +96,21 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
|
|
|
|
|
jumpToBottom(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refresh() async { |
|
|
|
|
Future refresh() async { |
|
|
|
|
List<Message> messagePage = await hxDatabase.queryUList(_toUser.mid, page: page + 1, pageSize: 10); |
|
|
|
|
if (messagePage.isEmpty) { |
|
|
|
|
refreshController.loadNoData(); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
refreshController.loadComplete(); |
|
|
|
|
} |
|
|
|
|
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; |
|
|
|
|
return Future.value(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///查询个人信息 |
|
|
|
@ -117,7 +122,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
|
|
|
|
|
userInfo = UserInfo.fromJson(jsonDecode(value.getString('user'))); |
|
|
|
|
} |
|
|
|
|
if (apiService == null) |
|
|
|
|
apiService = ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
|
apiService = |
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
|
BaseData<UserInfo> baseData = |
|
|
|
|
await apiService.queryInfo().catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
@ -328,6 +334,26 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
|
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: SmartRefresher( |
|
|
|
|
enablePullDown: false, |
|
|
|
|
enablePullUp: true, |
|
|
|
|
header: MyHeader(), |
|
|
|
|
reverse: true, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
footer: CustomFooter( |
|
|
|
|
loadStyle: LoadStyle.ShowWhenLoading, |
|
|
|
|
builder: (BuildContext context, LoadStatus mode) { |
|
|
|
|
return (messages.length == 0) |
|
|
|
|
? Container() |
|
|
|
|
: MyFooter(mode); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
controller: refreshController, |
|
|
|
|
onLoading: () { |
|
|
|
|
refresh().then((value) { |
|
|
|
|
refreshState(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
controller: scrollController, |
|
|
|
@ -349,6 +375,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
input() |
|
|
|
@ -392,7 +419,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
|
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
AppUtils.timeFormatter(DateTime.fromMillisecondsSinceEpoch(int.parse(message.time))), |
|
|
|
|
AppUtils.timeFormatter( |
|
|
|
|
DateTime.fromMillisecondsSinceEpoch(int.parse(message.time))), |
|
|
|
|
textAlign: TextAlign.center, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
@ -561,7 +589,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
),), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|