|
|
@ -88,16 +88,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
await refresh(); |
|
|
|
await refresh(); |
|
|
|
|
|
|
|
|
|
|
|
socketClient.addCallback(_toUser.mid, (Message message) { |
|
|
|
socketClient.addCallback(_toUser.mid, (Message message) { |
|
|
|
messages.insert(0, message); |
|
|
|
messages.insert(0, message..state = 1); |
|
|
|
refreshState(); |
|
|
|
refreshState(); |
|
|
|
|
|
|
|
|
|
|
|
// if (scrollController.position != null) { |
|
|
|
|
|
|
|
// double offset = scrollController.position.maxScrollExtent; |
|
|
|
|
|
|
|
// debugPrint("offset: $offset"); |
|
|
|
|
|
|
|
// Future.delayed(const Duration(milliseconds: 500), () { |
|
|
|
|
|
|
|
// scrollController.animateTo(offset + 108, duration: const Duration(milliseconds: 500), curve: Curves.easeIn); |
|
|
|
|
|
|
|
// }); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
if (scrollController.position != null) { |
|
|
|
if (scrollController.position != null) { |
|
|
|
double maxScrollExtent = scrollController.position.maxScrollExtent; |
|
|
|
double maxScrollExtent = scrollController.position.maxScrollExtent; |
|
|
|
double viewportDimensions = scrollController.position.viewportDimension; |
|
|
|
double viewportDimensions = scrollController.position.viewportDimension; |
|
|
@ -107,15 +100,12 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
double offset = maxScrollExtent; |
|
|
|
double offset = maxScrollExtent; |
|
|
|
debugPrint("offset: $offset"); |
|
|
|
debugPrint("offset: $offset"); |
|
|
|
Future.delayed(const Duration(milliseconds: 500), () { |
|
|
|
Future.delayed(const Duration(milliseconds: 500), () { |
|
|
|
scrollController.animateTo( |
|
|
|
scrollController.animateTo(offset + 108, |
|
|
|
offset + 108, |
|
|
|
|
|
|
|
duration: const Duration(milliseconds: 500), |
|
|
|
duration: const Duration(milliseconds: 500), |
|
|
|
curve: Curves.easeIn |
|
|
|
curve: Curves.easeIn); |
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
refreshState(); |
|
|
|
refreshState(); |
|
|
|
|
|
|
|
|
|
|
@ -124,16 +114,21 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
page += 1; |
|
|
|
List<Message> messagePage = await hxDatabase.queryUList(_toUser.mid, page: page, pageSize: 10); |
|
|
|
|
|
|
|
if (page == 1) { |
|
|
|
if (page == 1) { |
|
|
|
messages = messagePage; |
|
|
|
messages = messagePage; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
messages.addAll(messagePage); |
|
|
|
messages.addAll(messagePage); |
|
|
|
} |
|
|
|
} |
|
|
|
refreshController.refreshCompleted(); |
|
|
|
return Future.value(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///查询个人信息 |
|
|
|
///查询个人信息 |
|
|
@ -144,17 +139,18 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
value.getString('user') != "") { |
|
|
|
value.getString('user') != "") { |
|
|
|
userInfo = UserInfo.fromJson(jsonDecode(value.getString('user'))); |
|
|
|
userInfo = UserInfo.fromJson(jsonDecode(value.getString('user'))); |
|
|
|
} |
|
|
|
} |
|
|
|
if(apiService == null) |
|
|
|
if (apiService == null) |
|
|
|
apiService = ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
apiService = |
|
|
|
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
BaseData<UserInfo> baseData = |
|
|
|
BaseData<UserInfo> baseData = |
|
|
|
await apiService.queryInfo().catchError((onError) {}); |
|
|
|
await apiService.queryInfo().catchError((onError) {}); |
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
setState(() { |
|
|
|
setState(() { |
|
|
|
userInfo = baseData.data; |
|
|
|
userInfo = baseData.data; |
|
|
|
}); |
|
|
|
}); |
|
|
|
SharedPreferences.getInstance().then((value) => { |
|
|
|
SharedPreferences.getInstance().then((value) => { |
|
|
|
value.setString('user', jsonEncode(baseData.data)), |
|
|
|
value.setString('user', jsonEncode(baseData.data)), |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -354,25 +350,46 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
child: Column( |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Expanded( |
|
|
|
Expanded( |
|
|
|
child: SingleChildScrollView( |
|
|
|
child: SmartRefresher( |
|
|
|
|
|
|
|
enablePullDown: false, |
|
|
|
|
|
|
|
enablePullUp: true, |
|
|
|
|
|
|
|
header: MyHeader(), |
|
|
|
|
|
|
|
reverse: true, |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
controller: scrollController, |
|
|
|
footer: CustomFooter( |
|
|
|
child: Column( |
|
|
|
loadStyle: LoadStyle.ShowWhenLoading, |
|
|
|
children: [ |
|
|
|
builder: (BuildContext context, LoadStatus mode) { |
|
|
|
GestureDetector( |
|
|
|
return (messages.length == 0) |
|
|
|
behavior: HitTestBehavior.translucent, |
|
|
|
? Container() |
|
|
|
onTap: () { |
|
|
|
: MyFooter(mode); |
|
|
|
setState(() { |
|
|
|
}, |
|
|
|
emojiShowing = false; |
|
|
|
), |
|
|
|
isKeyBoardShow = emojiShowing; |
|
|
|
controller: refreshController, |
|
|
|
moreShow = false; |
|
|
|
onLoading: () { |
|
|
|
isKeyBoardShow = moreShow; |
|
|
|
refresh().then((value) { |
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
refreshState(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: chatDetailsList(), |
|
|
|
child: SingleChildScrollView( |
|
|
|
), |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
], |
|
|
|
controller: scrollController, |
|
|
|
|
|
|
|
child: Column( |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
GestureDetector( |
|
|
|
|
|
|
|
behavior: HitTestBehavior.translucent, |
|
|
|
|
|
|
|
onTap: () { |
|
|
|
|
|
|
|
setState(() { |
|
|
|
|
|
|
|
emojiShowing = false; |
|
|
|
|
|
|
|
isKeyBoardShow = emojiShowing; |
|
|
|
|
|
|
|
moreShow = false; |
|
|
|
|
|
|
|
isKeyBoardShow = moreShow; |
|
|
|
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
child: chatDetailsList(), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
flex: 1, |
|
|
|
flex: 1, |
|
|
@ -418,7 +435,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
child: Column( |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
Text( |
|
|
|
AppUtils.timeFormatter(DateTime.fromMillisecondsSinceEpoch(int.parse(message.time))), |
|
|
|
AppUtils.timeFormatter( |
|
|
|
|
|
|
|
DateTime.fromMillisecondsSinceEpoch(int.parse(message.time))), |
|
|
|
textAlign: TextAlign.center, |
|
|
|
textAlign: TextAlign.center, |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
color: Color(0xFFA29E9E), |
|
|
@ -554,40 +572,41 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
child: Container( |
|
|
|
child: Container( |
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
child: Container( |
|
|
|
child: Container( |
|
|
|
decoration: BoxDecoration( |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.circular(6), |
|
|
|
borderRadius: BorderRadius.circular(6), |
|
|
|
color: Color(0xFFFFFFFF), |
|
|
|
color: Color(0xFFFFFFFF), |
|
|
|
boxShadow: [ |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
BoxShadow( |
|
|
|
color: Color(0xFFA8A3A3).withAlpha(12), |
|
|
|
color: Color(0xFFA8A3A3).withAlpha(12), |
|
|
|
offset: Offset(0, 4), |
|
|
|
offset: Offset(0, 4), |
|
|
|
blurRadius: 4, |
|
|
|
blurRadius: 4, |
|
|
|
spreadRadius: 0, |
|
|
|
spreadRadius: 0, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
vertical: 8.h, |
|
|
|
vertical: 8.h, |
|
|
|
horizontal: 12.w, |
|
|
|
horizontal: 12.w, |
|
|
|
), |
|
|
|
), |
|
|
|
child: GestureDetector( |
|
|
|
child: GestureDetector( |
|
|
|
onLongPress: () { |
|
|
|
onLongPress: () { |
|
|
|
setState(() { |
|
|
|
setState(() { |
|
|
|
copyIndex = 1; |
|
|
|
copyIndex = 1; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: Text( |
|
|
|
child: Text( |
|
|
|
tex = message.content, |
|
|
|
tex = message.content, |
|
|
|
textAlign: TextAlign.left, |
|
|
|
textAlign: TextAlign.left, |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
height: 1.2.h, |
|
|
|
height: 1.2.h, |
|
|
|
color: Color(0XFF0D0D0D), |
|
|
|
color: Color(0XFF0D0D0D), |
|
|
|
fontSize: 17.sp, |
|
|
|
fontSize: 17.sp, |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
),), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
@ -753,7 +772,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
width: 12.w, |
|
|
|
width: 12.w, |
|
|
|
), |
|
|
|
), |
|
|
|
MImage( |
|
|
|
MImage( |
|
|
|
userInfo?.headimg??"", |
|
|
|
userInfo?.headimg ?? "", |
|
|
|
isCircle: true, |
|
|
|
isCircle: true, |
|
|
|
height: 44.h, |
|
|
|
height: 44.h, |
|
|
|
width: 44.h, |
|
|
|
width: 44.h, |
|
|
@ -895,7 +914,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
// scrollController.animateTo(offset + 108, duration: const Duration(milliseconds: 500), curve: Curves.easeIn); |
|
|
|
// scrollController.animateTo(offset + 108, duration: const Duration(milliseconds: 500), curve: Curves.easeIn); |
|
|
|
// }); |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// } |
|
|
|
if (scrollController.position.maxScrollExtent > scrollController.offset) { |
|
|
|
if (scrollController.position.maxScrollExtent > |
|
|
|
|
|
|
|
scrollController.offset) { |
|
|
|
// 如果未滑动到底部,则自动滑动到底部 |
|
|
|
// 如果未滑动到底部,则自动滑动到底部 |
|
|
|
scrollController.animateTo( |
|
|
|
scrollController.animateTo( |
|
|
|
scrollController.position.maxScrollExtent, |
|
|
|
scrollController.position.maxScrollExtent, |
|
|
@ -920,7 +940,6 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
// }); |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
maxLines: 8, |
|
|
|
maxLines: 8, |
|
|
|