show auto reply tip

opt pm msg

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-08 18:17:49 +08:00
parent b51c6b65a1
commit d2023b1750
2 changed files with 68 additions and 29 deletions

View File

@@ -35,14 +35,11 @@ class _CreateVotePageState extends State<CreateVotePage> {
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.9), color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.9),
); );
final padding = MediaQuery.paddingOf(context); final padding = MediaQuery.paddingOf(context);
final divider = [ final divider = Divider(
const SizedBox(height: 10), height: 20,
Divider( thickness: 1,
height: 1, color: theme.colorScheme.outline.withValues(alpha: 0.1),
color: theme.colorScheme.outline.withValues(alpha: 0.1), );
),
const SizedBox(height: 10),
];
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('${_controller.voteId != null ? '' : '发起'}投票'), title: Text('${_controller.voteId != null ? '' : '发起'}投票'),
@@ -74,7 +71,7 @@ class _CreateVotePageState extends State<CreateVotePage> {
inputFormatters: [LengthLimitingTextInputFormatter(32)], inputFormatters: [LengthLimitingTextInputFormatter(32)],
), ),
), ),
...divider, divider,
Obx( Obx(
() => _buildInput( () => _buildInput(
theme, theme,
@@ -85,7 +82,7 @@ class _CreateVotePageState extends State<CreateVotePage> {
inputFormatters: [LengthLimitingTextInputFormatter(100)], inputFormatters: [LengthLimitingTextInputFormatter(100)],
), ),
), ),
...divider, divider,
const SizedBox(height: 40), const SizedBox(height: 40),
Obx( Obx(
() { () {
@@ -118,7 +115,7 @@ class _CreateVotePageState extends State<CreateVotePage> {
hintText: '选项内容最多20字', hintText: '选项内容最多20字',
inputFormatters: [LengthLimitingTextInputFormatter(20)], inputFormatters: [LengthLimitingTextInputFormatter(20)],
)) ))
..addAll(divider); ..add(divider);
} }
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -188,7 +185,7 @@ class _CreateVotePageState extends State<CreateVotePage> {
], ],
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
...divider, divider,
Row( Row(
spacing: 12, spacing: 12,
children: [ children: [
@@ -238,7 +235,7 @@ class _CreateVotePageState extends State<CreateVotePage> {
), ),
], ],
), ),
...divider, divider,
const SizedBox(height: 40), const SizedBox(height: 40),
Obx(() { Obx(() {
final canCreate = _controller.canCreate.value; final canCreate = _controller.canCreate.value;

View File

@@ -19,6 +19,7 @@ import 'package:PiliPlus/utils/image_util.dart';
import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/gestures.dart';
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';
@@ -40,6 +41,13 @@ class ChatItem extends StatelessWidget {
final VoidCallback? onLongPress; final VoidCallback? onLongPress;
final bool isOwner; final bool isOwner;
// 消息来源
// enum MsgSource {
// EN_MSG_SOURCE_AUTOREPLY_BY_FOLLOWED = 8; //
// EN_MSG_SOURCE_AUTOREPLY_BY_RECEIVE_MSG = 9; //
// EN_MSG_SOURCE_AUTOREPLY_BY_KEYWORDS = 10; //
// EN_MSG_SOURCE_AUTOREPLY_BY_VOYAGE = 11; //
// };
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isPic = item.msgType == MsgType.EN_MSG_TYPE_PIC.value; // 图片 bool isPic = item.msgType == MsgType.EN_MSG_TYPE_PIC.value; // 图片
@@ -125,6 +133,22 @@ class ChatItem extends StatelessWidget {
color: theme.colorScheme.onErrorContainer, color: theme.colorScheme.onErrorContainer,
), ),
), ),
if (item.msgSource >= 8 &&
item.msgSource <= 11) ...[
Divider(
height: 10,
thickness: 1,
color: theme.colorScheme.outline
.withValues(alpha: 0.2),
),
Text(
'此条消息为自动回复',
style:
theme.textTheme.labelMedium!.copyWith(
color: theme.colorScheme.outline,
),
),
]
], ],
), ),
), ),
@@ -150,7 +174,7 @@ class ChatItem extends StatelessWidget {
case MsgType.EN_MSG_TYPE_TIP_MESSAGE: case MsgType.EN_MSG_TYPE_TIP_MESSAGE:
return msgTypeTipMessage_18(theme, content); return msgTypeTipMessage_18(theme, content);
case MsgType.EN_MSG_TYPE_TEXT: case MsgType.EN_MSG_TYPE_TEXT:
return msgTypeText_1(content: content, textColor: textColor); return msgTypeText_1(theme, content: content, textColor: textColor);
case MsgType.EN_MSG_TYPE_PIC: case MsgType.EN_MSG_TYPE_PIC:
return msgTypePic_2(context, content); return msgTypePic_2(context, content);
case MsgType.EN_MSG_TYPE_SHARE_V2: case MsgType.EN_MSG_TYPE_SHARE_V2:
@@ -588,7 +612,8 @@ class ChatItem extends StatelessWidget {
); );
} }
Widget msgTypeText_1({ Widget msgTypeText_1(
ThemeData theme, {
required dynamic content, required dynamic content,
required Color textColor, required Color textColor,
}) { }) {
@@ -606,25 +631,42 @@ class ChatItem extends StatelessWidget {
'size': e.size * 24.0, 'size': e.size * 24.0,
}; };
} }
final regex = RegExp(
[
...emojiMap.keys.map(RegExp.escape),
Constants.urlRegex.pattern,
].join('|'),
);
content['content'].splitMapJoin( content['content'].splitMapJoin(
RegExp(r"\[[^\[\]]+\]"), regex,
onMatch: (Match match) { onMatch: (Match match) {
final emojiKey = match[0]!; final matchStr = match[0]!;
final emoji = emojiMap[emojiKey]; if (matchStr.startsWith('[')) {
if (emoji != null) { final emoji = emojiMap[matchStr];
final size = emoji['size']; if (emoji != null) {
children.add( final size = emoji['size'];
WidgetSpan( children.add(
child: NetworkImgLayer( WidgetSpan(
width: size, child: NetworkImgLayer(
height: size, width: size,
src: emoji['url'], height: size,
type: ImageType.emote, src: emoji['url'],
type: ImageType.emote,
),
), ),
);
} else {
children.add(TextSpan(text: matchStr, style: style));
}
} else {
children.add(
TextSpan(
text: matchStr,
style: style.copyWith(color: theme.colorScheme.primary),
recognizer: TapGestureRecognizer()
..onTap = () => PiliScheme.routePushFromUrl(matchStr),
), ),
); );
} else {
children.add(TextSpan(text: emojiKey, style: style));
} }
return ''; return '';
}, },