feat(creator): 후원 탭 UI 모델 매핑을 추가한다

This commit is contained in:
2026-06-22 21:23:42 +09:00
parent eb71034365
commit 0344518130
3 changed files with 145 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
package kr.co.vividnext.sodalive.v2.creator.channel.donation.model
import android.content.Context
import androidx.annotation.ColorRes
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.v2.creator.channel.donation.data.CreatorChannelDonationResponse
import kr.co.vividnext.sodalive.v2.creator.channel.donation.data.MemberDonationRankingResponse
fun List<MemberDonationRankingResponse>.toDonationRankingUiModels(): List<CreatorChannelDonationRankingUiModel> =
mapIndexed { index, response -> response.toDonationRankingUiModel(rank = index + 1) }
fun List<CreatorChannelDonationResponse>.toDonationUiModels(
context: Context,
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
): List<CreatorChannelDonationUiModel> = map { it.toDonationUiModel(context, relativeTimeTextFormatter) }
private fun MemberDonationRankingResponse.toDonationRankingUiModel(rank: Int) = CreatorChannelDonationRankingUiModel(
rank = rank,
userId = userId,
nickname = nickname,
profileImageUrl = profileImage,
donationCan = donationCan
)
private fun CreatorChannelDonationResponse.toDonationUiModel(
context: Context,
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
) = CreatorChannelDonationUiModel(
nickname = nickname,
profileImageUrl = profileImageUrl,
can = can,
message = message.takeUnless { it.isBlank() } ?: context.getString(R.string.creator_channel_donation_fallback_message, can),
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
headerColorResId = calculateDonationHeaderColorRes(can)
)
@ColorRes
internal fun calculateDonationHeaderColorRes(can: Int): Int = when {
can >= 500 -> R.color.red_400
can >= 101 -> R.color.creator_channel_donation_cyan
can >= 51 -> R.color.green_400
else -> R.color.gray_200
}

View File

@@ -0,0 +1,20 @@
package kr.co.vividnext.sodalive.v2.creator.channel.donation.model
import androidx.annotation.ColorRes
data class CreatorChannelDonationRankingUiModel(
val rank: Int,
val userId: Long,
val nickname: String,
val profileImageUrl: String,
val donationCan: Int
)
data class CreatorChannelDonationUiModel(
val nickname: String,
val profileImageUrl: String,
val can: Int,
val message: String,
val createdAtText: String,
@param:ColorRes val headerColorResId: Int
)