feat(content): 전체 탭 UI 매핑을 추가한다
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.content.model
|
||||
|
||||
import kr.co.vividnext.sodalive.v2.main.content.data.MainContentAllTabResponse
|
||||
import kr.co.vividnext.sodalive.v2.main.content.data.MainContentAllType
|
||||
import kr.co.vividnext.sodalive.v2.main.content.data.MainContentAudioResponse
|
||||
import kr.co.vividnext.sodalive.v2.main.content.data.MainContentSeriesResponse
|
||||
import kr.co.vividnext.sodalive.v2.widget.AudioContentTag
|
||||
|
||||
fun MainContentAllTabResponse.toContent(): MainContentAllTabUiState.Content {
|
||||
return MainContentAllTabUiState.Content(
|
||||
selectedType = type,
|
||||
selectedSort = sort,
|
||||
selectedDayOfWeek = dayOfWeek,
|
||||
totalCount = totalCount,
|
||||
audioItems = if (type.usesSeriesItems()) emptyList() else audios.map { it.toUiModel() },
|
||||
seriesItems = if (type.usesSeriesItems()) series.map { it.toUiModel(type) } else emptyList(),
|
||||
page = page,
|
||||
size = size,
|
||||
hasNext = hasNext
|
||||
)
|
||||
}
|
||||
|
||||
fun MainContentAudioResponse.toUiModel(): MainContentAllAudioUiModel = MainContentAllAudioUiModel(
|
||||
audioContentId = audioContentId,
|
||||
title = title,
|
||||
imageUrl = imageUrl,
|
||||
price = price,
|
||||
creatorNickname = creatorNickname,
|
||||
tags = toAudioContentTags(),
|
||||
showAdultBadge = isAdult
|
||||
)
|
||||
|
||||
fun MainContentSeriesResponse.toUiModel(type: MainContentAllType): MainContentAllSeriesUiModel = MainContentAllSeriesUiModel(
|
||||
seriesId = seriesId,
|
||||
title = title,
|
||||
coverImageUrl = coverImageUrl,
|
||||
creatorNickname = creatorNickname,
|
||||
showOriginalTag = type == MainContentAllType.ORIGINAL || isOriginal,
|
||||
showAdultBadge = isAdult
|
||||
)
|
||||
|
||||
private fun MainContentAudioResponse.toAudioContentTags(): Set<AudioContentTag> = buildSet {
|
||||
if (isOriginalSeries) add(AudioContentTag.Original)
|
||||
if (isFirstContent) add(AudioContentTag.First)
|
||||
if (isPointAvailable) add(AudioContentTag.Point)
|
||||
if (price == 0) add(AudioContentTag.Free)
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.content.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.main.content.data.MainContentAllType
|
||||
import kr.co.vividnext.sodalive.v2.widget.AudioContentTag
|
||||
|
||||
data class MainContentAllAudioUiModel(
|
||||
val audioContentId: Long,
|
||||
val title: String,
|
||||
val imageUrl: String?,
|
||||
val price: Int,
|
||||
val creatorNickname: String,
|
||||
val tags: Set<AudioContentTag>,
|
||||
val showAdultBadge: Boolean
|
||||
)
|
||||
|
||||
data class MainContentAllSeriesUiModel(
|
||||
val seriesId: Long,
|
||||
val title: String,
|
||||
val coverImageUrl: String?,
|
||||
val creatorNickname: String,
|
||||
val showOriginalTag: Boolean,
|
||||
val showAdultBadge: Boolean
|
||||
)
|
||||
|
||||
data class MainContentAllTypeTabUiModel(
|
||||
val type: MainContentAllType,
|
||||
@StringRes val labelResId: Int
|
||||
)
|
||||
|
||||
fun MainContentAllType.toContentAllTypeLabelResId(): Int = when (this) {
|
||||
MainContentAllType.AUDIO -> R.string.screen_content_all_type_audio
|
||||
MainContentAllType.SERIES -> R.string.screen_content_all_type_series
|
||||
MainContentAllType.ORIGINAL -> R.string.screen_content_all_type_original
|
||||
MainContentAllType.FREE -> R.string.screen_content_all_type_free
|
||||
MainContentAllType.POINT -> R.string.screen_content_all_type_point
|
||||
}
|
||||
|
||||
fun MainContentAllType.usesSeriesItems(): Boolean = when (this) {
|
||||
MainContentAllType.SERIES,
|
||||
MainContentAllType.ORIGINAL -> true
|
||||
|
||||
MainContentAllType.AUDIO,
|
||||
MainContentAllType.FREE,
|
||||
MainContentAllType.POINT -> false
|
||||
}
|
||||
|
||||
fun MainContentAllType.usesDayOfWeekQuery(): Boolean = this == MainContentAllType.SERIES
|
||||
@@ -0,0 +1,27 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.content.model
|
||||
|
||||
import kr.co.vividnext.sodalive.home.SeriesPublishedDaysOfWeek
|
||||
import kr.co.vividnext.sodalive.v2.common.data.ContentSort
|
||||
import kr.co.vividnext.sodalive.v2.main.content.data.MainContentAllType
|
||||
|
||||
sealed interface MainContentAllTabUiState {
|
||||
data object Loading : MainContentAllTabUiState
|
||||
|
||||
data class Content(
|
||||
val selectedType: MainContentAllType,
|
||||
val selectedSort: ContentSort,
|
||||
val selectedDayOfWeek: SeriesPublishedDaysOfWeek?,
|
||||
val totalCount: Int,
|
||||
val audioItems: List<MainContentAllAudioUiModel>,
|
||||
val seriesItems: List<MainContentAllSeriesUiModel>,
|
||||
val page: Int,
|
||||
val size: Int,
|
||||
val hasNext: Boolean,
|
||||
val isLoadingMore: Boolean = false,
|
||||
val paginationErrorMessage: String? = null
|
||||
) : MainContentAllTabUiState
|
||||
|
||||
data object Empty : MainContentAllTabUiState
|
||||
|
||||
data class Error(val message: String? = null) : MainContentAllTabUiState
|
||||
}
|
||||
Reference in New Issue
Block a user