fix(creator): 라이브 empty와 CTA 목록 여백을 보정한다
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/black">
|
||||
|
||||
<LinearLayout
|
||||
@@ -195,21 +195,27 @@
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/item_creator_channel_live_replay" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_creator_channel_live_empty_message"
|
||||
style="@style/Typography.Body3"
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_creator_channel_live_empty"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/creator_channel_live_empty_message"
|
||||
android:textColor="@color/gray_500"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.58"
|
||||
tools:visibility="visible" />
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_creator_channel_live_empty_message"
|
||||
style="@style/Typography.Body3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="@string/creator_channel_live_empty_message"
|
||||
android:textColor="@color/gray_500" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_creator_channel_live_error_message"
|
||||
@@ -220,11 +226,9 @@
|
||||
android:text="@string/creator_channel_live_error_message"
|
||||
android:textColor="@color/gray_500"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/btn_creator_channel_live_retry"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_creator_channel_live_retry"
|
||||
@@ -239,38 +243,9 @@
|
||||
android:text="@string/creator_channel_live_retry_button"
|
||||
android:textColor="@color/white"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_creator_channel_live_error_message" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_creator_channel_live_owner_cta"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginHorizontal="@dimen/spacing_14"
|
||||
android:layout_marginBottom="@dimen/spacing_14"
|
||||
android:background="@drawable/bg_creator_channel_owner_fab"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_new_create_live" />
|
||||
|
||||
<TextView
|
||||
style="@style/Typography.Body1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/spacing_8"
|
||||
android:includeFontPadding="false"
|
||||
android:text="@string/creator_channel_live_start_button"
|
||||
android:textColor="@color/black" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
Reference in New Issue
Block a user