Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add long-press highlight overlay for comments

ashilkn4e3812b89134
diff --git a/mobile/apps/photos/lib/ui/social/widgets/comment_actions_popup.dart b/mobile/apps/photos/lib/ui/social/widgets/comment_actions_popup.dart
new file mode 100644
index 0000000000..6f8a83b84c
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/social/widgets/comment_actions_popup.dart
@@ -0,0 +1,117 @@
+import "package:flutter/material.dart";
+import "package:photos/theme/ente_theme.dart";
+
+class CommentActionsPopup extends StatelessWidget {
+ final bool isLiked;
+ final VoidCallback onLikeTap;
+ final VoidCallback onReplyTap;
+
+ const CommentActionsPopup({
+ required this.isLiked,
+ required this.onLikeTap,
+ required this.onReplyTap,
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
+ final backgroundColor = isDarkMode ? const Color(0xFF1C1C1E) : Colors.white;
+
+ return Material(
+ color: Colors.transparent,
+ child: Container(
+ decoration: BoxDecoration(
+ color: backgroundColor,
+ borderRadius: BorderRadius.circular(12),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.15),
+ blurRadius: 16,
+ offset: const Offset(0, 4),
+ ),
+ ],
+ ),
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(12),
+ child: IntrinsicWidth(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ _ActionItem(
+ icon: isLiked ? Icons.favorite : Icons.favorite_border,
+ iconColor: isLiked ? const Color(0xFFE25454) : null,
+ label: "Like",
+ onTap: onLikeTap,
+ textStyle: textTheme.body,
+ defaultIconColor: colorScheme.textBase,
+ ),
+ Divider(
+ height: 1,
+ thickness: 1,
+ color: colorScheme.strokeFaint,
+ ),
+ _ActionItem(
+ icon: Icons.reply,
+ label: "Reply",
+ onTap: onReplyTap,
+ textStyle: textTheme.body,
+ defaultIconColor: colorScheme.textBase,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _ActionItem extends StatelessWidget {
+ final IconData icon;
+ final Color? iconColor;
+ final String label;
+ final VoidCallback onTap;
+ final TextStyle textStyle;
+ final Color defaultIconColor;
+
+ const _ActionItem({
+ required this.icon,
+ this.iconColor,
+ required this.label,
+ required this.onTap,
+ required this.textStyle,
+ required this.defaultIconColor,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ return InkWell(
+ onTap: onTap,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(
+ icon,
+ size: 20,
+ color: iconColor ?? defaultIconColor,
+ ),
+ const SizedBox(width: 12),
+ Text(
+ label,
+ style: textStyle.copyWith(
+ color: defaultIconColor,
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart
index 3db907745c..f481b64dee 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart
@@ -8,6 +8,7 @@ import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/sharing/user_avator_widget.dart";
import "package:photos/ui/social/widgets/comment_actions_capsule.dart";
+import "package:photos/ui/social/widgets/comment_actions_popup.dart";
import "package:photos/utils/social/relative_time_formatter.dart";
class CommentBubbleWidget extends StatefulWidget {
@@ -45,6 +46,10 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget> {
bool _isLoadingParent = false;
bool _isLoadingReactions = false;
+ final OverlayPortalController _overlayController = OverlayPortalController();
+ final LayerLink _layerLink = LayerLink();
+ final GlobalKey _contentKey = GlobalKey();
+
@override
void initState() {
super.initState();
@@ -94,13 +99,122 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget> {
if (mounted) setState(() {});
}
+ void _showHighlight() {
+ _overlayController.show();
+ }
+
+ void _hideHighlight() {
+ _overlayController.hide();
+ }
+
@override
Widget build(BuildContext context) {
+ return CompositedTransformTarget(
+ link: _layerLink,
+ child: OverlayPortal(
+ controller: _overlayController,
+ overlayChildBuilder: _buildOverlayContent,
+ child: GestureDetector(
+ onLongPress: _showHighlight,
+ child: KeyedSubtree(
+ key: _contentKey,
+ child: _buildCommentContent(showActionsCapsule: true),
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildOverlayContent(BuildContext context) {
+ // Get original widget size for perfect alignment
+ final renderBox =
+ _contentKey.currentContext?.findRenderObject() as RenderBox?;
+ final size = renderBox?.size;
+
+ return Stack(
+ children: [
+ // Full-screen barrier with black opacity 0.7
+ GestureDetector(
+ onTap: _hideHighlight,
+ child: TweenAnimationBuilder<double>(
+ tween: Tween(begin: 0.0, end: 1.0),
+ duration: const Duration(milliseconds: 200),
+ curve: Curves.easeOutCubic,
+ builder: (context, value, child) {
+ return Container(
+ color: Colors.black.withValues(alpha: 0.7 * value),
+ );
+ },
+ ),
+ ),
+ // Highlighted comment + popup menu
+ CompositedTransformFollower(
+ link: _layerLink,
+ showWhenUnlinked: false,
+ child: Material(
+ color: Colors.transparent,
+ child: SizedBox(
+ width: size?.width,
+ child: TweenAnimationBuilder<double>(
+ tween: Tween(begin: 0.0, end: 1.0),
+ duration: const Duration(milliseconds: 200),
+ curve: Curves.easeOutCubic,
+ builder: (context, value, child) {
+ return Opacity(
+ opacity: value,
+ child: Transform.scale(
+ scale: 0.95 + (0.05 * value),
+ alignment: widget.isOwnComment
+ ? Alignment.topRight
+ : Alignment.topLeft,
+ child: child,
+ ),
+ );
+ },
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: widget.isOwnComment
+ ? CrossAxisAlignment.end
+ : CrossAxisAlignment.start,
+ children: [
+ _buildCommentContent(
+ showActionsCapsule: false,
+ ),
+ const SizedBox(height: 8),
+ Padding(
+ padding:
+ EdgeInsets.only(left: widget.isOwnComment ? 0 : 24),
+ child: CommentActionsPopup(
+ isLiked: _isLiked,
+ onLikeTap: () {
+ _hideHighlight();
+ _toggleLike();
+ },
+ onReplyTap: () {
+ _hideHighlight();
+ widget.onReplyTap();
+ },
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ Widget _buildCommentContent({
+ required bool showActionsCapsule,
+ bool includePadding = true,
+ }) {
return Padding(
padding: EdgeInsets.only(
right: widget.isOwnComment ? 24 : 0,
- top: 8,
- bottom: 8,
+ top: includePadding ? 8 : 0,
+ bottom: includePadding ? 8 : 0,
),
child: Column(
crossAxisAlignment: widget.isOwnComment
@@ -127,7 +241,7 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget> {
currentUserID: widget.currentUserID,
userResolver: widget.userResolver,
),
- if (!_isLoadingReactions)
+ if (!_isLoadingReactions && showActionsCapsule)
Positioned(
right: -16,
bottom: -17,