fix(home): 팔로잉 최근 소식 표시를 보완한다

This commit is contained in:
2026-06-30 15:04:14 +09:00
parent c5e94bbc92
commit 7e281a15a5
2 changed files with 47 additions and 3 deletions

View File

@@ -8,7 +8,9 @@ import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.extensions.loadUrl import kr.co.vividnext.sodalive.extensions.loadUrl
import kr.co.vividnext.sodalive.v2.main.home.data.FollowingNewsType import kr.co.vividnext.sodalive.v2.main.home.data.FollowingNewsType
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingNewsUiItem import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingNewsUiItem
import kr.co.vividnext.sodalive.v2.widget.feed.FeedContentCategory
import kr.co.vividnext.sodalive.v2.widget.feed.FeedContentView import kr.co.vividnext.sodalive.v2.widget.feed.FeedContentView
import kr.co.vividnext.sodalive.v2.widget.feed.FeedRankHighlight
import kr.co.vividnext.sodalive.v2.widget.feed.FeedItem import kr.co.vividnext.sodalive.v2.widget.feed.FeedItem
import kr.co.vividnext.sodalive.v2.widget.feed.FeedRankView import kr.co.vividnext.sodalive.v2.widget.feed.FeedRankView
import kr.co.vividnext.sodalive.v2.widget.feed.FeedSize import kr.co.vividnext.sodalive.v2.widget.feed.FeedSize
@@ -76,12 +78,24 @@ class HomeFollowingNewsAdapter(
override fun bind(item: HomeFollowingNewsUiItem) { override fun bind(item: HomeFollowingNewsUiItem) {
val ranking = item as HomeFollowingNewsUiItem.Ranking val ranking = item as HomeFollowingNewsUiItem.Ranking
val context = view.context
val rankText = "${ranking.rank}"
val message = context.getString(
R.string.screen_home_following_creator_ranking_news_message,
ranking.creatorNickname,
rankText
)
val feedItem = FeedItem.Rank( val feedItem = FeedItem.Rank(
feedId = ranking.newsId, feedId = ranking.newsId,
imageUrl = ranking.thumbnailImageUrl.orEmpty(), imageUrl = ranking.thumbnailImageUrl.orEmpty(),
rankText = ranking.rank.toString(), rankText = ranking.rank.toString(),
message = ranking.body.ifBlank { ranking.title }, message = message,
highlightRanges = emptyList() highlightRanges = listOf(
FeedRankHighlight(
start = message.indexOf(rankText),
endExclusive = message.indexOf(rankText) + rankText.length
)
)
) )
view.setFeedSize(feedSize(FeedVariant.Rank, parent)) view.setFeedSize(feedSize(FeedVariant.Rank, parent))
view.bind(feedItem) view.bind(feedItem)
@@ -135,7 +149,8 @@ class HomeFollowingNewsAdapter(
contentId = content.targetId.toString(), contentId = content.targetId.toString(),
contentTitle = content.title, contentTitle = content.title,
contentImageUrl = content.thumbnailImageUrl.orEmpty(), contentImageUrl = content.thumbnailImageUrl.orEmpty(),
createdAtText = content.visibleFromText createdAtText = content.visibleFromText,
category = content.type.toFeedContentCategory()
) )
view.setFeedSize(feedSize(FeedVariant.Content, parent)) view.setFeedSize(feedSize(FeedVariant.Content, parent))
view.bind(feedItem) view.bind(feedItem)
@@ -164,5 +179,13 @@ class HomeFollowingNewsAdapter(
imageView.loadUrl(url) imageView.loadUrl(url)
} }
} }
private fun FollowingNewsType.toFeedContentCategory(): FeedContentCategory = when (this) {
FollowingNewsType.AUDIO_CONTENT -> FeedContentCategory.Audio
FollowingNewsType.PHOTO_CONTENT -> FeedContentCategory.Photo
FollowingNewsType.COMMUNITY_POST,
FollowingNewsType.CREATOR_RANKING,
FollowingNewsType.CONTENT_RANKING -> FeedContentCategory.Content
}
} }
} }

View File

@@ -126,6 +126,9 @@ class HomeFollowingFragmentSourceTest {
assertTrue(newsLayout.contains("@+id/tv_feed_content_category")) assertTrue(newsLayout.contains("@+id/tv_feed_content_category"))
assertTrue(newsLayout.contains("@+id/tv_feed_content_title")) assertTrue(newsLayout.contains("@+id/tv_feed_content_title"))
assertTrue(newsAdapter.contains("contentTitle = content.title")) assertTrue(newsAdapter.contains("contentTitle = content.title"))
assertTrue(newsAdapter.contains("category = content.type.toFeedContentCategory()"))
assertTrue(newsAdapter.contains("FollowingNewsType.AUDIO_CONTENT -> FeedContentCategory.Audio"))
assertTrue(newsAdapter.contains("FollowingNewsType.PHOTO_CONTENT -> FeedContentCategory.Photo"))
assertTrue(newsAdapter.contains("createdAtText = content.visibleFromText")) assertTrue(newsAdapter.contains("createdAtText = content.visibleFromText"))
assertTrue(newsAdapter.contains("creatorImageUrl = content.creatorProfileImageUrl")) assertTrue(newsAdapter.contains("creatorImageUrl = content.creatorProfileImageUrl"))
} }
@@ -165,6 +168,24 @@ class HomeFollowingFragmentSourceTest {
assertFalse(adapter.contains("R.layout.item_home_following_news_rank")) assertFalse(adapter.contains("R.layout.item_home_following_news_rank"))
} }
@Test
fun `following ranking news builds sentence message and highlights rank text`() {
val adapter = projectFile(
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingNewsAdapter.kt"
).readText()
assertTrue(adapter.contains("ranking.creatorNickname"))
assertTrue(adapter.contains("ranking.rank"))
assertTrue(adapter.contains("R.string.screen_home_following_creator_ranking_news_message"))
assertTrue(adapter.contains("context.getString("))
assertTrue(adapter.contains("highlightRanges = listOf("))
assertTrue(adapter.contains("FeedRankHighlight("))
assertTrue(adapter.contains("start = message.indexOf(rankText)"))
assertTrue(adapter.contains("endExclusive = message.indexOf(rankText) + rankText.length"))
assertFalse(adapter.contains("message = ranking.body.ifBlank { ranking.title }"))
assertFalse(adapter.contains("highlightRanges = emptyList()"))
}
@Test @Test
fun `following creators section has no header and uses figma simple profile size`() { fun `following creators section has no header and uses figma simple profile size`() {
val layout = homeMainLayoutSource() val layout = homeMainLayoutSource()