Skip to content

armgit / ente

Public Imported from GitHub
0

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

Bold album names in shared feed copy

ashilknfb7744b66055
diff --git a/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart
index 0bfde0cf1c..cfa00f5217 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart
@@ -486,11 +486,13 @@ class _FeedTextContent extends StatelessWidget {
_buildUsernameRow(context, primaryName, textTheme, colorScheme),
const SizedBox(height: 2),
// Action description
- Text(
- _getActionDescription(context),
- style: textTheme.mini.copyWith(
- color: colorScheme.textMuted,
- fontWeight: FontWeight.w500,
+ Text.rich(
+ _getActionDescriptionSpan(
+ context,
+ textTheme.mini.copyWith(
+ color: colorScheme.textMuted,
+ fontWeight: FontWeight.w500,
+ ),
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -548,38 +550,96 @@ class _FeedTextContent extends StatelessWidget {
);
}
- String _getActionDescription(BuildContext context) {
+ InlineSpan _getActionDescriptionSpan(
+ BuildContext context,
+ TextStyle baseStyle,
+ ) {
final l10n = AppLocalizations.of(context);
final isOwn = feedItem.isOwnedByCurrentUser;
switch (feedItem.type) {
case FeedItemType.photoLike:
- return isOwn ? l10n.likedYourPhoto : l10n.likedAPhoto;
+ return TextSpan(
+ text: isOwn ? l10n.likedYourPhoto : l10n.likedAPhoto,
+ style: baseStyle,
+ );
case FeedItemType.comment:
- return isOwn ? l10n.commentedOnYourPhoto : l10n.commentedOnAPhoto;
+ return TextSpan(
+ text: isOwn ? l10n.commentedOnYourPhoto : l10n.commentedOnAPhoto,
+ style: baseStyle,
+ );
case FeedItemType.reply:
- return isOwn ? l10n.repliedToYourComment : l10n.repliedToAComment;
+ return TextSpan(
+ text: isOwn ? l10n.repliedToYourComment : l10n.repliedToAComment,
+ style: baseStyle,
+ );
case FeedItemType.commentLike:
- return isOwn ? l10n.likedYourComment : l10n.likedAComment;
+ return TextSpan(
+ text: isOwn ? l10n.likedYourComment : l10n.likedAComment,
+ style: baseStyle,
+ );
case FeedItemType.replyLike:
- return isOwn ? l10n.likedYourReply : l10n.likedAReply;
+ return TextSpan(
+ text: isOwn ? l10n.likedYourReply : l10n.likedAReply,
+ style: baseStyle,
+ );
case FeedItemType.sharedPhoto:
- return _getSharedPhotoDescription(context);
+ return _getSharedPhotoDescriptionSpan(context, baseStyle);
case FeedItemType.sharedCollection:
final albumName = feedItem.collectionName ?? l10n.albums;
- return l10n.sharedAlbumWithYou(albumName: albumName);
+ return _buildAlbumNameHighlightedSpan(
+ fullText: l10n.sharedAlbumWithYou(albumName: albumName),
+ albumName: albumName,
+ baseStyle: baseStyle,
+ );
}
}
- String _getSharedPhotoDescription(BuildContext context) {
+ InlineSpan _getSharedPhotoDescriptionSpan(
+ BuildContext context,
+ TextStyle baseStyle,
+ ) {
final l10n = AppLocalizations.of(context);
final count = feedItem.sharedFileCount;
final albumName = feedItem.collectionName ?? l10n.albums;
- if (count == 1) {
- return l10n.addedAMemoryTo(albumName: albumName);
- } else {
- return l10n.addedNMemoriesTo(count: count, albumName: albumName);
+ final fullText = count == 1
+ ? l10n.addedAMemoryTo(albumName: albumName)
+ : l10n.addedNMemoriesTo(count: count, albumName: albumName);
+ return _buildAlbumNameHighlightedSpan(
+ fullText: fullText,
+ albumName: albumName,
+ baseStyle: baseStyle,
+ );
+ }
+
+ InlineSpan _buildAlbumNameHighlightedSpan({
+ required String fullText,
+ required String albumName,
+ required TextStyle baseStyle,
+ }) {
+ if (albumName.isEmpty) {
+ return TextSpan(text: fullText, style: baseStyle);
+ }
+
+ final startIndex = fullText.indexOf(albumName);
+ if (startIndex < 0) {
+ return TextSpan(text: fullText, style: baseStyle);
}
+
+ final beforeText = fullText.substring(0, startIndex);
+ final afterText = fullText.substring(startIndex + albumName.length);
+
+ return TextSpan(
+ style: baseStyle,
+ children: [
+ if (beforeText.isNotEmpty) TextSpan(text: beforeText),
+ TextSpan(
+ text: albumName,
+ style: baseStyle.copyWith(fontWeight: FontWeight.w700),
+ ),
+ if (afterText.isNotEmpty) TextSpan(text: afterText),
+ ],
+ );
}
User _getPrimaryUser() {
diff --git a/mobile/apps/photos/lib/ui/social/widgets/feed_preview_item_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/feed_preview_item_widget.dart
index 4227dc4453..4242d0945b 100644
--- a/mobile/apps/photos/lib/ui/social/widgets/feed_preview_item_widget.dart
+++ b/mobile/apps/photos/lib/ui/social/widgets/feed_preview_item_widget.dart
@@ -256,11 +256,13 @@ class _PreviewTextContent extends StatelessWidget {
_buildUsernameRow(context, primaryName),
const SizedBox(height: 2),
// Action description
- Text(
- _getActionDescription(context),
- style: textTheme.small.copyWith(
- color: colorScheme.textMuted,
- fontWeight: FontWeight.w500,
+ Text.rich(
+ _getActionDescriptionSpan(
+ context,
+ textTheme.small.copyWith(
+ color: colorScheme.textMuted,
+ fontWeight: FontWeight.w500,
+ ),
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -311,32 +313,87 @@ class _PreviewTextContent extends StatelessWidget {
);
}
- String _getActionDescription(BuildContext context) {
+ InlineSpan _getActionDescriptionSpan(
+ BuildContext context,
+ TextStyle baseStyle,
+ ) {
final l10n = AppLocalizations.of(context);
final isOwn = feedItem.isOwnedByCurrentUser;
switch (feedItem.type) {
case FeedItemType.photoLike:
- return isOwn ? l10n.likedYourPhoto : l10n.likedAPhoto;
+ return TextSpan(
+ text: isOwn ? l10n.likedYourPhoto : l10n.likedAPhoto,
+ style: baseStyle,
+ );
case FeedItemType.comment:
- return isOwn ? l10n.commentedOnYourPhoto : l10n.commentedOnAPhoto;
+ return TextSpan(
+ text: isOwn ? l10n.commentedOnYourPhoto : l10n.commentedOnAPhoto,
+ style: baseStyle,
+ );
case FeedItemType.reply:
- return isOwn ? l10n.repliedToYourComment : l10n.repliedToAComment;
+ return TextSpan(
+ text: isOwn ? l10n.repliedToYourComment : l10n.repliedToAComment,
+ style: baseStyle,
+ );
case FeedItemType.commentLike:
- return isOwn ? l10n.likedYourComment : l10n.likedAComment;
+ return TextSpan(
+ text: isOwn ? l10n.likedYourComment : l10n.likedAComment,
+ style: baseStyle,
+ );
case FeedItemType.replyLike:
- return isOwn ? l10n.likedYourReply : l10n.likedAReply;
+ return TextSpan(
+ text: isOwn ? l10n.likedYourReply : l10n.likedAReply,
+ style: baseStyle,
+ );
case FeedItemType.sharedPhoto:
final count = feedItem.sharedFileCount;
final albumName = feedItem.collectionName ?? l10n.albums;
- if (count == 1) {
- return l10n.addedAMemoryTo(albumName: albumName);
- } else {
- return l10n.addedNMemoriesTo(count: count, albumName: albumName);
- }
+ final fullText = count == 1
+ ? l10n.addedAMemoryTo(albumName: albumName)
+ : l10n.addedNMemoriesTo(count: count, albumName: albumName);
+ return _buildAlbumNameHighlightedSpan(
+ fullText: fullText,
+ albumName: albumName,
+ baseStyle: baseStyle,
+ );
case FeedItemType.sharedCollection:
final albumName = feedItem.collectionName ?? l10n.albums;
- return l10n.sharedAlbumWithYou(albumName: albumName);
+ return _buildAlbumNameHighlightedSpan(
+ fullText: l10n.sharedAlbumWithYou(albumName: albumName),
+ albumName: albumName,
+ baseStyle: baseStyle,
+ );
+ }
+ }
+
+ InlineSpan _buildAlbumNameHighlightedSpan({
+ required String fullText,
+ required String albumName,
+ required TextStyle baseStyle,
+ }) {
+ if (albumName.isEmpty) {
+ return TextSpan(text: fullText, style: baseStyle);
}
+
+ final startIndex = fullText.indexOf(albumName);
+ if (startIndex < 0) {
+ return TextSpan(text: fullText, style: baseStyle);
+ }
+
+ final beforeText = fullText.substring(0, startIndex);
+ final afterText = fullText.substring(startIndex + albumName.length);
+
+ return TextSpan(
+ style: baseStyle,
+ children: [
+ if (beforeText.isNotEmpty) TextSpan(text: beforeText),
+ TextSpan(
+ text: albumName,
+ style: baseStyle.copyWith(fontWeight: FontWeight.w700),
+ ),
+ if (afterText.isNotEmpty) TextSpan(text: afterText),
+ ],
+ );
}
User _getPrimaryUser() {