💄 Make attachment in chat aligned with message

This commit is contained in:
LittleSheep 2025-02-23 14:35:51 +08:00
parent 81a79f9476
commit 6d0145c335

View File

@ -109,11 +109,13 @@ class ChatMessage extends StatelessWidget {
onTap: () { onTap: () {
if (user == null) return; if (user == null) return;
showPopover( showPopover(
backgroundColor: Theme.of(context).colorScheme.surface, backgroundColor:
Theme.of(context).colorScheme.surface,
context: context, context: context,
transition: PopoverTransition.other, transition: PopoverTransition.other,
bodyBuilder: (context) => SizedBox( bodyBuilder: (context) => SizedBox(
width: math.min(400, MediaQuery.of(context).size.width - 10), width: math.min(
400, MediaQuery.of(context).size.width - 10),
child: AccountPopoverCard( child: AccountPopoverCard(
data: user, data: user,
), ),
@ -144,11 +146,14 @@ class ChatMessage extends StatelessWidget {
radius: 12, radius: 12,
).padding(right: 8), ).padding(right: 8),
Text( Text(
(data.sender.nick?.isNotEmpty ?? false) ? data.sender.nick! : user?.nick ?? 'unknown', (data.sender.nick?.isNotEmpty ?? false)
? data.sender.nick!
: user?.nick ?? 'unknown',
).bold(), ).bold(),
const Gap(8), const Gap(8),
Text( Text(
dateFormatter.format(data.createdAt.toLocal()), dateFormatter
.format(data.createdAt.toLocal()),
).fontSize(13), ).fontSize(13),
], ],
).height(21), ).height(21),
@ -159,7 +164,8 @@ class ChatMessage extends StatelessWidget {
maxWidth: 480, maxWidth: 480,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(8)), borderRadius:
const BorderRadius.all(Radius.circular(8)),
border: Border.all( border: Border.all(
color: Theme.of(context).dividerColor, color: Theme.of(context).dividerColor,
width: 1, width: 1,
@ -207,9 +213,12 @@ class ChatMessage extends StatelessWidget {
maxHeight: 560, maxHeight: 560,
maxWidth: 480, maxWidth: 480,
minWidth: 480, minWidth: 480,
padding: padding.copyWith(top: 8), padding: padding.copyWith(top: 8, left: 48 + padding.left),
), ),
if (!hasMerged && !isCompact) const Gap(12) else if (!isCompact) const Gap(8), if (!hasMerged && !isCompact)
const Gap(12)
else if (!isCompact)
const Gap(8),
], ],
), ),
), ),
@ -223,7 +232,8 @@ class _ChatMessageText extends StatelessWidget {
final Function(SnChatMessage)? onEdit; final Function(SnChatMessage)? onEdit;
final Function(SnChatMessage)? onDelete; final Function(SnChatMessage)? onDelete;
const _ChatMessageText({required this.data, this.onReply, this.onEdit, this.onDelete}); const _ChatMessageText(
{required this.data, this.onReply, this.onEdit, this.onDelete});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -237,7 +247,8 @@ class _ChatMessageText extends StatelessWidget {
children: [ children: [
SelectionArea( SelectionArea(
contextMenuBuilder: (context, editableTextState) { contextMenuBuilder: (context, editableTextState) {
final List<ContextMenuButtonItem> items = editableTextState.contextMenuButtonItems; final List<ContextMenuButtonItem> items =
editableTextState.contextMenuButtonItems;
if (onReply != null) { if (onReply != null) {
items.insert( items.insert(