fix(content): 콘텐츠 카드 동적 폭을 추가한다

This commit is contained in:
2026-06-25 18:31:26 +09:00
parent 15de359d4f
commit 78e0a53018
4 changed files with 129 additions and 0 deletions

View File

@@ -82,6 +82,35 @@ class AudioContentCardView @JvmOverloads constructor(
}
}
fun setGridItemWidthPx(widthPx: Int) {
if (widthPx <= 0) return
updateRootWidth(widthPx)
requireNotNull(thumbnailContainer).layoutParams = LayoutParams(widthPx, widthPx)
requireNotNull(thumbnail).layoutParams = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
requireNotNull(labelContainer).layoutParams = LayoutParams(
widthPx,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
topMargin = AudioContentCardSize.Small.thumbnailLabelGapDp.dpToPx()
}
requireNotNull(titleText).setTextAppearance(AudioContentCardSize.Small.titleStyleRes)
requireNotNull(creatorText).apply {
setTextAppearance(AudioContentCardSize.Small.creatorStyleRes)
layoutParams = LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
topMargin = TITLE_CREATOR_GAP_DP.dpToPx()
}
}
}
fun setContent(
title: String,
creatorName: String

View File

@@ -73,6 +73,35 @@ class SeriesContentCardView @JvmOverloads constructor(
}
}
fun setGridItemWidthPx(widthPx: Int) {
if (widthPx <= 0) return
updateRootWidth(widthPx)
requireNotNull(thumbnailContainer).layoutParams = LayoutParams(
widthPx,
(widthPx * SERIES_SMALL_THUMBNAIL_HEIGHT_RATIO).roundToInt()
)
requireNotNull(labelContainer).layoutParams = LayoutParams(
widthPx,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
topMargin = SeriesContentCardSize.Small.thumbnailLabelGapDp.dpToPx()
}
requireNotNull(titleText).setTextAppearance(SeriesContentCardSize.Small.titleStyleRes)
updateAdultBadge(SeriesContentCardSize.Small)
requireNotNull(creatorText).apply {
setTextAppearance(SeriesContentCardSize.Small.creatorStyleRes)
layoutParams = LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
topMargin = TITLE_CREATOR_GAP_DP.dpToPx()
}
}
}
fun setContent(
title: String,
creatorName: String
@@ -150,6 +179,7 @@ class SeriesContentCardView @JvmOverloads constructor(
private companion object {
const val TITLE_CREATOR_GAP_DP = 2
const val SERIES_SMALL_THUMBNAIL_HEIGHT_RATIO = 172f / 122f
}
private data class AdultBadgeSpec(