💄 Hovering actions
This commit is contained in:
@@ -160,53 +160,85 @@ class MessageItem extends HookConsumerWidget {
|
|||||||
? Theme.of(context).colorScheme.primaryContainer.withOpacity(0.8)
|
? Theme.of(context).colorScheme.primaryContainer.withOpacity(0.8)
|
||||||
: Colors.transparent;
|
: Colors.transparent;
|
||||||
|
|
||||||
return InkWell(
|
final isHovered = useState(false);
|
||||||
mouseCursor: MouseCursor.defer,
|
|
||||||
focusColor: Colors.transparent,
|
return Stack(
|
||||||
onLongPress: showActionMenu,
|
clipBehavior: Clip.none,
|
||||||
onSecondaryTap: showActionMenu,
|
children: [
|
||||||
onTap: () {
|
InkWell(
|
||||||
// Jump to related message
|
mouseCursor: MouseCursor.defer,
|
||||||
if (['messages.update', 'messages.delete'].contains(message.type) &&
|
focusColor: Colors.transparent,
|
||||||
message.meta['message_id'] is String &&
|
onLongPress: showActionMenu,
|
||||||
message.meta['message_id'] != null) {
|
onSecondaryTap: showActionMenu,
|
||||||
onJump(message.meta['message_id']);
|
onTap: () {
|
||||||
}
|
// Jump to related message
|
||||||
},
|
if (['messages.update', 'messages.delete'].contains(message.type) &&
|
||||||
child: AnimatedContainer(
|
message.meta['message_id'] is String &&
|
||||||
curve: Curves.easeInOut,
|
message.meta['message_id'] != null) {
|
||||||
duration: const Duration(milliseconds: kFlashDuration),
|
onJump(message.meta['message_id']);
|
||||||
decoration: BoxDecoration(color: flashColor),
|
}
|
||||||
child: switch (settings.messageDisplayStyle) {
|
},
|
||||||
'compact' => MessageItemDisplayIRC(
|
child: Container(
|
||||||
message: message,
|
width: double.infinity,
|
||||||
isCurrentUser: isCurrentUser,
|
child: MouseRegion(
|
||||||
progress: progress,
|
onEnter: (_) => isHovered.value = true,
|
||||||
showAvatar: showAvatar,
|
onExit: (_) => isHovered.value = false,
|
||||||
onJump: onJump,
|
child: AnimatedContainer(
|
||||||
translatedText: translatedText.value,
|
curve: Curves.easeInOut,
|
||||||
translating: translating.value,
|
duration: const Duration(milliseconds: kFlashDuration),
|
||||||
|
decoration: BoxDecoration(color: flashColor),
|
||||||
|
child: switch (settings.messageDisplayStyle) {
|
||||||
|
'compact' => MessageItemDisplayIRC(
|
||||||
|
message: message,
|
||||||
|
isCurrentUser: isCurrentUser,
|
||||||
|
progress: progress,
|
||||||
|
showAvatar: showAvatar,
|
||||||
|
onJump: onJump,
|
||||||
|
translatedText: translatedText.value,
|
||||||
|
translating: translating.value,
|
||||||
|
),
|
||||||
|
'column' => MessageItemDisplayDiscord(
|
||||||
|
message: message,
|
||||||
|
isCurrentUser: isCurrentUser,
|
||||||
|
progress: progress,
|
||||||
|
showAvatar: showAvatar,
|
||||||
|
onJump: onJump,
|
||||||
|
translatedText: translatedText.value,
|
||||||
|
translating: translating.value,
|
||||||
|
),
|
||||||
|
_ => MessageItemDisplayBubble(
|
||||||
|
message: message,
|
||||||
|
isCurrentUser: isCurrentUser,
|
||||||
|
progress: progress,
|
||||||
|
showAvatar: showAvatar,
|
||||||
|
onJump: onJump,
|
||||||
|
translatedText: translatedText.value,
|
||||||
|
translating: translating.value,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
'column' => MessageItemDisplayDiscord(
|
),
|
||||||
message: message,
|
if (isHovered.value && !isMobile)
|
||||||
isCurrentUser: isCurrentUser,
|
Positioned(
|
||||||
progress: progress,
|
top: -15,
|
||||||
showAvatar: showAvatar,
|
right: 15,
|
||||||
onJump: onJump,
|
child: MouseRegion(
|
||||||
translatedText: translatedText.value,
|
onEnter: (_) => isHovered.value = true,
|
||||||
translating: translating.value,
|
onExit: (_) => isHovered.value = false,
|
||||||
|
child: MessageHoverActionMenu(
|
||||||
|
isCurrentUser: isCurrentUser,
|
||||||
|
onAction: onAction,
|
||||||
|
translatableLanguage: translatableLanguage,
|
||||||
|
translating: translating.value,
|
||||||
|
translatedText: translatedText.value,
|
||||||
|
translate: translate,
|
||||||
|
remoteMessage: remoteMessage,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
_ => MessageItemDisplayBubble(
|
],
|
||||||
message: message,
|
|
||||||
isCurrentUser: isCurrentUser,
|
|
||||||
progress: progress,
|
|
||||||
showAvatar: showAvatar,
|
|
||||||
onJump: onJump,
|
|
||||||
translatedText: translatedText.value,
|
|
||||||
translating: translating.value,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,6 +349,88 @@ class MessageActionSheet extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MessageHoverActionMenu extends StatelessWidget {
|
||||||
|
final bool isCurrentUser;
|
||||||
|
final Function(String action)? onAction;
|
||||||
|
final bool translatableLanguage;
|
||||||
|
final bool translating;
|
||||||
|
final String? translatedText;
|
||||||
|
final VoidCallback translate;
|
||||||
|
final dynamic remoteMessage;
|
||||||
|
|
||||||
|
const MessageHoverActionMenu({
|
||||||
|
super.key,
|
||||||
|
required this.isCurrentUser,
|
||||||
|
required this.onAction,
|
||||||
|
required this.translatableLanguage,
|
||||||
|
required this.translating,
|
||||||
|
required this.translatedText,
|
||||||
|
required this.translate,
|
||||||
|
required this.remoteMessage,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.1),
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (isCurrentUser)
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Symbols.edit, size: 16),
|
||||||
|
onPressed: () => onAction?.call(MessageItemAction.edit),
|
||||||
|
tooltip: 'edit'.tr(),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
|
||||||
|
),
|
||||||
|
if (isCurrentUser)
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Symbols.delete, size: 16),
|
||||||
|
onPressed: () => onAction?.call(MessageItemAction.delete),
|
||||||
|
tooltip: 'delete'.tr(),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Symbols.reply, size: 16),
|
||||||
|
onPressed: () => onAction?.call(MessageItemAction.reply),
|
||||||
|
tooltip: 'reply'.tr(),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Symbols.forward, size: 16),
|
||||||
|
onPressed: () => onAction?.call(MessageItemAction.forward),
|
||||||
|
tooltip: 'forward'.tr(),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
|
||||||
|
),
|
||||||
|
if (translatableLanguage)
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Symbols.translate, size: 16),
|
||||||
|
onPressed: translate,
|
||||||
|
tooltip:
|
||||||
|
translatedText == null ? 'translate'.tr() : 'translated'.tr(),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class MessageItemDisplayBubble extends HookConsumerWidget {
|
class MessageItemDisplayBubble extends HookConsumerWidget {
|
||||||
final LocalChatMessage message;
|
final LocalChatMessage message;
|
||||||
final bool isCurrentUser;
|
final bool isCurrentUser;
|
||||||
|
Reference in New Issue
Block a user