聊天记录

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) { if (dataEntity.code == 0) {
List<ChatInfoBean> data = (dataEntity.data as List<dynamic>).map((e) => ChatInfoBean.fromJson(e as Map<String, dynamic>)).toList(); List<ChatInfoBean> data = (dataEntity.data as List<dynamic>).map((e) => ChatInfoBean.fromJson(e as Map<String, dynamic>)).toList();
streamController.sink.add({ streamController.sink.add({
'code': "getChatInfo", // 'code': "getChatInfo", //
'data': data 'data': data

View File

@ -11,6 +11,7 @@ import '../../beans/character_info_bean.dart';
import '../../beans/chat_info_bean.dart'; import '../../beans/chat_info_bean.dart';
import '../../beans/send_message_bean.dart'; import '../../beans/send_message_bean.dart';
import '../../common/func.dart'; import '../../common/func.dart';
import '../../custom/DynamicText.dart';
import '../../custom/custom_popup.dart'; import '../../custom/custom_popup.dart';
import '../../dialog/delete_dialog.dart'; import '../../dialog/delete_dialog.dart';
import '../../dialog/memory_card_dialog.dart'; import '../../dialog/memory_card_dialog.dart';
@ -87,7 +88,17 @@ class _ChatPageState extends State<ChatPage> {
_viewmodel.getChatInfo(widget.characterId); _viewmodel.getChatInfo(widget.characterId);
break; break;
case "getChatInfo": 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(); EasyLoading.dismiss();
setState(() {}); setState(() {});
_scrollToBottom(); _scrollToBottom();
@ -292,14 +303,14 @@ class _ChatPageState extends State<ChatPage> {
child: Text( child: Text(
"${characterInfoBean?.characterName}", "${characterInfoBean?.characterName}",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 10, color: Colors.white), style: TextStyle(fontSize: 11, color: Colors.white),
), ),
), ),
SizedBox( SizedBox(
width: h35, width: h35,
child: Text( child: Text(
'${characterInfoBean?.lookCount} 聊过', '${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( borderRadius: BorderRadius.only(
topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)), topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)),
), ),
child: Text( child: DynamicText(
chatList[index].content!, text: chatList[index].content!,
style: const TextStyle( highlightedStyle: TextStyle(color: Color(0xFF595959), fontStyle: FontStyle.italic, fontSize: 14, height: 1.4), //
fontSize: 14, normalStyle: TextStyle(color: Colors.black, fontSize: 14, height: 1.4), //
color: Colors.black,
),
), ),
), ),
), ),

View File

@ -11,6 +11,7 @@ import '../../beans/character_info_bean.dart';
import '../../beans/chat_info_bean.dart'; import '../../beans/chat_info_bean.dart';
import '../../beans/send_message_bean.dart'; import '../../beans/send_message_bean.dart';
import '../../common/func.dart'; import '../../common/func.dart';
import '../../custom/DynamicText.dart';
import '../../custom/custom_popup.dart'; import '../../custom/custom_popup.dart';
import '../../dialog/delete_dialog.dart'; import '../../dialog/delete_dialog.dart';
import '../../dialog/memory_card_dialog.dart'; import '../../dialog/memory_card_dialog.dart';
@ -76,7 +77,17 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
_viewmodel.getChatInfo(widget.characterId); _viewmodel.getChatInfo(widget.characterId);
break; break;
case "getChatInfo": 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(() {}); setState(() {});
_scrollToBottom(); _scrollToBottom();
EasyLoading.dismiss(); EasyLoading.dismiss();
@ -276,14 +287,14 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
child: Text( child: Text(
"${characterInfoBean.characterName}", "${characterInfoBean.characterName}",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 10, color: Colors.white), style: TextStyle(fontSize: 11, color: Colors.white),
), ),
), ),
SizedBox( SizedBox(
width: h35, width: h35,
child: Text( child: Text(
'${characterInfoBean.lookCount} 聊过', '${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( borderRadius: BorderRadius.only(
topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)), topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)),
), ),
child: Text( child: DynamicText(
chatList[index].content!, text: chatList[index].content!,
style: const TextStyle( highlightedStyle: TextStyle(color: Color(0xFF595959), fontStyle: FontStyle.italic, fontSize: 14, height: 1.4), //
fontSize: 14, normalStyle: TextStyle(color: Colors.black, fontSize: 14, height: 1.4), //
color: Colors.black,
),
), ),
), ),
), ),