fix: magType value

This commit is contained in:
guozhigq
2024-01-31 23:03:45 +08:00
parent a86fe76e59
commit 8a2c023343

View File

@ -5,7 +5,6 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/utils/utils.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
@ -53,12 +52,13 @@ class ChatItem extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isOwner = bool isOwner =
item.senderUid == GStrorage.userInfo.get('userInfoCache').mid; item.senderUid == GStrorage.userInfo.get('userInfoCache').mid;
bool isPic = item.msgType == MsgType.pic; // 图片
bool isText = item.msgType == MsgType.text; // 文本 bool isPic = item.msgType == MsgType.pic.value; // 图片
bool isText = item.msgType == MsgType.text.value; // 文本
// bool isArchive = item.msgType == 11; // 投稿 // bool isArchive = item.msgType == 11; // 投稿
// bool isArticle = item.msgType == 12; // 专栏 // bool isArticle = item.msgType == 12; // 专栏
bool isRevoke = item.msgType == MsgType.revoke; // 撤回消息 bool isRevoke = item.msgType == MsgType.revoke.value; // 撤回消息
bool isShareV2 = item.msgType == MsgType.share_v2; bool isShareV2 = item.msgType == MsgType.share_v2.value;
bool isSystem = bool isSystem =
item.msgType == 18 || item.msgType == 10 || item.msgType == 13; item.msgType == 18 || item.msgType == 10 || item.msgType == 13;
dynamic content = item.content ?? ''; dynamic content = item.content ?? '';
@ -72,7 +72,7 @@ class ChatItem extends StatelessWidget {
var text = content['content']; var text = content['content'];
if (e_infos != null) { if (e_infos != null) {
final List<InlineSpan> children = []; final List<InlineSpan> children = [];
Map<String,String> emojiMap = {}; Map<String, String> emojiMap = {};
for (var e in e_infos!) { for (var e in e_infos!) {
emojiMap[e['text']] = e['url']; emojiMap[e['text']] = e['url'];
} }
@ -83,18 +83,22 @@ class ChatItem extends StatelessWidget {
if (emojiMap.containsKey(emojiKey)) { if (emojiMap.containsKey(emojiKey)) {
children.add(WidgetSpan( children.add(WidgetSpan(
child: NetworkImgLayer( child: NetworkImgLayer(
width: 18, height: 18, width: 18,
src: emojiMap[emojiKey]!,), height: 18,
src: emojiMap[emojiKey]!,
),
)); ));
} }
return ''; return '';
}, },
onNonMatch: (String text) { onNonMatch: (String text) {
children.add(TextSpan(text: text, style: TextStyle( children.add(TextSpan(
color: textColor(context), text: text,
letterSpacing: 0.6, style: TextStyle(
height: 1.5, color: textColor(context),
))); letterSpacing: 0.6,
height: 1.5,
)));
return ''; return '';
}, },
); );
@ -123,11 +127,13 @@ class ChatItem extends StatelessWidget {
return SystemNotice2(item: item); return SystemNotice2(item: item);
case MsgType.notify_text: case MsgType.notify_text:
return Text( return Text(
jsonDecode(content['content']).map((m) => m['text'] as String).join("\n"), jsonDecode(content['content'])
.map((m) => m['text'] as String)
.join("\n"),
style: TextStyle( style: TextStyle(
letterSpacing: 0.6, letterSpacing: 0.6,
height: 5, height: 5,
color: Theme.of(context).colorScheme.outline.withOpacity(0.8) color: Theme.of(context).colorScheme.outline.withOpacity(0.8),
), ),
); );
case MsgType.text: case MsgType.text:
@ -166,9 +172,11 @@ class ChatItem extends StatelessWidget {
Text( Text(
content['title'], content['title'],
style: TextStyle( style: TextStyle(
letterSpacing: 0.6, letterSpacing: 0.6,
height: 1.5, height: 1.5,
color: textColor(context), fontWeight: FontWeight.bold), color: textColor(context),
fontWeight: FontWeight.bold,
),
), ),
const SizedBox(height: 1), const SizedBox(height: 1),
Text( Text(
@ -186,9 +194,11 @@ class ChatItem extends StatelessWidget {
return Text( return Text(
content['content'] ?? content.toString(), content['content'] ?? content.toString(),
style: TextStyle( style: TextStyle(
letterSpacing: 0.6, letterSpacing: 0.6,
height: 1.5, height: 1.5,
color: textColor(context), fontWeight: FontWeight.bold), color: textColor(context),
fontWeight: FontWeight.bold,
),
); );
} }
} }