feat(creator): 채널 표시와 상대 시간을 정리한다

This commit is contained in:
2026-08-26 16:30:03 +09:00
parent 9939910c71
commit 1f88d721d7
48 changed files with 679 additions and 233 deletions
@@ -463,13 +463,13 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
viewModel { CreatorChannelLiveViewModel(get()) }
viewModel { CreatorChannelAudioViewModel(get()) }
viewModel { CreatorChannelSeriesViewModel(get()) }
viewModel { CreatorChannelCommunityViewModel(get(), get()) }
viewModel { CreatorChannelCommunityDetailViewModel(get(), get(), get()) }
viewModel { CreatorChannelCommunityReplyViewModel(get(), get(), get()) }
viewModel { CreatorChannelFanTalkViewModel(get(), get()) }
viewModel { CreatorChannelFanTalkDetailViewModel(get(), get()) }
viewModel { CreatorChannelCommunityViewModel(get()) }
viewModel { CreatorChannelCommunityDetailViewModel(get(), get()) }
viewModel { CreatorChannelCommunityReplyViewModel(get(), get()) }
viewModel { CreatorChannelFanTalkViewModel(get()) }
viewModel { CreatorChannelFanTalkDetailViewModel(get()) }
viewModel { CreatorChannelFanTalkWriteViewModel(get()) }
viewModel { CreatorChannelDonationViewModel(get(), get()) }
viewModel { CreatorChannelDonationViewModel(get()) }
viewModel { PushNotificationListViewModel(get()) }
viewModel { CharacterTabViewModel(get()) }
viewModel { CharacterDetailViewModel(get()) }
@@ -7,15 +7,13 @@ import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.v2.creator.channel.community.data.CreatorChannelCommunityTabResponse
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityPostUiModel
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.toCommunityPostUiModels
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
class CreatorChannelCommunityViewModel(
private val repository: CreatorChannelRepository,
private val relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
private val repository: CreatorChannelRepository
) : BaseViewModel() {
private val _communityStateLiveData = MutableLiveData<CreatorChannelCommunityUiState>()
@@ -158,7 +156,6 @@ class CreatorChannelCommunityViewModel(
private fun CreatorChannelCommunityTabResponse.toCommunityPostUiModels(): List<CreatorChannelCommunityPostUiModel> =
communityPosts.toCommunityPostUiModels(
relativeTimeTextFormatter = relativeTimeTextFormatter,
isOwner = isOwner,
currentUserId = SharedPreferenceManager.userId
)
@@ -24,6 +24,7 @@ import com.bumptech.glide.request.target.Target
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.common.Constants
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
import kr.co.vividnext.sodalive.databinding.ActivityCreatorChannelCommunityDetailBinding
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.CreatorCommunityPostMenuBottomSheetDialog
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.CreatorCommunityReportDialog
@@ -171,7 +172,8 @@ class CreatorChannelCommunityDetailActivity : BaseActivity<ActivityCreatorChanne
transformations(CircleCropTransformation())
}
tvCreatorChannelCommunityDetailNickname.text = post.creatorNickname
tvCreatorChannelCommunityDetailTime.text = post.createdAtText
tvCreatorChannelCommunityDetailTime.text =
formatUtcRelativeTimeText(tvCreatorChannelCommunityDetailTime.context, post.createdAtUtc)
btnCreatorChannelCommunityDetailMore.isVisible = post.showMore
tvCreatorChannelCommunityDetailBody.text = post.content
layoutCreatorChannelCommunityDetailReaction.isVisible = post.showReaction || content.isCommentAvailable
@@ -11,7 +11,6 @@ import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.ToastMessage
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.explorer.profile.creator_community.CreatorCommunityRepository
import kr.co.vividnext.sodalive.explorer.profile.creator_community.modify.ModifyCommunityPostRequest
import kr.co.vividnext.sodalive.v2.creator.channel.CreatorChannelEvent
@@ -25,8 +24,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
class CreatorChannelCommunityDetailViewModel(
private val repository: CreatorChannelRepository,
private val legacyRepository: CreatorCommunityRepository,
private val relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
private val legacyRepository: CreatorCommunityRepository
) : BaseViewModel() {
private val _detailStateLiveData = MutableLiveData<CreatorChannelCommunityDetailUiState>()
@@ -536,7 +534,7 @@ class CreatorChannelCommunityDetailViewModel(
creatorId = creatorId,
creatorNickname = creatorNickname,
creatorProfileUrl = creatorProfileUrl,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
createdAtUtc = createdAtUtc,
content = content,
imageUrl = imageUrl.takeUnless { isLocked() },
audioUrl = audioUrl.takeUnless { isLocked() },
@@ -566,7 +564,6 @@ class CreatorChannelCommunityDetailViewModel(
memberNickname = writerNickname,
memberProfileUrl = writerProfileImageUrl,
createdAtUtc = createdAtUtc,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
comment = content,
likeCount = 0,
replyCount = if (latestReply != null) 1 else 0,
@@ -586,7 +583,6 @@ class CreatorChannelCommunityDetailViewModel(
memberNickname = writerNickname,
memberProfileUrl = writerProfileImageUrl,
createdAtUtc = createdAtUtc,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
comment = content,
likeCount = 0,
isLiked = false,
@@ -625,7 +621,7 @@ data class CreatorChannelCommunityPostDetailUiModel(
val creatorId: Long,
val creatorNickname: String,
val creatorProfileUrl: String?,
val createdAtText: String,
val createdAtUtc: String,
val content: String,
val imageUrl: String?,
val audioUrl: String?,
@@ -648,7 +644,6 @@ data class CreatorChannelCommunityCommentUiModel(
val memberNickname: String,
val memberProfileUrl: String?,
val createdAtUtc: String,
val createdAtText: String,
val comment: String,
val likeCount: Int,
val replyCount: Int,
@@ -665,7 +660,6 @@ data class CreatorChannelCommunityReplyUiModel(
val memberNickname: String,
val memberProfileUrl: String?,
val createdAtUtc: String,
val createdAtText: String,
val comment: String,
val likeCount: Int,
val isLiked: Boolean,
@@ -12,6 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
import kr.co.vividnext.sodalive.databinding.ActivityCreatorChannelCommunityReplyBinding
import kr.co.vividnext.sodalive.v2.components.modal.V2ModalDialog
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.CreatorChannelCommunityCommentUiModel
@@ -110,6 +111,11 @@ class CreatorChannelCommunityReplyActivity : BaseActivity<ActivityCreatorChannel
onModifyClick = { comment -> viewModel.startParentCommentEdit(comment.comment) },
onDeleteClick = { showDeleteParentCommentDialog() }
)
layoutCreatorChannelCommunityReplyParent.tvCreatorChannelCommunityCommentTime.text =
formatUtcRelativeTimeText(
layoutCreatorChannelCommunityReplyParent.tvCreatorChannelCommunityCommentTime.context,
content.parentComment.createdAtUtc
)
layoutCreatorChannelCommunityReplyParent.layoutCreatorChannelCommunityCommentLatestReply.isVisible = false
replyAdapter.submitItems(content.replies)
if (etCreatorChannelCommunityReply.text.toString() != content.replyInput) {
@@ -183,7 +189,6 @@ class CreatorChannelCommunityReplyActivity : BaseActivity<ActivityCreatorChannel
memberNickname = intent.getStringExtra(EXTRA_MEMBER_NICKNAME).orEmpty(),
memberProfileUrl = intent.getStringExtra(EXTRA_MEMBER_PROFILE_URL),
createdAtUtc = intent.getStringExtra(EXTRA_CREATED_AT_UTC).orEmpty(),
createdAtText = intent.getStringExtra(EXTRA_CREATED_AT_TEXT).orEmpty(),
comment = intent.getStringExtra(EXTRA_COMMENT).orEmpty(),
likeCount = intent.getIntExtra(EXTRA_LIKE_COUNT, 0),
replyCount = intent.getIntExtra(EXTRA_REPLY_COUNT, 0),
@@ -201,7 +206,6 @@ class CreatorChannelCommunityReplyActivity : BaseActivity<ActivityCreatorChannel
private const val EXTRA_MEMBER_NICKNAME = "extra_member_nickname"
private const val EXTRA_MEMBER_PROFILE_URL = "extra_member_profile_url"
private const val EXTRA_CREATED_AT_UTC = "extra_created_at_utc"
private const val EXTRA_CREATED_AT_TEXT = "extra_created_at_text"
private const val EXTRA_COMMENT = "extra_comment"
private const val EXTRA_LIKE_COUNT = "extra_like_count"
private const val EXTRA_REPLY_COUNT = "extra_reply_count"
@@ -217,7 +221,6 @@ class CreatorChannelCommunityReplyActivity : BaseActivity<ActivityCreatorChannel
.putExtra(EXTRA_MEMBER_NICKNAME, parentComment.memberNickname)
.putExtra(EXTRA_MEMBER_PROFILE_URL, parentComment.memberProfileUrl)
.putExtra(EXTRA_CREATED_AT_UTC, parentComment.createdAtUtc)
.putExtra(EXTRA_CREATED_AT_TEXT, parentComment.createdAtText)
.putExtra(EXTRA_COMMENT, parentComment.comment)
.putExtra(EXTRA_LIKE_COUNT, parentComment.likeCount)
.putExtra(EXTRA_REPLY_COUNT, parentComment.replyCount)
@@ -10,7 +10,6 @@ import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.ToastMessage
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.explorer.profile.creator_community.CreatorCommunityRepository
import kr.co.vividnext.sodalive.v2.creator.channel.CreatorChannelEvent
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.CreatorChannelCommunityCommentUiModel
@@ -21,8 +20,7 @@ import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
class CreatorChannelCommunityReplyViewModel(
private val repository: CreatorChannelRepository,
private val legacyRepository: CreatorCommunityRepository,
private val relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
private val legacyRepository: CreatorCommunityRepository
) : BaseViewModel() {
private val _replyStateLiveData = MutableLiveData<CreatorChannelCommunityReplyUiState>()
@@ -57,20 +55,17 @@ class CreatorChannelCommunityReplyViewModel(
private var isModifyingReply = false
fun loadReplies(postId: Long, parentComment: CreatorChannelCommunityCommentUiModel) {
val formattedParentComment = parentComment.copy(
createdAtText = relativeTimeTextFormatter.format(parentComment.createdAtUtc)
)
this.postId = postId
this.parentComment = formattedParentComment
this.parentComment = parentComment
replyRequestGeneration++
isLoadingReplies = false
_replyStateLiveData.value = CreatorChannelCommunityReplyUiState.Content(
parentComment = formattedParentComment,
parentComment = parentComment,
replies = emptyList(),
replyPage = FIRST_PAGE,
hasNextReply = false
)
if (formattedParentComment.commentId > 0) {
if (parentComment.commentId > 0) {
loadReplyPage(page = FIRST_PAGE, append = false)
}
}
@@ -486,7 +481,6 @@ class CreatorChannelCommunityReplyViewModel(
memberNickname = writerNickname,
memberProfileUrl = writerProfileImageUrl,
createdAtUtc = createdAtUtc,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
comment = content,
likeCount = 0,
isLiked = false,
@@ -7,6 +7,7 @@ import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import coil.transform.CircleCropTransformation
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelCommunityReplyBinding
import kr.co.vividnext.sodalive.extensions.loadUrl
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.CreatorChannelCommunityReplyUiModel
@@ -51,7 +52,8 @@ class CreatorChannelCommunityReplyAdapter(
transformations(CircleCropTransformation())
}
tvCreatorChannelCommunityReplyItemNickname.text = item.memberNickname
tvCreatorChannelCommunityReplyItemTime.text = item.createdAtText
tvCreatorChannelCommunityReplyItemTime.text =
formatUtcRelativeTimeText(tvCreatorChannelCommunityReplyItemTime.context, item.createdAtUtc)
tvCreatorChannelCommunityReplyItemBody.text = item.comment
ivCreatorChannelCommunityReplyItemMore.isVisible = item.canShowMore
ivCreatorChannelCommunityReplyItemMore.setOnClickListener { anchor ->
@@ -7,6 +7,7 @@ import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import coil.transform.CircleCropTransformation
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelCommunityCommentBinding
import kr.co.vividnext.sodalive.extensions.loadUrl
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.CreatorChannelCommunityCommentUiModel
@@ -70,7 +71,8 @@ class CreatorChannelCommunityCommentAdapter(
transformations(CircleCropTransformation())
}
tvCreatorChannelCommunityCommentNickname.text = item.memberNickname
tvCreatorChannelCommunityCommentTime.text = item.createdAtText
tvCreatorChannelCommunityCommentTime.text =
formatUtcRelativeTimeText(tvCreatorChannelCommunityCommentTime.context, item.createdAtUtc)
tvCreatorChannelCommunityCommentBody.text = item.comment
ivCreatorChannelCommunityCommentMore.isVisible = item.canShowMore && onDeleteClick != null
ivCreatorChannelCommunityCommentMore.setOnClickListener { anchor ->
@@ -1,20 +1,17 @@
package kr.co.vividnext.sodalive.v2.creator.channel.community.model
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.v2.creator.channel.community.data.CreatorChannelCommunityPostResponse
private const val GRID_PREVIEW_MAX_LENGTH = 24
fun List<CreatorChannelCommunityPostResponse>.toCommunityPostUiModels(
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter,
isOwner: Boolean,
currentUserId: Long
): List<CreatorChannelCommunityPostUiModel> = map {
it.toCommunityPostUiModel(relativeTimeTextFormatter, isOwner, currentUserId)
it.toCommunityPostUiModel(isOwner, currentUserId)
}
private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter,
isOwner: Boolean,
currentUserId: Long
): CreatorChannelCommunityPostUiModel {
@@ -26,7 +23,7 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
creatorId = creatorId,
creatorNickname = creatorNickname,
creatorProfileUrl = creatorProfileUrl,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
createdAtUtc = createdAtUtc,
content = content,
imageUrl = visibleImageUrl,
price = price,
@@ -29,7 +29,7 @@ data class CreatorChannelCommunityPostUiModel(
val creatorId: Long,
val creatorNickname: String,
val creatorProfileUrl: String,
val createdAtText: String,
val createdAtUtc: String,
val content: String,
val imageUrl: String?,
val price: Int,
@@ -15,6 +15,7 @@ import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelCommunityListBinding
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.extensions.loadUrl
@@ -68,7 +69,8 @@ class CreatorChannelCommunityListAdapter(
transformations(CircleCropTransformation())
}
tvCreatorChannelCommunityListNickname.text = item.creatorNickname
tvCreatorChannelCommunityListTime.text = item.createdAtText
tvCreatorChannelCommunityListTime.text =
formatUtcRelativeTimeText(tvCreatorChannelCommunityListTime.context, item.createdAtUtc)
layoutCreatorChannelCommunityListNotice.isVisible = item.showNotice
tvCreatorChannelCommunityListBody.text = item.content
layoutCreatorChannelCommunityListReaction.isVisible = item.showReaction || item.showComment
@@ -194,7 +194,7 @@ private data class CreatorChannelDonationItemLayoutKey(
val nickname: String,
val can: Int,
val message: String,
val createdAtText: String
val createdAtUtc: String
)
private fun CreatorChannelDonationUiState.Content.toContentLayoutKey(): CreatorChannelDonationContentLayoutKey {
@@ -206,7 +206,7 @@ private fun CreatorChannelDonationUiState.Content.toContentLayoutKey(): CreatorC
nickname = donation.nickname,
can = donation.can,
message = donation.message,
createdAtText = donation.createdAtText
createdAtUtc = donation.createdAtUtc
)
}
)
@@ -7,8 +7,6 @@ import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
import kr.co.vividnext.sodalive.v2.creator.channel.donation.data.CreatorChannelDonationTabResponse
import kr.co.vividnext.sodalive.v2.creator.channel.donation.model.CreatorChannelDonationRankingUiModel
@@ -17,15 +15,13 @@ import kr.co.vividnext.sodalive.v2.creator.channel.donation.model.toDonationRank
import kr.co.vividnext.sodalive.v2.creator.channel.donation.model.toDonationUiModels
class CreatorChannelDonationViewModel(
private val repository: CreatorChannelRepository,
private val relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
private val repository: CreatorChannelRepository
) : BaseViewModel() {
private val _donationStateLiveData = MutableLiveData<CreatorChannelDonationUiState>()
val donationStateLiveData: LiveData<CreatorChannelDonationUiState>
get() = _donationStateLiveData
private val context = SodaLiveApplicationHolder.get()
private var creatorId: Long = 0L
private var isOwner: Boolean = false
private var requestGeneration: Int = 0
@@ -222,7 +218,7 @@ class CreatorChannelDonationViewModel(
rankings.toDonationRankingUiModels()
private fun CreatorChannelDonationTabResponse.toDonationUiModels(): List<CreatorChannelDonationUiModel> =
donations.toDonationUiModels(context, relativeTimeTextFormatter)
donations.toDonationUiModels()
private fun authToken(): String = "Bearer ${SharedPreferenceManager.token}"
@@ -1,19 +1,15 @@
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) }
fun List<CreatorChannelDonationResponse>.toDonationUiModels(): List<CreatorChannelDonationUiModel> =
map { it.toDonationUiModel() }
private fun MemberDonationRankingResponse.toDonationRankingUiModel(rank: Int) = CreatorChannelDonationRankingUiModel(
rank = rank,
@@ -23,15 +19,12 @@ private fun MemberDonationRankingResponse.toDonationRankingUiModel(rank: Int) =
donationCan = donationCan
)
private fun CreatorChannelDonationResponse.toDonationUiModel(
context: Context,
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
) = CreatorChannelDonationUiModel(
private fun CreatorChannelDonationResponse.toDonationUiModel() = CreatorChannelDonationUiModel(
nickname = nickname,
profileImageUrl = profileImageUrl,
can = can,
message = message,
createdAtText = createdAtUtc,
createdAtUtc = createdAtUtc,
headerColorResId = calculateDonationHeaderColorRes(can)
)
@@ -15,6 +15,6 @@ data class CreatorChannelDonationUiModel(
val profileImageUrl: String,
val can: Int,
val message: String,
val createdAtText: String,
val createdAtUtc: String,
@param:ColorRes val headerColorResId: Int
)
@@ -128,7 +128,7 @@ class CreatorChannelDonationAdapter(
headerColorResId = item.headerColorResId,
profileImageUrl = item.profileImageUrl,
nickname = item.nickname,
createdAtText = formatUtcRelativeTimeText(context, item.createdAtText),
createdAtText = formatUtcRelativeTimeText(context, item.createdAtUtc),
can = item.can,
message = item.message.takeUnless { it.isBlank() }
?: context.getString(R.string.creator_channel_donation_fallback_message, item.can)
@@ -9,15 +9,13 @@ import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkTabResponse
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkUiModel
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.toFanTalkUiModels
class CreatorChannelFanTalkViewModel(
private val repository: CreatorChannelRepository,
private val relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
private val repository: CreatorChannelRepository
) : BaseViewModel() {
private val _fanTalkStateLiveData = MutableLiveData<CreatorChannelFanTalkUiState>()
@@ -198,7 +196,6 @@ class CreatorChannelFanTalkViewModel(
private fun CreatorChannelFanTalkTabResponse.toFanTalkUiModels(): List<CreatorChannelFanTalkUiModel> =
fanTalks.toFanTalkUiModels(
relativeTimeTextFormatter = relativeTimeTextFormatter,
isOwner = isOwner,
currentUserId = SharedPreferenceManager.userId
)
@@ -19,6 +19,7 @@ import androidx.core.widget.doAfterTextChanged
import coil.transform.CircleCropTransformation
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
import kr.co.vividnext.sodalive.databinding.ActivityCreatorChannelFantalkDetailBinding
import kr.co.vividnext.sodalive.databinding.ViewCreatorChannelFantalkMorePopupBinding
import kr.co.vividnext.sodalive.extensions.loadUrl
@@ -107,7 +108,8 @@ class CreatorChannelFanTalkDetailActivity : BaseActivity<ActivityCreatorChannelF
private fun bindParentFanTalk(item: CreatorChannelFanTalkUiModel) = with(binding) {
ivCreatorChannelFantalkDetailProfile.loadProfile(item.writerProfileImageUrl)
tvCreatorChannelFantalkDetailNickname.text = item.writerNickname
tvCreatorChannelFantalkDetailTime.text = item.createdAtText
tvCreatorChannelFantalkDetailTime.text =
formatUtcRelativeTimeText(tvCreatorChannelFantalkDetailTime.context, item.createdAtUtc)
tvCreatorChannelFantalkDetailContent.text = item.content
ivCreatorChannelFantalkDetailMore.isVisible = false
ivCreatorChannelFantalkDetailMore.setOnClickListener(null)
@@ -123,7 +125,8 @@ class CreatorChannelFanTalkDetailActivity : BaseActivity<ActivityCreatorChannelF
ivCreatorChannelFantalkDetailReplyProfile.loadProfile(reply.writerProfileImageUrl)
tvCreatorChannelFantalkDetailReplyNickname.text = reply.writerNickname
tvCreatorChannelFantalkDetailReplyTime.text = reply.createdAtText
tvCreatorChannelFantalkDetailReplyTime.text =
formatUtcRelativeTimeText(tvCreatorChannelFantalkDetailReplyTime.context, reply.createdAtUtc)
tvCreatorChannelFantalkDetailReplyContent.text = reply.content
ivCreatorChannelFantalkDetailReplyMore.isVisible = reply.fanTalkId > 0L
ivCreatorChannelFantalkDetailReplyMore.setOnClickListener(
@@ -15,7 +15,7 @@ data class CreatorChannelFanTalkDetailPayload(
val writerNickname: String,
val writerProfileImageUrl: String,
val content: String,
val createdAtText: String,
val createdAtUtc: String,
val reply: CreatorChannelFanTalkDetailReplyPayload?,
val showEdit: Boolean,
val showDelete: Boolean
@@ -26,7 +26,7 @@ data class CreatorChannelFanTalkDetailPayload(
writerNickname = writerNickname,
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = createdAtText,
createdAtUtc = createdAtUtc,
reply = reply?.toUiModel(),
rightAction = CreatorChannelFanTalkRightAction.OwnerMore(showEdit = showEdit, showDelete = showDelete)
)
@@ -39,7 +39,7 @@ data class CreatorChannelFanTalkDetailReplyPayload(
val writerNickname: String,
val writerProfileImageUrl: String,
val content: String,
val createdAtText: String
val createdAtUtc: String
) : Parcelable {
fun toUiModel(): CreatorChannelFanTalkReplyUiModel = CreatorChannelFanTalkReplyUiModel(
fanTalkId = fanTalkId,
@@ -47,7 +47,7 @@ data class CreatorChannelFanTalkDetailReplyPayload(
writerNickname = writerNickname,
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = createdAtText
createdAtUtc = createdAtUtc
)
}
@@ -59,7 +59,7 @@ fun CreatorChannelFanTalkUiModel.toFanTalkDetailPayload(): CreatorChannelFanTalk
writerNickname = writerNickname,
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = createdAtText,
createdAtUtc = createdAtUtc,
reply = reply?.toFanTalkDetailReplyPayload(),
showEdit = ownerMore?.showEdit == true,
showDelete = ownerMore?.showDelete == true
@@ -73,7 +73,7 @@ fun CreatorChannelFanTalkReplyUiModel.toFanTalkDetailReplyPayload(): CreatorChan
writerNickname = writerNickname,
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = createdAtText
createdAtUtc = createdAtUtc
)
}
@@ -11,15 +11,13 @@ import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.ToastMessage
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.v2.creator.channel.CreatorChannelEvent
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.toFanTalkReplyUiModel
class CreatorChannelFanTalkDetailViewModel(
private val repository: CreatorChannelRepository,
private val relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
private val repository: CreatorChannelRepository
) : BaseViewModel() {
private val _detailStateLiveData = MutableLiveData<CreatorChannelFanTalkDetailUiState>()
@@ -191,7 +189,7 @@ class CreatorChannelFanTalkDetailViewModel(
val current = currentContent() ?: return
if (response.success) {
_detailStateLiveData.value = current.copy(
reply = response.data?.toFanTalkReplyUiModel(relativeTimeTextFormatter) ?: current.reply,
reply = response.data?.toFanTalkReplyUiModel() ?: current.reply,
replyInput = "",
isSubmitting = false,
editingTarget = null
@@ -1,19 +1,16 @@
package kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkResponse
fun List<CreatorChannelFanTalkResponse>.toFanTalkUiModels(
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter,
isOwner: Boolean,
currentUserId: Long
): List<CreatorChannelFanTalkUiModel> = map {
it.toFanTalkUiModel(relativeTimeTextFormatter, isOwner, currentUserId)
it.toFanTalkUiModel(isOwner, currentUserId)
}
private fun CreatorChannelFanTalkResponse.toFanTalkUiModel(
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter,
isOwner: Boolean,
currentUserId: Long
) = CreatorChannelFanTalkUiModel(
@@ -22,31 +19,27 @@ private fun CreatorChannelFanTalkResponse.toFanTalkUiModel(
writerNickname = writerNickname,
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
reply = creatorReplies.orEmpty().firstOrNull()?.toFanTalkReplyUiModel(relativeTimeTextFormatter),
createdAtUtc = createdAtUtc,
reply = creatorReplies.orEmpty().firstOrNull()?.toFanTalkReplyUiModel(),
rightAction = toRightAction(isOwner = isOwner, currentUserId = currentUserId)
)
fun CreatorChannelFanTalkReplyResponse.toFanTalkReplyUiModel(
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
) = CreatorChannelFanTalkReplyUiModel(
fun CreatorChannelFanTalkReplyResponse.toFanTalkReplyUiModel() = CreatorChannelFanTalkReplyUiModel(
fanTalkId = fanTalkId,
writerId = writerId,
writerNickname = writerNickname,
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc)
createdAtUtc = createdAtUtc
)
fun CreatorChannelFanTalkResponse.toFanTalkReplyUiModel(
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
) = CreatorChannelFanTalkReplyUiModel(
fun CreatorChannelFanTalkResponse.toFanTalkReplyUiModel() = CreatorChannelFanTalkReplyUiModel(
fanTalkId = fanTalkId,
writerId = writerId,
writerNickname = writerNickname,
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc)
createdAtUtc = createdAtUtc
)
private fun CreatorChannelFanTalkResponse.toRightAction(
@@ -6,7 +6,7 @@ data class CreatorChannelFanTalkUiModel(
val writerNickname: String,
val writerProfileImageUrl: String,
val content: String,
val createdAtText: String,
val createdAtUtc: String,
val reply: CreatorChannelFanTalkReplyUiModel?,
val rightAction: CreatorChannelFanTalkRightAction
)
@@ -17,7 +17,7 @@ data class CreatorChannelFanTalkReplyUiModel(
val writerNickname: String,
val writerProfileImageUrl: String,
val content: String,
val createdAtText: String
val createdAtUtc: String
)
sealed interface CreatorChannelFanTalkRightAction {
@@ -7,6 +7,7 @@ import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import coil.transform.CircleCropTransformation
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelFantalkBinding
import kr.co.vividnext.sodalive.extensions.loadUrl
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkReplyUiModel
@@ -51,7 +52,8 @@ class CreatorChannelFanTalkAdapter(
fun bind(item: CreatorChannelFanTalkUiModel) = with(binding) {
ivCreatorChannelFantalkProfile.loadProfile(item.writerProfileImageUrl)
tvCreatorChannelFantalkNickname.text = item.writerNickname
tvCreatorChannelFantalkTime.text = item.createdAtText
tvCreatorChannelFantalkTime.text =
formatUtcRelativeTimeText(tvCreatorChannelFantalkTime.context, item.createdAtUtc)
tvCreatorChannelFantalkContent.text = item.content
root.setOnClickListener { onItemClick(item) }
tvCreatorChannelFantalkContent.setOnClickListener { onItemClick(item) }
@@ -63,6 +65,7 @@ class CreatorChannelFanTalkAdapter(
when (item.rightAction) {
CreatorChannelFanTalkRightAction.Report -> {
tvCreatorChannelFantalkReport.isVisible = true
tvCreatorChannelFantalkReport.text = root.context.getString(R.string.creator_channel_fantalk_report)
tvCreatorChannelFantalkReport.setOnClickListener { onReportClick(item) }
ivCreatorChannelFantalkMore.isVisible = false
ivCreatorChannelFantalkMore.setOnClickListener(null)
@@ -84,7 +87,8 @@ class CreatorChannelFanTalkAdapter(
ivCreatorChannelFantalkReplyProfile.loadProfile(reply.writerProfileImageUrl)
tvCreatorChannelFantalkReplyNickname.text = reply.writerNickname
tvCreatorChannelFantalkReplyTime.text = reply.createdAtText
tvCreatorChannelFantalkReplyTime.text =
formatUtcRelativeTimeText(tvCreatorChannelFantalkReplyTime.context, reply.createdAtUtc)
tvCreatorChannelFantalkReplyContent.text = reply.content
}
@@ -33,7 +33,7 @@ internal fun bindCreatorChannelDonationCard(
}
nicknameView.text = nickname
createdAtView.text = createdAtText
canView.text = context.getString(R.string.creator_channel_donation_can_format, can.moneyFormat())
canView.text = can.moneyFormat()
messageView.text = message
if (headerColorResId == R.color.red_400) {
nicknameView.setTextColor(context.getColor(R.color.white))
@@ -77,7 +77,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:textColor="@color/white"
tools:text="20캔" />
tools:text="20" />
</LinearLayout>
</FrameLayout>
-1
View File
@@ -411,7 +411,6 @@
<string name="creator_channel_home_donation_empty_title">Be the first to\nsupport this creator!</string>
<string name="creator_channel_donation_empty_title">No support yet.\nBe the first to support this creator!</string>
<string name="creator_channel_donation_empty_owner_title">No donation history yet.</string>
<string name="creator_channel_donation_can_format">%1$s cans</string>
<string name="creator_channel_donation_fallback_message">Supported with %1$d cans.</string>
<string name="creator_channel_owner_fab_open">Create content</string>
<string name="creator_channel_owner_fab_community">Post community</string>
-1
View File
@@ -411,7 +411,6 @@
<string name="creator_channel_home_donation_empty_title">最初のサポートをしてみましょう!</string>
<string name="creator_channel_donation_empty_title">まだサポートがありません。\n最初のサポートをしてみましょう!</string>
<string name="creator_channel_donation_empty_owner_title">応援履歴がありません</string>
<string name="creator_channel_donation_can_format">%1$sCAN</string>
<string name="creator_channel_donation_fallback_message">%1$dCANを応援しました。</string>
<string name="creator_channel_owner_fab_open">コンテンツ作成</string>
<string name="creator_channel_owner_fab_community">コミュニティ投稿</string>
-1
View File
@@ -410,7 +410,6 @@
<string name="creator_channel_home_donation_empty_title">처음으로 크리에이터를\n후원해 보세요!</string>
<string name="creator_channel_donation_empty_title">아직 후원이 없습니다.\n처음으로 크리에이터를 후원해 보세요!</string>
<string name="creator_channel_donation_empty_owner_title">후원 내역이 없습니다</string>
<string name="creator_channel_donation_can_format">%1$s캔</string>
<string name="creator_channel_donation_fallback_message">%1$d캔을 후원하였습니다.</string>
<string name="creator_channel_owner_fab_open">콘텐츠 만들기</string>
<string name="creator_channel_owner_fab_community">커뮤니티 글 올리기</string>