fix: 消息页面夜间模式异常 issues #309 | 包含撤回消息时显示异常

This commit is contained in:
guozhigq
2023-12-19 07:47:18 +08:00
parent 6dd1360a76
commit ada1aa5d1d
4 changed files with 108 additions and 81 deletions

View File

@ -70,10 +70,14 @@ class MsgHttp {
}); });
var res = await Request().get(Api.sessionMsg, data: params); var res = await Request().get(Api.sessionMsg, data: params);
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
try {
return { return {
'status': true, 'status': true,
'data': SessionMsgDataModel.fromJson(res.data['data']), 'data': SessionMsgDataModel.fromJson(res.data['data']),
}; };
} catch (err) {
print(err);
}
} else { } else {
return { return {
'status': false, 'status': false,

View File

@ -199,7 +199,7 @@ class MessageItem {
int? receiverType; int? receiverType;
int? receiverId; int? receiverId;
int? msgType; int? msgType;
Map? content; dynamic content;
int? msgSeqno; int? msgSeqno;
int? timestamp; int? timestamp;
List? atUids; List? atUids;
@ -212,7 +212,7 @@ class MessageItem {
senderUid = json['sender_uid']; senderUid = json['sender_uid'];
receiverType = json['receiver_type']; receiverType = json['receiver_type'];
receiverId = json['receiver_id']; receiverId = json['receiver_id'];
// 1 文本 2 图片 18 系统提示 10 系统通知 // 1 文本 2 图片 18 系统提示 10 系统通知 5 撤回的消息
msgType = json['msg_type']; msgType = json['msg_type'];
content = jsonDecode(json['content']); content = jsonDecode(json['content']);
msgSeqno = json['msg_seqno']; msgSeqno = json['msg_seqno'];

View File

@ -93,6 +93,9 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
future: _futureBuilderFuture, future: _futureBuilderFuture,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == null) {
return const SizedBox();
}
Map data = snapshot.data as Map; Map data = snapshot.data as Map;
if (data['status']) { if (data['status']) {
List messageList = _whisperDetailController.messageList; List messageList = _whisperDetailController.messageList;
@ -138,7 +141,6 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
bottom: MediaQuery.of(context).padding.bottom, bottom: MediaQuery.of(context).padding.bottom,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white,
border: Border( border: Border(
top: BorderSide( top: BorderSide(
width: 4, width: 4,

View File

@ -15,21 +15,24 @@ class ChatItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isOwner = item.senderUid == 17340771; bool isOwner = item.senderUid == 17340771;
bool isPic = item.msgType == 2; bool isPic = item.msgType == 2; // 图片
bool isText = item.msgType == 1; bool isText = item.msgType == 1; // 文本
bool isAchive = item.msgType == 11; bool isAchive = item.msgType == 11; // 投稿
bool isArticle = item.msgType == 12; bool isArticle = item.msgType == 12; // 专栏
bool isRevoke = item.msgType == 5; // 撤回消息
bool isSystem = bool isSystem =
item.msgType == 18 || item.msgType == 10 || item.msgType == 13; item.msgType == 18 || item.msgType == 10 || item.msgType == 13;
int msgType = item.msgType; int msgType = item.msgType;
Map content = item.content ?? ''; dynamic content = item.content ?? '';
return isSystem return isSystem
? (msgType == 10 ? (msgType == 10
? SystemNotice(item: item) ? SystemNotice(item: item)
: msgType == 13 : msgType == 13
? SystemNotice2(item: item) ? SystemNotice2(item: item)
: const SizedBox()) : const SizedBox())
: isRevoke
? const SizedBox()
: Row( : Row(
children: [ children: [
if (!isOwner) const SizedBox(width: 12), if (!isOwner) const SizedBox(width: 12),
@ -66,7 +69,9 @@ class ChatItem extends StatelessWidget {
content['content'], content['content'],
style: TextStyle( style: TextStyle(
color: isOwner color: isOwner
? Theme.of(context).colorScheme.onPrimary ? Theme.of(context)
.colorScheme
.onPrimary
: Theme.of(context) : Theme.of(context)
.colorScheme .colorScheme
.onSecondaryContainer), .onSecondaryContainer),
@ -74,15 +79,22 @@ class ChatItem extends StatelessWidget {
: isPic : isPic
? NetworkImgLayer( ? NetworkImgLayer(
width: 220, width: 220,
height: height: 220 *
220 * content['height'] / content['width'], content['height'] /
content['width'],
src: content['url'], src: content['url'],
) )
: const SizedBox(), : const SizedBox(),
SizedBox(height: isPic ? 7 : 2), SizedBox(height: isPic ? 7 : 2),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text( Text(
Utils.dateFormat(item.timestamp), Utils.dateFormat(item.timestamp),
style: Theme.of(context).textTheme.labelSmall!.copyWith( style: Theme.of(context)
.textTheme
.labelSmall!
.copyWith(
color: isOwner color: isOwner
? Theme.of(context) ? Theme.of(context)
.colorScheme .colorScheme
@ -92,6 +104,15 @@ class ChatItem extends StatelessWidget {
.colorScheme .colorScheme
.onSecondaryContainer .onSecondaryContainer
.withOpacity(0.8)), .withOpacity(0.8)),
),
item.msgStatus == 1
? Text(
' 已撤回',
style:
Theme.of(context).textTheme.labelSmall!,
)
: const SizedBox()
],
) )
], ],
), ),