fix: 消息页面夜间模式异常 issues #309 | 包含撤回消息时显示异常
This commit is contained in:
@ -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) {
|
||||||
return {
|
try {
|
||||||
'status': true,
|
return {
|
||||||
'data': SessionMsgDataModel.fromJson(res.data['data']),
|
'status': true,
|
||||||
};
|
'data': SessionMsgDataModel.fromJson(res.data['data']),
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
print(err);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
'status': false,
|
'status': false,
|
||||||
|
|||||||
@ -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'];
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -15,91 +15,112 @@ 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())
|
||||||
: Row(
|
: isRevoke
|
||||||
children: [
|
? const SizedBox()
|
||||||
if (!isOwner) const SizedBox(width: 12),
|
: Row(
|
||||||
if (isOwner) const Spacer(),
|
children: [
|
||||||
Container(
|
if (!isOwner) const SizedBox(width: 12),
|
||||||
constraints: const BoxConstraints(
|
if (isOwner) const Spacer(),
|
||||||
maxWidth: 300.0, // 设置最大宽度为200.0
|
Container(
|
||||||
),
|
constraints: const BoxConstraints(
|
||||||
decoration: BoxDecoration(
|
maxWidth: 300.0, // 设置最大宽度为200.0
|
||||||
color: isOwner
|
),
|
||||||
? Theme.of(context).colorScheme.primary
|
decoration: BoxDecoration(
|
||||||
: Theme.of(context).colorScheme.secondaryContainer,
|
color: isOwner
|
||||||
borderRadius: BorderRadius.only(
|
? Theme.of(context).colorScheme.primary
|
||||||
topLeft: const Radius.circular(16),
|
: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
topRight: const Radius.circular(16),
|
borderRadius: BorderRadius.only(
|
||||||
bottomLeft: Radius.circular(isOwner ? 16 : 6),
|
topLeft: const Radius.circular(16),
|
||||||
bottomRight: Radius.circular(isOwner ? 6 : 16),
|
topRight: const Radius.circular(16),
|
||||||
),
|
bottomLeft: Radius.circular(isOwner ? 16 : 6),
|
||||||
),
|
bottomRight: Radius.circular(isOwner ? 6 : 16),
|
||||||
margin: const EdgeInsets.only(top: 12),
|
),
|
||||||
padding: EdgeInsets.only(
|
),
|
||||||
top: 8,
|
margin: const EdgeInsets.only(top: 12),
|
||||||
bottom: 6,
|
padding: EdgeInsets.only(
|
||||||
left: isPic ? 8 : 12,
|
top: 8,
|
||||||
right: isPic ? 8 : 12,
|
bottom: 6,
|
||||||
),
|
left: isPic ? 8 : 12,
|
||||||
child: Column(
|
right: isPic ? 8 : 12,
|
||||||
crossAxisAlignment: isOwner
|
),
|
||||||
? CrossAxisAlignment.end
|
child: Column(
|
||||||
: CrossAxisAlignment.start,
|
crossAxisAlignment: isOwner
|
||||||
children: [
|
? CrossAxisAlignment.end
|
||||||
isText
|
: CrossAxisAlignment.start,
|
||||||
? Text(
|
children: [
|
||||||
content['content'],
|
isText
|
||||||
style: TextStyle(
|
? Text(
|
||||||
color: isOwner
|
content['content'],
|
||||||
? Theme.of(context).colorScheme.onPrimary
|
style: TextStyle(
|
||||||
: Theme.of(context)
|
color: isOwner
|
||||||
.colorScheme
|
? Theme.of(context)
|
||||||
.onSecondaryContainer),
|
.colorScheme
|
||||||
)
|
.onPrimary
|
||||||
: isPic
|
: Theme.of(context)
|
||||||
? NetworkImgLayer(
|
.colorScheme
|
||||||
width: 220,
|
.onSecondaryContainer),
|
||||||
height:
|
|
||||||
220 * content['height'] / content['width'],
|
|
||||||
src: content['url'],
|
|
||||||
)
|
)
|
||||||
: const SizedBox(),
|
: isPic
|
||||||
SizedBox(height: isPic ? 7 : 2),
|
? NetworkImgLayer(
|
||||||
Text(
|
width: 220,
|
||||||
Utils.dateFormat(item.timestamp),
|
height: 220 *
|
||||||
style: Theme.of(context).textTheme.labelSmall!.copyWith(
|
content['height'] /
|
||||||
color: isOwner
|
content['width'],
|
||||||
? Theme.of(context)
|
src: content['url'],
|
||||||
.colorScheme
|
)
|
||||||
.onPrimary
|
: const SizedBox(),
|
||||||
.withOpacity(0.8)
|
SizedBox(height: isPic ? 7 : 2),
|
||||||
: Theme.of(context)
|
Row(
|
||||||
.colorScheme
|
mainAxisSize: MainAxisSize.min,
|
||||||
.onSecondaryContainer
|
children: [
|
||||||
.withOpacity(0.8)),
|
Text(
|
||||||
)
|
Utils.dateFormat(item.timestamp),
|
||||||
],
|
style: Theme.of(context)
|
||||||
),
|
.textTheme
|
||||||
),
|
.labelSmall!
|
||||||
if (!isOwner) const Spacer(),
|
.copyWith(
|
||||||
if (isOwner) const SizedBox(width: 12),
|
color: isOwner
|
||||||
],
|
? Theme.of(context)
|
||||||
);
|
.colorScheme
|
||||||
|
.onPrimary
|
||||||
|
.withOpacity(0.8)
|
||||||
|
: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSecondaryContainer
|
||||||
|
.withOpacity(0.8)),
|
||||||
|
),
|
||||||
|
item.msgStatus == 1
|
||||||
|
? Text(
|
||||||
|
' 已撤回',
|
||||||
|
style:
|
||||||
|
Theme.of(context).textTheme.labelSmall!,
|
||||||
|
)
|
||||||
|
: const SizedBox()
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!isOwner) const Spacer(),
|
||||||
|
if (isOwner) const SizedBox(width: 12),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user