fix(creator-ranking): 텍스트 크기 기준을 확장한다
This commit is contained in:
@@ -5,6 +5,12 @@ data class CreatorRankingTextStyle(
|
||||
val nameTextSizeSp: Int,
|
||||
val deltaTextSizeSp: Int
|
||||
) {
|
||||
fun scaledBy(scale: Float): CreatorRankingScaledTextStyle = CreatorRankingScaledTextStyle(
|
||||
rankTextSizeSp = rankTextSizeSp * scale,
|
||||
nameTextSizeSp = nameTextSizeSp * scale,
|
||||
deltaTextSizeSp = deltaTextSizeSp * scale
|
||||
)
|
||||
|
||||
companion object {
|
||||
fun fromPlacement(placement: CreatorRankingPlacement): CreatorRankingTextStyle {
|
||||
return when (placement.viewType) {
|
||||
@@ -25,3 +31,9 @@ data class CreatorRankingTextStyle(
|
||||
fun fromRank(rank: Int): CreatorRankingTextStyle = fromPlacement(CreatorRankingPlacement.fromRank(rank))
|
||||
}
|
||||
}
|
||||
|
||||
data class CreatorRankingScaledTextStyle(
|
||||
val rankTextSizeSp: Float,
|
||||
val nameTextSizeSp: Float,
|
||||
val deltaTextSizeSp: Float
|
||||
)
|
||||
|
||||
@@ -46,4 +46,23 @@ class CreatorRankingTextStyleTest {
|
||||
assertEquals(16, style.deltaTextSizeSp)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `402dp 이상 scale에서는 기존 baseline text size를 유지한다`() {
|
||||
val style = CreatorRankingTextStyle.fromRank(1).scaledBy(1f)
|
||||
|
||||
assertEquals(96f, style.rankTextSizeSp, 0.0001f)
|
||||
assertEquals(32f, style.nameTextSizeSp, 0.0001f)
|
||||
assertEquals(16f, style.deltaTextSizeSp, 0.0001f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `402dp 미만 scale에서는 baseline text size에 scale을 곱한다`() {
|
||||
val scale = 360f / 402f
|
||||
val style = CreatorRankingTextStyle.fromRank(11).scaledBy(scale)
|
||||
|
||||
assertEquals(40f * scale, style.rankTextSizeSp, 0.0001f)
|
||||
assertEquals(18f * scale, style.nameTextSizeSp, 0.0001f)
|
||||
assertEquals(16f * scale, style.deltaTextSizeSp, 0.0001f)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user