聊天记录

This commit is contained in:
18631081161 2024-07-29 22:19:14 +08:00
parent 2d931437bd
commit a2a5d2813f
3 changed files with 37 additions and 18 deletions

View File

@ -47,6 +47,7 @@ class ChatModel {
if (dataEntity.code == 0) {
List<ChatInfoBean> data = (dataEntity.data as List<dynamic>).map((e) => ChatInfoBean.fromJson(e as Map<String, dynamic>)).toList();
streamController.sink.add({
'code': "getChatInfo", //
'data': data

View File

@ -11,6 +11,7 @@ import '../../beans/character_info_bean.dart';
import '../../beans/chat_info_bean.dart';
import '../../beans/send_message_bean.dart';
import '../../common/func.dart';
import '../../custom/DynamicText.dart';
import '../../custom/custom_popup.dart';
import '../../dialog/delete_dialog.dart';
import '../../dialog/memory_card_dialog.dart';
@ -87,7 +88,17 @@ class _ChatPageState extends State<ChatPage> {
_viewmodel.getChatInfo(widget.characterId);
break;
case "getChatInfo":
chatList.addAll(newData['data']);
ChatInfoBean profile;
List<ChatInfoBean> list = newData['data'].reversed.toList();
for (int i = 0; i < list.length; i++) {
if (list[i].role == 'profile') {
profile = list[i];
list.removeAt(i);
list.insert(0, profile);
break;
}
}
chatList.addAll(list);
EasyLoading.dismiss();
setState(() {});
_scrollToBottom();
@ -292,14 +303,14 @@ class _ChatPageState extends State<ChatPage> {
child: Text(
"${characterInfoBean?.characterName}",
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 10, color: Colors.white),
style: TextStyle(fontSize: 11, color: Colors.white),
),
),
SizedBox(
width: h35,
child: Text(
'${characterInfoBean?.lookCount} 聊过',
style: TextStyle(fontSize: 7, color: Colors.white),
style: TextStyle(fontSize: 9, color: Color(0xFFBDBDBD)),
),
),
],
@ -705,12 +716,10 @@ class _ChatPageState extends State<ChatPage> {
borderRadius: BorderRadius.only(
topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)),
),
child: Text(
chatList[index].content!,
style: const TextStyle(
fontSize: 14,
color: Colors.black,
),
child: DynamicText(
text: chatList[index].content!,
highlightedStyle: TextStyle(color: Color(0xFF595959), fontStyle: FontStyle.italic, fontSize: 14, height: 1.4), //
normalStyle: TextStyle(color: Colors.black, fontSize: 14, height: 1.4), //
),
),
),

View File

@ -11,6 +11,7 @@ import '../../beans/character_info_bean.dart';
import '../../beans/chat_info_bean.dart';
import '../../beans/send_message_bean.dart';
import '../../common/func.dart';
import '../../custom/DynamicText.dart';
import '../../custom/custom_popup.dart';
import '../../dialog/delete_dialog.dart';
import '../../dialog/memory_card_dialog.dart';
@ -76,7 +77,17 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
_viewmodel.getChatInfo(widget.characterId);
break;
case "getChatInfo":
chatList.addAll(newData['data']);
ChatInfoBean profile;
List<ChatInfoBean> list = newData['data'].reversed.toList();
for (int i = 0; i < list.length; i++) {
if (list[i].role == 'profile') {
profile = list[i];
list.removeAt(i);
list.insert(0, profile);
break;
}
}
chatList.addAll(list);
setState(() {});
_scrollToBottom();
EasyLoading.dismiss();
@ -276,14 +287,14 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
child: Text(
"${characterInfoBean.characterName}",
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 10, color: Colors.white),
style: TextStyle(fontSize: 11, color: Colors.white),
),
),
SizedBox(
width: h35,
child: Text(
'${characterInfoBean.lookCount} 聊过',
style: TextStyle(fontSize: 7, color: Colors.white),
style: TextStyle(fontSize: 9, color: Color(0xFFBDBDBD)),
),
),
],
@ -706,12 +717,10 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
borderRadius: BorderRadius.only(
topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)),
),
child: Text(
chatList[index].content!,
style: const TextStyle(
fontSize: 14,
color: Colors.black,
),
child: DynamicText(
text: chatList[index].content!,
highlightedStyle: TextStyle(color: Color(0xFF595959), fontStyle: FontStyle.italic, fontSize: 14, height: 1.4), //
normalStyle: TextStyle(color: Colors.black, fontSize: 14, height: 1.4), //
),
),
),