fix(content): 콘텐츠 랭킹 rank 간격을 보정한다

This commit is contained in:
2026-06-25 15:57:53 +09:00
parent 2e86e21cb7
commit 11853761cf
7 changed files with 103 additions and 0 deletions

View File

@@ -123,6 +123,7 @@ open class ContentRankingGridCardView @JvmOverloads constructor(
requireNotNull(rankText).apply {
textSize = 54f
layoutParams = LayoutParams((55 * scale).roundToInt(), (75 * scale).roundToInt())
setPadding(0, 0, 0, (6 * scale).roundToInt())
}
requireNotNull(titleText).textSize = 22f
placeDelta(left = 10, top = 70, scale = scale)
@@ -136,6 +137,7 @@ open class ContentRankingGridCardView @JvmOverloads constructor(
layoutParams = LayoutParams((42 * scale).roundToInt(), (56 * scale).roundToInt()).apply {
leftMargin = (8 * scale).roundToInt()
}
setPadding(0, 0, 0, (5 * scale).roundToInt())
}
requireNotNull(titleText).textSize = 14f
placeDelta(left = 10, top = 49, scale = scale)

View File

@@ -122,6 +122,11 @@ class ContentRankingHorizontalCardView @JvmOverloads constructor(
leftMargin = (14 * scale).roundToInt()
topMargin = (14 * scale).roundToInt()
}
requireNotNull(rankText).layoutParams = android.widget.LinearLayout.LayoutParams(
(48 * scale).roundToInt(),
(52 * scale).roundToInt()
)
requireNotNull(rankText).setPadding(0, 0, 0, (4 * scale).roundToInt())
requireNotNull(rankText).applyContentRankingRankGradient()
imageView().layoutParams = LayoutParams((80 * scale).roundToInt(), (80 * scale).roundToInt()).apply {
leftMargin = (77 * scale).roundToInt()

View File

@@ -120,6 +120,7 @@ class ContentRankingLargeCardView @JvmOverloads constructor(
private fun positionViews(size: ContentRankingCardSize) {
val scale = size.widthPx / FIGMA_WIDTH.toFloat()
requireNotNull(rankText).layoutParams = LayoutParams((91 * scale).roundToInt(), (114 * scale).roundToInt())
requireNotNull(rankText).setPadding(0, 0, 0, (10 * scale).roundToInt())
contentImageView().layoutParams = LayoutParams((155 * scale).roundToInt(), (154 * scale).roundToInt()).apply {
leftMargin = ((size.widthPx - (155 * scale)) / 2f).roundToInt()
topMargin = (14 * scale).roundToInt()

View File

@@ -21,6 +21,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/pattaya_regular"
android:gravity="center"
android:includeFontPadding="false"
android:shadowColor="#7A000000"
android:shadowRadius="4"

View File

@@ -16,6 +16,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/pattaya_regular"
android:gravity="center"
android:includeFontPadding="false"
android:shadowColor="#7A000000"
android:shadowRadius="4"

View File

@@ -29,6 +29,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/pattaya_regular"
android:gravity="center"
android:includeFontPadding="false"
android:shadowColor="#7A000000"
android:shadowRadius="4"

View File

@@ -2,8 +2,11 @@ package kr.co.vividnext.sodalive.v2.widget.contentranking
import android.app.Application
import android.content.Context
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.test.core.app.ApplicationProvider
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType.Increase
@@ -17,6 +20,77 @@ import org.robolectric.annotation.Config
@Config(sdk = [28], application = Application::class)
class ContentRankingCardViewTest {
@Test
fun `large card 순위 숫자는 폰트 padding 없이 하단 보정 padding을 가진다`() {
val view = inflateView<ContentRankingLargeCardView>(R.layout.view_content_ranking_large_card)
view.setCardSize(ContentRankingCardSize(widthPx = 374, heightPx = 268))
assertRankTextBox(
view = view.findViewById(R.id.tv_content_ranking_rank),
expectedWidth = 91,
expectedHeight = 114,
expectedLeft = 0,
expectedTop = 0,
expectedBottomPadding = 10
)
}
@Test
fun `medium grid card 순위 숫자는 폰트 padding 없이 하단 보정 padding을 가진다`() {
val view = inflateView<ContentRankingMediumGridCardView>(R.layout.view_content_ranking_medium_grid_card)
view.setCardSize(ContentRankingCardSize(widthPx = 185, heightPx = 185))
assertRankTextBox(
view = view.findViewById(R.id.tv_content_ranking_rank),
expectedWidth = 55,
expectedHeight = 75,
expectedLeft = 0,
expectedTop = 0,
expectedBottomPadding = 6
)
}
@Test
fun `small grid card 순위 숫자는 폰트 padding 없이 하단 보정 padding을 가진다`() {
val view = inflateView<ContentRankingSmallGridCardView>(R.layout.view_content_ranking_small_grid_card)
view.setCardSize(ContentRankingCardSize(widthPx = 122, heightPx = 122))
assertRankTextBox(
view = view.findViewById(R.id.tv_content_ranking_rank),
expectedWidth = 42,
expectedHeight = 56,
expectedLeft = 8,
expectedTop = 0,
expectedBottomPadding = 5
)
}
@Test
fun `horizontal card 순위 숫자는 폰트 padding 없이 하단 보정 padding을 가진다`() {
val view = inflateView<ContentRankingHorizontalCardView>(R.layout.view_content_ranking_horizontal_card)
view.setCardSize(ContentRankingCardSize(widthPx = 374, heightPx = 100))
val rankGroup = view.findViewById<View>(R.id.ll_content_ranking_rank_group)
val rankGroupParams = rankGroup.layoutParams as ViewGroup.MarginLayoutParams
assertEquals(49, rankGroupParams.width)
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, rankGroupParams.height)
assertEquals(14, rankGroupParams.leftMargin)
assertEquals(14, rankGroupParams.topMargin)
assertRankTextBox(
view = view.findViewById(R.id.tv_content_ranking_rank),
expectedWidth = 48,
expectedHeight = 52,
expectedLeft = 0,
expectedTop = 0,
expectedBottomPadding = 4
)
}
@Test
fun `large card는 showRankChange가 false이면 rank num을 숨긴다`() {
val view = inflateView<ContentRankingLargeCardView>(R.layout.view_content_ranking_large_card)
@@ -67,6 +141,24 @@ class ContentRankingCardViewTest {
return LayoutInflater.from(context).inflate(layoutResId, null, false) as T
}
private fun assertRankTextBox(
view: TextView,
expectedWidth: Int,
expectedHeight: Int,
expectedLeft: Int,
expectedTop: Int,
expectedBottomPadding: Int
) {
val params = view.layoutParams as ViewGroup.MarginLayoutParams
assertEquals(expectedWidth, params.width)
assertEquals(expectedHeight, params.height)
assertEquals(expectedLeft, params.leftMargin)
assertEquals(expectedTop, params.topMargin)
assertEquals(Gravity.CENTER, view.gravity)
assertEquals(false, view.includeFontPadding)
assertEquals(expectedBottomPadding, view.paddingBottom)
}
private fun sampleItem(
rank: Int = 1,
showRankChange: Boolean = true