feat(creator): 라이브 정렬 팝업을 연결한다
This commit is contained in:
@@ -13,6 +13,7 @@ import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelLiveRespon
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.live.model.toLabelResId
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.live.model.toReplayUiModel
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.live.ui.CreatorChannelLiveReplayAdapter
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.live.ui.CreatorChannelLiveSortPopup
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelLiveDateTime
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
@@ -25,6 +26,8 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
host.onCreatorChannelLiveReplayClicked(item.audioContentId)
|
||||
}
|
||||
private var lastContentLayoutKey: CreatorChannelLiveContentLayoutKey? = null
|
||||
private var sortPopup: CreatorChannelLiveSortPopup? = null
|
||||
private var currentContentState: CreatorChannelLiveUiState.Content? = null
|
||||
private val creatorId: Long by lazy { arguments?.getLong(ARG_CREATOR_ID) ?: 0L }
|
||||
private val host: Host
|
||||
get() = requireActivity() as Host
|
||||
@@ -44,6 +47,9 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
sortPopup?.dismiss()
|
||||
sortPopup = null
|
||||
currentContentState = null
|
||||
binding.rvCreatorChannelLiveReplays.adapter = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
@@ -59,6 +65,9 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
|
||||
private fun setupClickListeners() {
|
||||
binding.ivCreatorChannelLiveSort.setImageResource(R.drawable.ic_new_sort)
|
||||
binding.layoutCreatorChannelLiveSortButton.setOnClickListener {
|
||||
currentContentState?.let { state -> showSortPopup(state) }
|
||||
}
|
||||
binding.btnCreatorChannelLiveRetry.setOnClickListener {
|
||||
viewModel.retryLive()
|
||||
}
|
||||
@@ -76,6 +85,7 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
}
|
||||
|
||||
private fun bindLoading() = with(binding) {
|
||||
currentContentState = null
|
||||
lastContentLayoutKey = null
|
||||
layoutCreatorChannelLiveSortBar.isVisible = false
|
||||
layoutCreatorChannelLiveCurrentCard.isVisible = false
|
||||
@@ -86,6 +96,7 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
}
|
||||
|
||||
private fun bindEmpty() = with(binding) {
|
||||
currentContentState = null
|
||||
lastContentLayoutKey = null
|
||||
layoutCreatorChannelLiveSortBar.isVisible = false
|
||||
layoutCreatorChannelLiveCurrentCard.isVisible = false
|
||||
@@ -97,6 +108,7 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
}
|
||||
|
||||
private fun bindError(state: CreatorChannelLiveUiState.Error) = with(binding) {
|
||||
currentContentState = null
|
||||
lastContentLayoutKey = null
|
||||
layoutCreatorChannelLiveSortBar.isVisible = false
|
||||
layoutCreatorChannelLiveCurrentCard.isVisible = false
|
||||
@@ -109,6 +121,7 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
}
|
||||
|
||||
private fun bindContent(state: CreatorChannelLiveUiState.Content) = with(binding) {
|
||||
currentContentState = state
|
||||
tvCreatorChannelLiveEmptyMessage.isVisible = false
|
||||
tvCreatorChannelLiveErrorMessage.isVisible = false
|
||||
btnCreatorChannelLiveRetry.isVisible = false
|
||||
@@ -125,6 +138,15 @@ class CreatorChannelLiveFragment : BaseFragment<FragmentCreatorChannelLiveBindin
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSortPopup(state: CreatorChannelLiveUiState.Content) {
|
||||
sortPopup?.dismiss()
|
||||
sortPopup = CreatorChannelLiveSortPopup(
|
||||
anchor = binding.layoutCreatorChannelLiveSortButton,
|
||||
selectedSort = state.selectedSort,
|
||||
onSortSelected = { sort -> viewModel.changeSort(sort) }
|
||||
).also { it.show() }
|
||||
}
|
||||
|
||||
private fun notifyContentChangedIfLayoutChanged(state: CreatorChannelLiveUiState.Content) {
|
||||
val contentLayoutKey = state.toContentLayoutKey()
|
||||
if (contentLayoutKey == lastContentLayoutKey) return
|
||||
|
||||
Reference in New Issue
Block a user