diff --git a/lib/tools/chat/chat_model.dart b/lib/tools/chat/chat_model.dart index 9f12cf8..fbabc2a 100644 --- a/lib/tools/chat/chat_model.dart +++ b/lib/tools/chat/chat_model.dart @@ -47,6 +47,7 @@ class ChatModel { if (dataEntity.code == 0) { List data = (dataEntity.data as List).map((e) => ChatInfoBean.fromJson(e as Map)).toList(); + streamController.sink.add({ 'code': "getChatInfo", //有数据 'data': data diff --git a/lib/tools/chat/chat_page.dart b/lib/tools/chat/chat_page.dart index ed7832e..4dac89a 100644 --- a/lib/tools/chat/chat_page.dart +++ b/lib/tools/chat/chat_page.dart @@ -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 { _viewmodel.getChatInfo(widget.characterId); break; case "getChatInfo": - chatList.addAll(newData['data']); + ChatInfoBean profile; + List 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 { 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 { 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), // 正常颜色 ), ), ), diff --git a/lib/tools/home/home_chat_page.dart b/lib/tools/home/home_chat_page.dart index fef1d60..f26f1a7 100644 --- a/lib/tools/home/home_chat_page.dart +++ b/lib/tools/home/home_chat_page.dart @@ -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 with AutomaticKeepAliveClie _viewmodel.getChatInfo(widget.characterId); break; case "getChatInfo": - chatList.addAll(newData['data']); + ChatInfoBean profile; + List 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 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 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), // 正常颜色 ), ), ),