fix(creator): 라이브 empty와 CTA 목록 여백을 보정한다

This commit is contained in:
2026-06-18 15:21:26 +09:00
parent f4af9868e6
commit efac753f83
3 changed files with 117 additions and 117 deletions

View File

@@ -3,11 +3,7 @@ package kr.co.vividnext.sodalive.v2.creator.channel.live
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import androidx.recyclerview.widget.LinearLayoutManager
import kr.co.vividnext.sodalive.R
@@ -34,8 +30,7 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
private var lastContentLayoutKey: CreatorChannelLiveContentLayoutKey? = null
private var sortPopup: CreatorChannelLiveSortPopup? = null
private var currentContentState: CreatorChannelLiveUiState.Content? = null
private var isOwner: Boolean = false
private var ownerCtaBottomInset: Int = 0
private var emptyMinHeight: Int = 0
private val creatorId: Long by lazy { arguments?.getLong(ARG_CREATOR_ID) ?: 0L }
private val host: Host
get() = requireActivity() as Host
@@ -44,15 +39,8 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
super.onViewCreated(view, savedInstanceState)
bindLoading()
setupReplayList()
setupOwnerCtaInsets()
setupClickListeners()
observeViewModel()
bindOwnerCta(host.isCreatorChannelOwner())
}
override fun onResume() {
super.onResume()
binding.layoutCreatorChannelLiveOwnerCta.isEnabled = true
}
fun onCreatorChannelLiveTabSelected() {
@@ -78,17 +66,18 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
viewModel.loadMore()
}
fun onCreatorChannelOwnerChanged(isOwner: Boolean) {
bindOwnerCta(isOwner)
fun onCreatorChannelLiveViewportHeightChanged(minHeight: Int) {
emptyMinHeight = minHeight.coerceAtLeast(0)
applyEmptyMinHeight()
}
private fun setupOwnerCtaInsets() {
ViewCompat.setOnApplyWindowInsetsListener(binding.layoutCreatorChannelLiveOwnerCta) { _, insets ->
ownerCtaBottomInset = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom
updateOwnerCtaInsets()
insets
fun onCreatorChannelLiveOwnerCtaVisibilityChanged(isVisible: Boolean) = with(binding) {
val bottomPadding = if (isVisible) {
LIVE_OWNER_CTA_LIST_BOTTOM_PADDING_DP.dpToPx().toInt()
} else {
DEFAULT_LIST_BOTTOM_PADDING_DP.dpToPx().toInt()
}
ViewCompat.requestApplyInsets(binding.layoutCreatorChannelLiveOwnerCta)
rvCreatorChannelLiveReplays.updatePadding(bottom = bottomPadding)
}
private fun setupClickListeners() {
@@ -99,29 +88,6 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
binding.btnCreatorChannelLiveRetry.setOnClickListener {
viewModel.retryLive()
}
binding.layoutCreatorChannelLiveOwnerCta.setOnClickListener {
binding.layoutCreatorChannelLiveOwnerCta.isEnabled = false
host.onCreatorChannelLiveStartClicked()
}
}
private fun bindOwnerCta(isOwner: Boolean) = with(binding) {
this@CreatorChannelLiveFragment.isOwner = isOwner
layoutCreatorChannelLiveOwnerCta.isVisible = isOwner
updateOwnerCtaInsets()
}
private fun updateOwnerCtaInsets() = with(binding) {
val baseBottomMargin = OWNER_CTA_BASE_MARGIN_DP.dpToPx().toInt()
val listBottomPadding = if (isOwner) {
OWNER_CTA_LIST_BOTTOM_PADDING_DP.dpToPx().toInt() + ownerCtaBottomInset
} else {
DEFAULT_LIST_BOTTOM_PADDING_DP.dpToPx().toInt()
}
layoutCreatorChannelLiveOwnerCta.updateLayoutParams<ConstraintLayout.LayoutParams> {
bottomMargin = baseBottomMargin + ownerCtaBottomInset
}
rvCreatorChannelLiveReplays.updatePadding(bottom = listBottomPadding)
}
private fun observeViewModel() {
@@ -141,7 +107,7 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
layoutCreatorChannelLiveSortBar.isVisible = false
layoutCreatorChannelLiveCurrentCard.isVisible = false
rvCreatorChannelLiveReplays.isVisible = false
tvCreatorChannelLiveEmptyMessage.isVisible = false
layoutCreatorChannelLiveEmpty.isVisible = false
tvCreatorChannelLiveErrorMessage.isVisible = false
btnCreatorChannelLiveRetry.isVisible = false
}
@@ -152,19 +118,24 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
layoutCreatorChannelLiveSortBar.isVisible = false
layoutCreatorChannelLiveCurrentCard.isVisible = false
rvCreatorChannelLiveReplays.isVisible = false
tvCreatorChannelLiveEmptyMessage.isVisible = true
layoutCreatorChannelLiveEmpty.isVisible = true
applyEmptyMinHeight()
tvCreatorChannelLiveErrorMessage.isVisible = false
btnCreatorChannelLiveRetry.isVisible = false
host.onCreatorChannelLiveContentChanged()
}
private fun applyEmptyMinHeight() = with(binding) {
layoutCreatorChannelLiveEmpty.minimumHeight = emptyMinHeight
}
private fun bindError(state: CreatorChannelLiveUiState.Error) = with(binding) {
currentContentState = null
lastContentLayoutKey = null
layoutCreatorChannelLiveSortBar.isVisible = false
layoutCreatorChannelLiveCurrentCard.isVisible = false
rvCreatorChannelLiveReplays.isVisible = false
tvCreatorChannelLiveEmptyMessage.isVisible = false
layoutCreatorChannelLiveEmpty.isVisible = false
tvCreatorChannelLiveErrorMessage.isVisible = true
tvCreatorChannelLiveErrorMessage.text = state.message ?: getString(R.string.creator_channel_live_error_message)
btnCreatorChannelLiveRetry.isVisible = true
@@ -173,7 +144,7 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
private fun bindContent(state: CreatorChannelLiveUiState.Content) = with(binding) {
currentContentState = state
tvCreatorChannelLiveEmptyMessage.isVisible = false
layoutCreatorChannelLiveEmpty.isVisible = false
tvCreatorChannelLiveErrorMessage.isVisible = false
btnCreatorChannelLiveRetry.isVisible = false
layoutCreatorChannelLiveSortBar.isVisible = true
@@ -225,18 +196,15 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
}
interface Host {
fun isCreatorChannelOwner(): Boolean
fun onCreatorChannelCurrentLiveClicked(live: CreatorChannelLiveResponse)
fun onCreatorChannelLiveReplayClicked(audioContentId: Long)
fun onCreatorChannelLiveStartClicked()
fun onCreatorChannelLiveContentChanged()
}
companion object {
private const val ARG_CREATOR_ID: String = "arg_creator_id"
private const val DEFAULT_LIST_BOTTOM_PADDING_DP = 32
private const val OWNER_CTA_BASE_MARGIN_DP = 14
private const val OWNER_CTA_LIST_BOTTOM_PADDING_DP = 102
private const val LIVE_OWNER_CTA_LIST_BOTTOM_PADDING_DP = 132
fun newInstance(creatorId: Long): CreatorChannelLiveFragment {
return CreatorChannelLiveFragment().apply {