feat(feed): 피드 크기 계산 계약을 추가한다

This commit is contained in:
2026-05-21 15:53:40 +09:00
parent 3444b1eeef
commit a5728bcc4d
5 changed files with 148 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
package kr.co.vividnext.sodalive.v2.widget.feed
data class FeedContentImageSize(
val widthDp: Int,
val heightDp: Int
) {
companion object {
fun from(widthDp: Int, category: FeedContentCategory): FeedContentImageSize {
require(widthDp > 0) { "widthDp must be greater than 0." }
val height = (widthDp * category.ratioHeight.toFloat() / category.ratioWidth).toInt()
return FeedContentImageSize(widthDp = widthDp, heightDp = height)
}
}
}

View File

@@ -0,0 +1,27 @@
package kr.co.vividnext.sodalive.v2.widget.feed
data class FeedSize(
val rootWidthDp: Int
) {
companion object {
private const val FIGMA_ROOT_WIDTH_DP = 374
fun from(
variant: FeedVariant,
widthMode: FeedWidthMode,
parentAvailableWidthDp: Int,
horizontalItemDecorationDp: Int = 0
): FeedSize {
val width = when (widthMode) {
FeedWidthMode.FigmaFixed -> FIGMA_ROOT_WIDTH_DP
FeedWidthMode.ParentAvailable -> {
require(parentAvailableWidthDp > 0) { "parentAvailableWidthDp must be greater than 0." }
require(horizontalItemDecorationDp >= 0) { "horizontalItemDecorationDp must be 0 or greater." }
parentAvailableWidthDp - horizontalItemDecorationDp
}
}
require(width > 0) { "rootWidthDp must be greater than 0." }
return FeedSize(rootWidthDp = width)
}
}
}

View File

@@ -0,0 +1,6 @@
package kr.co.vividnext.sodalive.v2.widget.feed
enum class FeedWidthMode {
FigmaFixed,
ParentAvailable
}