fix(home): 팔로잉 최근 소식 표시를 보완한다
This commit is contained in:
@@ -8,7 +8,9 @@ import kr.co.vividnext.sodalive.R
|
||||
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.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.FeedRankHighlight
|
||||
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.FeedSize
|
||||
@@ -76,12 +78,24 @@ class HomeFollowingNewsAdapter(
|
||||
|
||||
override fun bind(item: HomeFollowingNewsUiItem) {
|
||||
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(
|
||||
feedId = ranking.newsId,
|
||||
imageUrl = ranking.thumbnailImageUrl.orEmpty(),
|
||||
rankText = ranking.rank.toString(),
|
||||
message = ranking.body.ifBlank { ranking.title },
|
||||
highlightRanges = emptyList()
|
||||
message = message,
|
||||
highlightRanges = listOf(
|
||||
FeedRankHighlight(
|
||||
start = message.indexOf(rankText),
|
||||
endExclusive = message.indexOf(rankText) + rankText.length
|
||||
)
|
||||
)
|
||||
)
|
||||
view.setFeedSize(feedSize(FeedVariant.Rank, parent))
|
||||
view.bind(feedItem)
|
||||
@@ -135,7 +149,8 @@ class HomeFollowingNewsAdapter(
|
||||
contentId = content.targetId.toString(),
|
||||
contentTitle = content.title,
|
||||
contentImageUrl = content.thumbnailImageUrl.orEmpty(),
|
||||
createdAtText = content.visibleFromText
|
||||
createdAtText = content.visibleFromText,
|
||||
category = content.type.toFeedContentCategory()
|
||||
)
|
||||
view.setFeedSize(feedSize(FeedVariant.Content, parent))
|
||||
view.bind(feedItem)
|
||||
@@ -164,5 +179,13 @@ class HomeFollowingNewsAdapter(
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,9 @@ class HomeFollowingFragmentSourceTest {
|
||||
assertTrue(newsLayout.contains("@+id/tv_feed_content_category"))
|
||||
assertTrue(newsLayout.contains("@+id/tv_feed_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("creatorImageUrl = content.creatorProfileImageUrl"))
|
||||
}
|
||||
@@ -165,6 +168,24 @@ class HomeFollowingFragmentSourceTest {
|
||||
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
|
||||
fun `following creators section has no header and uses figma simple profile size`() {
|
||||
val layout = homeMainLayoutSource()
|
||||
|
||||
Reference in New Issue
Block a user