Skip to content

armgit / ente

Public Imported from GitHub
0

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

Make comments screen more similar to figma design + refactor to use widgets instead of helper functions that return widget

ashilknd086eb05cb36
diff --git a/mobile/apps/photos/lib/ui/social/comments_screen.dart b/mobile/apps/photos/lib/ui/social/comments_screen.dart
index e8f8e3f0a1..e20a6a9a70 100644
--- a/mobile/apps/photos/lib/ui/social/comments_screen.dart
+++ b/mobile/apps/photos/lib/ui/social/comments_screen.dart
@@ -216,9 +216,9 @@ class _CommentsScreenState extends State<CommentsScreen> {
controller: _scrollController,
reverse: true,
padding: const EdgeInsets.only(
- top: 12,
- left: 4,
- right: 4,
+ top: 24,
+ left: 16,
+ right: 16,
bottom: 24,
),
itemCount: _comments.length + (_hasMoreComments ? 1 : 0),
diff --git a/mobile/apps/photos/lib/ui/social/widgets/comment_actions_capsule.dart b/mobile/apps/photos/lib/ui/social/widgets/comment_actions_capsule.dart
index 86fe2c26d6..a89b407dda 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/comment_actions_capsule.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/comment_actions_capsule.dart
@@ -16,13 +16,19 @@ class CommentActionsCapsule extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
+ final background = Theme.of(context).brightness == Brightness.dark
+ ? const Color(0xFF161616)
+ : const Color(0xFFF5F5F7);
return Container(
- padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
+ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
decoration: BoxDecoration(
- color: colorScheme.backgroundBase,
- border: Border.all(color: colorScheme.strokeFaint),
- borderRadius: BorderRadius.circular(18),
+ color: background,
+ border: Border.all(
+ color: colorScheme.backgroundBase,
+ width: 2,
+ ),
+ borderRadius: BorderRadius.circular(42),
),
child: Row(
mainAxisSize: MainAxisSize.min,
@@ -35,7 +41,7 @@ class CommentActionsCapsule extends StatelessWidget {
color: isLiked ? colorScheme.primary500 : colorScheme.textMuted,
),
),
- const SizedBox(width: 12),
+ const SizedBox(width: 8),
GestureDetector(
onTap: onReplyTap,
child: Icon(
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 e2ff332977..75750fb477 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
@@ -6,7 +6,6 @@ import "package:photos/models/social/reaction.dart";
import "package:photos/models/social/social_data_provider.dart";
import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
import "package:photos/ui/sharing/user_avator_widget.dart";
import "package:photos/ui/social/widgets/comment_actions_capsule.dart";
import "package:photos/utils/social/relative_time_formatter.dart";
@@ -95,110 +94,71 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
-
- final bubbleTextColor =
- widget.isOwnComment ? colorScheme.backgroundBase : colorScheme.textBase;
- final bubbleBackgroundColor =
- widget.isOwnComment ? colorScheme.primary700 : colorScheme.fillBaseGrey;
-
return Padding(
padding: EdgeInsets.only(
- left: widget.isOwnComment ? 48 : 20,
- right: widget.isOwnComment ? 20 : 48,
- top: 12,
- bottom: 28,
+ right: widget.isOwnComment ? 24 : 0,
+ top: 8,
+ bottom: 8,
),
child: Column(
crossAxisAlignment: widget.isOwnComment
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
children: [
- Padding(
- padding: const EdgeInsets.only(bottom: 8),
- child: _Header(
- isOwnComment: widget.isOwnComment,
- user: widget.user,
- createdAt: widget.comment.createdAt,
- currentUserID: widget.currentUserID,
- ),
- ),
- _buildBubble(
- colorScheme: colorScheme,
- textTheme: textTheme,
- textColor: bubbleTextColor,
- bubbleColor: bubbleBackgroundColor,
+ _Header(
+ isOwnComment: widget.isOwnComment,
+ user: widget.user,
+ createdAt: widget.comment.createdAt,
+ currentUserID: widget.currentUserID,
),
- if (!_isLoadingReactions) ...[
- const SizedBox(height: 2),
- Transform.translate(
- offset: const Offset(0, -12),
- child: Align(
- alignment: widget.isOwnComment
- ? Alignment.centerRight
- : Alignment.centerLeft,
- child: CommentActionsCapsule(
- isLiked: _isLiked,
- onLikeTap: _toggleLike,
- onReplyTap: widget.onReplyTap,
+ const SizedBox(height: 12),
+ Padding(
+ padding: EdgeInsets.only(left: widget.isOwnComment ? 0 : 24),
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ _CommentBubble(
+ comment: widget.comment,
+ isOwnComment: widget.isOwnComment,
+ isLoadingParent: _isLoadingParent,
+ parentComment: _parentComment,
),
- ),
+ if (!_isLoadingReactions)
+ Positioned(
+ right: -16,
+ bottom: -17,
+ child: CommentActionsCapsule(
+ isLiked: _isLiked,
+ onLikeTap: _toggleLike,
+ onReplyTap: widget.onReplyTap,
+ ),
+ ),
+ ],
),
- ],
+ ),
],
),
);
}
+}
- Widget _buildBubble({
- required EnteColorScheme colorScheme,
- required EnteTextTheme textTheme,
- required Color textColor,
- required Color bubbleColor,
- }) {
- final bubbleBorderRadius = BorderRadius.only(
- topLeft: Radius.circular(widget.isOwnComment ? 20 : 6),
- topRight: Radius.circular(widget.isOwnComment ? 6 : 20),
- bottomLeft: const Radius.circular(20),
- bottomRight: const Radius.circular(20),
- );
+class _InlineParentQuote extends StatelessWidget {
+ final bool isLoading;
+ final Comment? parentComment;
+ final bool isOwnComment;
- return Container(
- padding: const EdgeInsets.fromLTRB(14, 12, 14, 16),
- decoration: BoxDecoration(
- color: bubbleColor,
- borderRadius: bubbleBorderRadius,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- if (widget.comment.isReply)
- _buildInlineParent(
- colorScheme: colorScheme,
- textTheme: textTheme,
- textColor: textColor,
- ),
- Text(
- widget.comment.data,
- style: textTheme.small.copyWith(
- color: textColor,
- height: 22 / 14,
- fontWeight: FontWeight.w500,
- ),
- ),
- ],
- ),
- );
- }
+ const _InlineParentQuote({
+ required this.isLoading,
+ required this.parentComment,
+ required this.isOwnComment,
+ });
- Widget _buildInlineParent({
- required EnteColorScheme colorScheme,
- required EnteTextTheme textTheme,
- required Color textColor,
- }) {
- if (_isLoadingParent) {
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
+ if (isLoading) {
return Container(
margin: const EdgeInsets.only(bottom: 8),
height: 16,
@@ -212,7 +172,7 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget> {
);
}
- final parentText = _parentComment?.data ?? "Original comment unavailable";
+ final parentText = parentComment?.data ?? "Original comment unavailable";
return Container(
margin: const EdgeInsets.only(bottom: 8),
@@ -220,8 +180,8 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget> {
decoration: BoxDecoration(
border: Border(
left: BorderSide(
- color: widget.isOwnComment
- ? colorScheme.backgroundBase.withValues(alpha: 0.6)
+ color: isOwnComment
+ ? textBaseDark.withValues(alpha: 0.6)
: colorScheme.strokeMuted,
width: 2,
),
@@ -231,8 +191,8 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget> {
parentText,
style: textTheme.tiny.copyWith(
height: 1.7,
- color: widget.isOwnComment
- ? colorScheme.backgroundBase.withValues(alpha: 0.9)
+ color: isOwnComment
+ ? textBaseDark.withValues(alpha: 0.9)
: colorScheme.textMuted,
),
maxLines: 2,
@@ -242,6 +202,65 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget> {
}
}
+class _CommentBubble extends StatelessWidget {
+ final Comment comment;
+ final bool isOwnComment;
+ final bool isLoadingParent;
+ final Comment? parentComment;
+
+ const _CommentBubble({
+ required this.comment,
+ required this.isOwnComment,
+ required this.isLoadingParent,
+ required this.parentComment,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
+ final textColor = isOwnComment ? textBaseDark : colorScheme.textBase;
+ final bubbleColor =
+ isOwnComment ? const Color(0xFF0DAF35) : colorScheme.fillBaseGrey;
+
+ final bubbleBorderRadius = BorderRadius.only(
+ topLeft: Radius.circular(isOwnComment ? 20 : 6),
+ topRight: Radius.circular(isOwnComment ? 6 : 20),
+ bottomLeft: const Radius.circular(20),
+ bottomRight: const Radius.circular(20),
+ );
+
+ return Container(
+ padding: const EdgeInsets.fromLTRB(16, 16, 16, 18),
+ decoration: BoxDecoration(
+ color: bubbleColor,
+ borderRadius: bubbleBorderRadius,
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (comment.isReply)
+ _InlineParentQuote(
+ isLoading: isLoadingParent,
+ parentComment: parentComment,
+ isOwnComment: isOwnComment,
+ ),
+ Text(
+ comment.data,
+ style: textTheme.small.copyWith(
+ color: textColor,
+ height: 22 / 14,
+ fontWeight: FontWeight.w500,
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
class _Header extends StatelessWidget {
final bool isOwnComment;
final User user;
@@ -276,43 +295,47 @@ class _Header extends StatelessWidget {
);
}
- final headerText = Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.baseline,
- textBaseline: TextBaseline.alphabetic,
- children: [
- Text(
- name,
- style: textTheme.small.copyWith(
- color: colorScheme.textMuted,
- height: 20 / 14,
- fontWeight: FontWeight.w500,
+ final baseNameStyle = textTheme.small.copyWith(
+ color: colorScheme.textMuted,
+ height: 20 / 14,
+ fontWeight: FontWeight.w500,
+ );
+
+ final headerText = Text.rich(
+ TextSpan(
+ children: [
+ TextSpan(text: name, style: baseNameStyle),
+ WidgetSpan(
+ alignment: PlaceholderAlignment.baseline,
+ baseline: TextBaseline.alphabetic,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 4),
+ child: Text(
+ 'β€’',
+ style: baseNameStyle.copyWith(
+ fontSize: (baseNameStyle.fontSize ?? 14) * 0.65,
+ height: 1,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- const SizedBox(width: 4),
- Transform.translate(
- offset: const Offset(0, 1),
- child: Text(
- 'β€’',
+ TextSpan(
+ text: timestamp,
style: textTheme.tiny.copyWith(
color: colorScheme.textMuted,
- height: 1,
- fontWeight: FontWeight.w600,
+ height: 14 / 10,
+ fontWeight: FontWeight.w500,
),
),
- ),
- const SizedBox(width: 4),
- Text(
- timestamp,
- style: textTheme.tiny.copyWith(
- color: colorScheme.textMuted,
- height: 14 / 10,
- fontWeight: FontWeight.w500,
- ),
- ),
- ],
+ ],
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textHeightBehavior: const TextHeightBehavior(
+ applyHeightToFirstAscent: false,
+ applyHeightToLastDescent: false,
+ ),
);
return Row(