refactor(creator): 시리즈 subtitle 모델을 분리한다
This commit is contained in:
@@ -2,10 +2,6 @@ package kr.co.vividnext.sodalive.v2.creator.channel.series.model
|
||||
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.series.data.CreatorChannelSeriesResponse
|
||||
|
||||
private const val BULLET_SEPARATOR = " • "
|
||||
private const val STATUS_PROCEEDING = "연재"
|
||||
private const val STATUS_COMPLETED = "완결"
|
||||
|
||||
fun List<CreatorChannelSeriesResponse>.toSeriesItemUiModels(
|
||||
isOwner: Boolean
|
||||
): List<CreatorChannelSeriesItemUiModel> = mapNotNull { it.toSeriesItemUiModel(isOwner) }
|
||||
@@ -16,7 +12,7 @@ private fun CreatorChannelSeriesResponse.toSeriesItemUiModel(isOwner: Boolean):
|
||||
return CreatorChannelSeriesItemUiModel(
|
||||
seriesId = seriesId,
|
||||
title = title,
|
||||
subtitle = subtitle(),
|
||||
subtitle = toSubtitleUiModel(),
|
||||
coverImageUrl = coverImageUrl,
|
||||
showOriginalTag = isOriginal,
|
||||
showAdultBadge = isAdult,
|
||||
@@ -24,11 +20,13 @@ private fun CreatorChannelSeriesResponse.toSeriesItemUiModel(isOwner: Boolean):
|
||||
)
|
||||
}
|
||||
|
||||
private fun CreatorChannelSeriesResponse.subtitle(): String = listOfNotNull(
|
||||
publishedDaysOfWeek?.takeIf { it.isNotBlank() },
|
||||
"총 ${contentCount}화",
|
||||
if (isProceeding) STATUS_PROCEEDING else STATUS_COMPLETED
|
||||
).joinToString(BULLET_SEPARATOR)
|
||||
private fun CreatorChannelSeriesResponse.toSubtitleUiModel(): CreatorChannelSeriesSubtitleUiModel {
|
||||
return CreatorChannelSeriesSubtitleUiModel(
|
||||
publishedDaysOfWeek = publishedDaysOfWeek?.takeIf { it.isNotBlank() },
|
||||
contentCount = contentCount,
|
||||
isProceeding = isProceeding
|
||||
)
|
||||
}
|
||||
|
||||
private fun CreatorChannelSeriesResponse.toProgressUiModel(isOwner: Boolean): CreatorChannelSeriesProgressUiModel? {
|
||||
if (isOwner) return null
|
||||
|
||||
@@ -3,13 +3,19 @@ package kr.co.vividnext.sodalive.v2.creator.channel.series.model
|
||||
data class CreatorChannelSeriesItemUiModel(
|
||||
val seriesId: Long,
|
||||
val title: String,
|
||||
val subtitle: String,
|
||||
val subtitle: CreatorChannelSeriesSubtitleUiModel,
|
||||
val coverImageUrl: String?,
|
||||
val showOriginalTag: Boolean,
|
||||
val showAdultBadge: Boolean,
|
||||
val progress: CreatorChannelSeriesProgressUiModel?
|
||||
)
|
||||
|
||||
data class CreatorChannelSeriesSubtitleUiModel(
|
||||
val publishedDaysOfWeek: String?,
|
||||
val contentCount: Int,
|
||||
val isProceeding: Boolean
|
||||
)
|
||||
|
||||
data class CreatorChannelSeriesProgressUiModel(
|
||||
val purchasedCount: Int,
|
||||
val paidCount: Int,
|
||||
|
||||
Reference in New Issue
Block a user