feat(creator): 라이브 다시듣기 mapper를 추가한다
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.live.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.common.data.ContentSort
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelAudioContentResponse
|
||||
import kr.co.vividnext.sodalive.v2.widget.AudioContentTag
|
||||
|
||||
fun CreatorChannelAudioContentResponse.toReplayUiModel(): CreatorChannelLiveReplayUiModel =
|
||||
CreatorChannelLiveReplayUiModel(
|
||||
audioContentId = audioContentId,
|
||||
title = title,
|
||||
secondaryText = duration,
|
||||
imageUrl = imageUrl,
|
||||
price = price,
|
||||
showAdultBadge = isAdult,
|
||||
tags = toAudioContentTags(),
|
||||
status = toReplayStatus()
|
||||
)
|
||||
|
||||
@StringRes
|
||||
fun ContentSort.toLabelResId(): Int = when (this) {
|
||||
ContentSort.LATEST -> R.string.screen_audio_content_sort_newest
|
||||
ContentSort.POPULAR -> R.string.screen_audio_content_sort_popularity
|
||||
ContentSort.OWNED -> R.string.creator_channel_live_sort_owned
|
||||
ContentSort.PRICE_HIGH -> R.string.screen_audio_content_sort_price_high
|
||||
ContentSort.PRICE_LOW -> R.string.screen_audio_content_sort_price_low
|
||||
}
|
||||
|
||||
fun ContentSort.toSortOptionUiModel(selectedSort: ContentSort): CreatorChannelLiveSortOptionUiModel =
|
||||
CreatorChannelLiveSortOptionUiModel(
|
||||
sort = this,
|
||||
labelResId = toLabelResId(),
|
||||
isSelected = this == selectedSort
|
||||
)
|
||||
|
||||
private fun CreatorChannelAudioContentResponse.toAudioContentTags(): Set<AudioContentTag> = buildSet {
|
||||
if (isOriginalSeries == true) add(AudioContentTag.Original)
|
||||
if (isFirstContent) add(AudioContentTag.First)
|
||||
if (isPointAvailable) add(AudioContentTag.Point)
|
||||
if (price == 0) add(AudioContentTag.Free)
|
||||
}
|
||||
|
||||
private fun CreatorChannelAudioContentResponse.toReplayStatus(): CreatorChannelLiveReplayStatus = when {
|
||||
isOwned -> CreatorChannelLiveReplayStatus.Owned
|
||||
isRented -> CreatorChannelLiveReplayStatus.Rented
|
||||
price == 0 -> CreatorChannelLiveReplayStatus.Play
|
||||
else -> CreatorChannelLiveReplayStatus.Price(price)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.live.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import kr.co.vividnext.sodalive.v2.common.data.ContentSort
|
||||
import kr.co.vividnext.sodalive.v2.widget.AudioContentTag
|
||||
|
||||
data class CreatorChannelLiveReplayUiModel(
|
||||
val audioContentId: Long,
|
||||
val title: String,
|
||||
val secondaryText: String?,
|
||||
val imageUrl: String?,
|
||||
val price: Int,
|
||||
val showAdultBadge: Boolean,
|
||||
val tags: Set<AudioContentTag>,
|
||||
val status: CreatorChannelLiveReplayStatus
|
||||
)
|
||||
|
||||
sealed interface CreatorChannelLiveReplayStatus {
|
||||
data object Play : CreatorChannelLiveReplayStatus
|
||||
data object Owned : CreatorChannelLiveReplayStatus
|
||||
data object Rented : CreatorChannelLiveReplayStatus
|
||||
data class Price(val price: Int) : CreatorChannelLiveReplayStatus
|
||||
}
|
||||
|
||||
data class CreatorChannelLiveSortOptionUiModel(
|
||||
val sort: ContentSort,
|
||||
@param:StringRes val labelResId: Int,
|
||||
val isSelected: Boolean
|
||||
)
|
||||
Reference in New Issue
Block a user