feat(creator): 라이브 탭 본인 CTA를 연결한다
This commit is contained in:
@@ -387,6 +387,7 @@ class CreatorChannelActivity :
|
||||
bindHeader(header)
|
||||
bindTitleBar(header)
|
||||
updateOwnerFabVisibility()
|
||||
findLiveFragment()?.onCreatorChannelOwnerChanged(header.isOwner)
|
||||
}
|
||||
|
||||
override fun onCreatorChannelFollowProgressChanged(inProgress: Boolean) {
|
||||
@@ -425,6 +426,10 @@ class CreatorChannelActivity :
|
||||
postCheckCreatorChannelLiveNeedsMore()
|
||||
}
|
||||
|
||||
override fun isCreatorChannelOwner(): Boolean {
|
||||
return currentHeader?.isOwner == true
|
||||
}
|
||||
|
||||
private fun setupOwnerFabInsets() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(binding.ownerFabButton) { _, insets ->
|
||||
val navigationBottomInset = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom
|
||||
@@ -556,6 +561,10 @@ class CreatorChannelActivity :
|
||||
startAudioContentDetail(audioContentId)
|
||||
}
|
||||
|
||||
override fun onCreatorChannelLiveStartClicked() {
|
||||
onOwnerFabLiveClicked()
|
||||
}
|
||||
|
||||
private fun findLiveFragment(): CreatorChannelLiveFragment? {
|
||||
val fragmentTag = "f${CreatorChannelTab.Live.ordinal}"
|
||||
return supportFragmentManager.findFragmentByTag(fragmentTag) as? CreatorChannelLiveFragment
|
||||
|
||||
@@ -3,11 +3,17 @@ 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
|
||||
import kr.co.vividnext.sodalive.base.BaseFragment
|
||||
import kr.co.vividnext.sodalive.databinding.FragmentCreatorChannelLiveBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelLiveResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.live.model.toLabelResId
|
||||
@@ -28,6 +34,8 @@ 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 val creatorId: Long by lazy { arguments?.getLong(ARG_CREATOR_ID) ?: 0L }
|
||||
private val host: Host
|
||||
get() = requireActivity() as Host
|
||||
@@ -36,8 +44,15 @@ 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() {
|
||||
@@ -63,6 +78,19 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
viewModel.loadMore()
|
||||
}
|
||||
|
||||
fun onCreatorChannelOwnerChanged(isOwner: Boolean) {
|
||||
bindOwnerCta(isOwner)
|
||||
}
|
||||
|
||||
private fun setupOwnerCtaInsets() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(binding.layoutCreatorChannelLiveOwnerCta) { _, insets ->
|
||||
ownerCtaBottomInset = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom
|
||||
updateOwnerCtaInsets()
|
||||
insets
|
||||
}
|
||||
ViewCompat.requestApplyInsets(binding.layoutCreatorChannelLiveOwnerCta)
|
||||
}
|
||||
|
||||
private fun setupClickListeners() {
|
||||
binding.ivCreatorChannelLiveSort.setImageResource(R.drawable.ic_new_sort)
|
||||
binding.layoutCreatorChannelLiveSortButton.setOnClickListener {
|
||||
@@ -71,6 +99,29 @@ 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() {
|
||||
@@ -174,13 +225,18 @@ 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
|
||||
|
||||
fun newInstance(creatorId: Long): CreatorChannelLiveFragment {
|
||||
return CreatorChannelLiveFragment().apply {
|
||||
|
||||
Reference in New Issue
Block a user