|
|
@ -97,19 +97,20 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Future refresh() async { |
|
|
|
Future refresh() async { |
|
|
|
List<Message> messagePage = await hxDatabase.queryUList(_toUser.mid, page: page + 1, pageSize: 10); |
|
|
|
List<Message> messagePage = |
|
|
|
if (messagePage.isEmpty) { |
|
|
|
await hxDatabase.queryUList(_toUser.mid, page: page + 1, pageSize: 10); |
|
|
|
refreshController.loadNoData(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
refreshController.loadComplete(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
page += 1; |
|
|
|
page += 1; |
|
|
|
if (page == 1) { |
|
|
|
if (page == 1) { |
|
|
|
messages = messagePage; |
|
|
|
messages = messagePage; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
messages.addAll(messagePage); |
|
|
|
messages.addAll(messagePage); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (messagePage.isEmpty) { |
|
|
|
|
|
|
|
refreshController.loadNoData(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
refreshController.loadComplete(); |
|
|
|
|
|
|
|
} |
|
|
|
return Future.value(); |
|
|
|
return Future.value(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -155,7 +156,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
|
|
|
|
|
|
|
|
void jumpToBottom() { |
|
|
|
void jumpToBottom() { |
|
|
|
Future.delayed(const Duration(milliseconds: 100), () { |
|
|
|
Future.delayed(const Duration(milliseconds: 100), () { |
|
|
|
scrollController.position.jumpTo(scrollController.position.maxScrollExtent); |
|
|
|
scrollController.position |
|
|
|
|
|
|
|
.jumpTo(scrollController.position.maxScrollExtent); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -326,11 +328,16 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
leadingColor: Colors.black, |
|
|
|
leadingColor: Colors.black, |
|
|
|
action: GestureDetector( |
|
|
|
action: GestureDetector( |
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
onTap: () { |
|
|
|
onTap: () async { |
|
|
|
setState(() { |
|
|
|
await Navigator.of(context).pushNamed('/router/chat_setting', |
|
|
|
Navigator.of(context).pushNamed('/router/chat_setting',arguments: {"userId": _toUser.mid}); |
|
|
|
arguments: {"userId": _toUser.mid}); |
|
|
|
copyIndex = 0; |
|
|
|
page = 0; |
|
|
|
|
|
|
|
refresh().then((value) { |
|
|
|
|
|
|
|
refreshState(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// setState(() { |
|
|
|
|
|
|
|
// copyIndex = 0; |
|
|
|
|
|
|
|
// }); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
child: Container( |
|
|
|
alignment: Alignment.center, |
|
|
|
alignment: Alignment.center, |
|
|
@ -355,9 +362,10 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
footer: CustomFooter( |
|
|
|
footer: CustomFooter( |
|
|
|
loadStyle: LoadStyle.ShowWhenLoading, |
|
|
|
loadStyle: LoadStyle.ShowWhenLoading, |
|
|
|
builder: (BuildContext context, LoadStatus mode) { |
|
|
|
builder: (BuildContext context, LoadStatus mode) { |
|
|
|
return (messages.length == 0) |
|
|
|
// return (messages.length == 0) |
|
|
|
? Container() |
|
|
|
// ? Container() |
|
|
|
: MyFooter(mode); |
|
|
|
// : MyFooter(mode); |
|
|
|
|
|
|
|
return SizedBox(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
controller: refreshController, |
|
|
|
controller: refreshController, |
|
|
@ -367,10 +375,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: SingleChildScrollView( |
|
|
|
child: SingleChildScrollView( |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
controller: scrollController, |
|
|
|
controller: scrollController, |
|
|
|
child: chatDetailsList() |
|
|
|
child: chatDetailsList()), |
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
flex: 1, |
|
|
|
flex: 1, |
|
|
|
), |
|
|
|
), |
|
|
@ -378,8 +385,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
)); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///聊天列表 |
|
|
|
///聊天列表 |
|
|
@ -397,18 +403,19 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
onTap: () { |
|
|
|
onTap: () { |
|
|
|
setState(() { |
|
|
|
setState(() { |
|
|
|
copyIndex = 0; |
|
|
|
copyIndex = 0; |
|
|
|
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: chatDetailsItem(messages[position]), |
|
|
|
child: chatDetailsItem(position), |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget chatDetailsItem(Message message) { |
|
|
|
Widget chatDetailsItem(position) { |
|
|
|
bool isSelf = message.fromId == selfUserId; |
|
|
|
bool isSelf = messages[position].fromId == selfUserId; |
|
|
|
bool isText = message.msgType == 1; |
|
|
|
bool isText = messages[position].msgType == 1; |
|
|
|
return Container( |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
top: 32.h, |
|
|
|
top: 32.h, |
|
|
@ -416,8 +423,16 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
child: Column( |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
Text( |
|
|
|
AppUtils.timeFormatter( |
|
|
|
// position == messages.length-1 |
|
|
|
DateTime.fromMillisecondsSinceEpoch(int.parse(message.time))), |
|
|
|
// ? |
|
|
|
|
|
|
|
AppUtils.milliTimeFormatter(DateTime.fromMillisecondsSinceEpoch( |
|
|
|
|
|
|
|
int.parse(messages[position].time))) |
|
|
|
|
|
|
|
// : AppUtils.getTimeDisplay( |
|
|
|
|
|
|
|
// DateTime.fromMillisecondsSinceEpoch( |
|
|
|
|
|
|
|
// int.parse(messages[position].time)), |
|
|
|
|
|
|
|
// DateTime.fromMillisecondsSinceEpoch( |
|
|
|
|
|
|
|
// int.parse(messages[position+1].time))) |
|
|
|
|
|
|
|
, |
|
|
|
textAlign: TextAlign.center, |
|
|
|
textAlign: TextAlign.center, |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
color: Color(0xFFA29E9E), |
|
|
@ -537,15 +552,24 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
padding: EdgeInsets.only(left: 17.w, right: 39.w), |
|
|
|
padding: EdgeInsets.only(left: 17.w, right: 39.w), |
|
|
|
child: Row( |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
MImage( |
|
|
|
GestureDetector( |
|
|
|
_toUser.avatar, |
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
isCircle: true, |
|
|
|
onTap: () { |
|
|
|
height: 44.h, |
|
|
|
Navigator.of(context).pushNamed('/router/personal_page', |
|
|
|
width: 44.h, |
|
|
|
arguments: { |
|
|
|
fit: BoxFit.cover, |
|
|
|
"memberId": _toUser?.mid ?? "", |
|
|
|
errorSrc: "assets/image/default_1.webp", |
|
|
|
"inletType": 1 |
|
|
|
fadeSrc: "assets/image/default_1.webp", |
|
|
|
}); |
|
|
|
), |
|
|
|
}, |
|
|
|
|
|
|
|
child: MImage( |
|
|
|
|
|
|
|
_toUser.avatar, |
|
|
|
|
|
|
|
isCircle: true, |
|
|
|
|
|
|
|
height: 44.h, |
|
|
|
|
|
|
|
width: 44.h, |
|
|
|
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
|
|
|
errorSrc: "assets/image/default_1.webp", |
|
|
|
|
|
|
|
fadeSrc: "assets/image/default_1.webp", |
|
|
|
|
|
|
|
)), |
|
|
|
SizedBox( |
|
|
|
SizedBox( |
|
|
|
width: 12.w, |
|
|
|
width: 12.w, |
|
|
|
), |
|
|
|
), |
|
|
@ -576,7 +600,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: Text( |
|
|
|
child: Text( |
|
|
|
tex = message.content, |
|
|
|
tex = messages[position].content, |
|
|
|
textAlign: TextAlign.left, |
|
|
|
textAlign: TextAlign.left, |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
height: 1.2.h, |
|
|
|
height: 1.2.h, |
|
|
@ -686,7 +710,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
padding: EdgeInsets.only(left: 36.w, right: 16.w), |
|
|
|
padding: EdgeInsets.only(left: 36.w, right: 16.w), |
|
|
|
child: Row( |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
if (message.state == 3) |
|
|
|
if (messages[position].state == 3) |
|
|
|
Container( |
|
|
|
Container( |
|
|
|
decoration: BoxDecoration( |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.circular(100), |
|
|
|
borderRadius: BorderRadius.circular(100), |
|
|
@ -705,7 +729,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
if (message.state == 3) |
|
|
|
if (messages[position].state == 3) |
|
|
|
SizedBox( |
|
|
|
SizedBox( |
|
|
|
width: 12.w, |
|
|
|
width: 12.w, |
|
|
|
), |
|
|
|
), |
|
|
@ -736,7 +760,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: Text( |
|
|
|
child: Text( |
|
|
|
tex = message.content, |
|
|
|
tex = messages[position].content, |
|
|
|
textAlign: TextAlign.left, |
|
|
|
textAlign: TextAlign.left, |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
height: 1.2.h, |
|
|
|
height: 1.2.h, |
|
|
@ -752,20 +776,21 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
SizedBox( |
|
|
|
SizedBox( |
|
|
|
width: 12.w, |
|
|
|
width: 12.w, |
|
|
|
), |
|
|
|
), |
|
|
|
MImage( |
|
|
|
GestureDetector( |
|
|
|
userInfo?.headimg ?? "", |
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
isCircle: true, |
|
|
|
onTap: () { |
|
|
|
height: 44.h, |
|
|
|
Navigator.of(context).pushNamed('/router/personal_page', |
|
|
|
width: 44.h, |
|
|
|
arguments: {"memberId": "0", "inletType": 1}); |
|
|
|
fit: BoxFit.cover, |
|
|
|
}, |
|
|
|
errorSrc: "assets/image/default_1.webp", |
|
|
|
child: MImage( |
|
|
|
fadeSrc: "assets/image/default_1.webp", |
|
|
|
userInfo?.headimg ?? "", |
|
|
|
), |
|
|
|
isCircle: true, |
|
|
|
// Image.asset( |
|
|
|
height: 44.h, |
|
|
|
// "assets/image/fuka_zj.webp", |
|
|
|
width: 44.h, |
|
|
|
// height: 44, |
|
|
|
fit: BoxFit.cover, |
|
|
|
// width: 44, |
|
|
|
errorSrc: "assets/image/default_1.webp", |
|
|
|
// ), |
|
|
|
fadeSrc: "assets/image/default_1.webp", |
|
|
|
|
|
|
|
)), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|