fix(widget): 랭킹 순위 영역 위치를 보정한다

This commit is contained in:
2026-06-09 15:13:01 +09:00
parent ea076a5ac7
commit 64fb55db55
4 changed files with 64 additions and 16 deletions

View File

@@ -125,7 +125,7 @@ class CreatorRankingCompactCardView @JvmOverloads constructor(
private fun positionMedium(size: CreatorRankingCardSize) {
val scale = size.widthPx / 185f
requireNotNull(rankText).layoutParams = LayoutParams((55 * scale).roundToInt(), (75 * scale).roundToInt())
requireNotNull(rankText).layoutParams = LayoutParams((56 * scale).roundToInt(), (70 * scale).roundToInt())
findViewById<View>(R.id.ll_creator_ranking_delta).layoutParams = LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
@@ -145,17 +145,17 @@ class CreatorRankingCompactCardView @JvmOverloads constructor(
private fun positionSmall(size: CreatorRankingCardSize) {
val scale = size.widthPx / 122f
requireNotNull(rankText).layoutParams = LayoutParams(
(42 * scale).roundToInt(),
(56 * scale).roundToInt()
(52 * scale).roundToInt(),
(50 * scale).roundToInt()
).apply {
leftMargin = (8 * scale).roundToInt()
leftMargin = 0
}
findViewById<View>(R.id.ll_creator_ranking_delta).layoutParams = LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
leftMargin = (10 * scale).roundToInt()
topMargin = (49 * scale).roundToInt()
topMargin = (50 * scale).roundToInt()
}
requireNotNull(nameText).layoutParams = LayoutParams(
(102 * scale).roundToInt(),

View File

@@ -110,8 +110,12 @@ class CreatorRankingHorizontalCardView @JvmOverloads constructor(
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
leftMargin = (14 * scale).roundToInt()
topMargin = (14 * scale).roundToInt()
topMargin = (12 * scale).roundToInt()
}
requireNotNull(rankText).layoutParams = android.widget.LinearLayout.LayoutParams(
(48 * scale).roundToInt(),
(52 * scale).roundToInt()
)
requireNotNull(rankText).applyCreatorRankingRankGradient()
imageView().layoutParams = LayoutParams((80 * scale).roundToInt(), (80 * scale).roundToInt()).apply {
leftMargin = (77 * scale).roundToInt()

View File

@@ -112,7 +112,7 @@ class CreatorRankingLargeCardView @JvmOverloads constructor(
private fun positionViews(size: CreatorRankingCardSize) {
val scale = size.widthPx / FIGMA_SIZE.toFloat()
requireNotNull(rankText).layoutParams = LayoutParams((112 * scale).roundToInt(), (124 * scale).roundToInt()).apply {
requireNotNull(rankText).layoutParams = LayoutParams((86 * scale).roundToInt(), (116 * scale).roundToInt()).apply {
leftMargin = 0
topMargin = 0
}
@@ -129,7 +129,7 @@ class CreatorRankingLargeCardView @JvmOverloads constructor(
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
leftMargin = (20 * scale).roundToInt()
topMargin = (122 * scale).roundToInt()
topMargin = (116 * scale).roundToInt()
}
}

View File

@@ -49,8 +49,8 @@ class CreatorRankingAdapterLayoutTest {
assertRankTextBox(
view = view.findViewById(R.id.tv_creator_ranking_rank),
expectedWidth = 112,
expectedHeight = 124,
expectedWidth = 86,
expectedHeight = 116,
expectedLeft = 0,
expectedTop = 0
)
@@ -64,8 +64,8 @@ class CreatorRankingAdapterLayoutTest {
assertRankTextBox(
view = view.findViewById(R.id.tv_creator_ranking_rank),
expectedWidth = 55,
expectedHeight = 75,
expectedWidth = 56,
expectedHeight = 70,
expectedLeft = 0,
expectedTop = 0
)
@@ -79,9 +79,9 @@ class CreatorRankingAdapterLayoutTest {
assertRankTextBox(
view = view.findViewById(R.id.tv_creator_ranking_rank),
expectedWidth = 42,
expectedHeight = 56,
expectedLeft = 8,
expectedWidth = 52,
expectedHeight = 50,
expectedLeft = 0,
expectedTop = 0
)
}
@@ -97,7 +97,41 @@ class CreatorRankingAdapterLayoutTest {
assertEquals(49, params.width)
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, params.height)
assertEquals(14, params.leftMargin)
assertEquals(14, params.topMargin)
assertEquals(12, params.topMargin)
assertRankTextBox(
view = view.findViewById(R.id.tv_creator_ranking_rank),
expectedWidth = 48,
expectedHeight = 52,
expectedLeft = 0,
expectedTop = 0
)
}
@Test
fun `large card 순위 변화 표시는 Figma 위치를 유지한다`() {
val view = inflateView<CreatorRankingLargeCardView>(R.layout.view_creator_ranking_large_card)
view.setCardSize(CreatorRankingCardSize(widthPx = 374, heightPx = 374))
assertViewPosition(
view = view.findViewById(R.id.ll_creator_ranking_delta),
expectedLeft = 20,
expectedTop = 116
)
}
@Test
fun `compact small card 순위 변화 표시는 Figma 위치를 유지한다`() {
val view = inflateView<CreatorRankingCompactCardView>(R.layout.view_creator_ranking_compact_card)
view.setCardSize(CreatorRankingCardSize(widthPx = 122, heightPx = 122))
assertViewPosition(
view = view.findViewById(R.id.ll_creator_ranking_delta),
expectedLeft = 10,
expectedTop = 50
)
}
@Test
@@ -154,6 +188,16 @@ class CreatorRankingAdapterLayoutTest {
assertEquals(View.VISIBLE, view.findViewById<View>(R.id.ll_creator_ranking_delta).visibility)
}
private fun assertViewPosition(
view: View,
expectedLeft: Int,
expectedTop: Int
) {
val params = view.layoutParams as ViewGroup.MarginLayoutParams
assertEquals(expectedLeft, params.leftMargin)
assertEquals(expectedTop, params.topMargin)
}
private fun assertRankTextBox(
view: TextView,
expectedWidth: Int,