feat(creator): 채널 홈 팔로우와 탭 동작을 연결한다

This commit is contained in:
2026-06-15 21:00:42 +09:00
parent bfb5440c9e
commit 19b8e4750f
4 changed files with 114 additions and 7 deletions

View File

@@ -10,11 +10,11 @@ import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowCompat
import androidx.recyclerview.widget.LinearLayoutManager
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.audio_content.detail.AudioContentDetailActivity
@@ -22,6 +22,7 @@ import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.chat.talk.room.ChatRoomActivity
import kr.co.vividnext.sodalive.common.Constants
import kr.co.vividnext.sodalive.databinding.ActivityCreatorChannelHomeBinding
import kr.co.vividnext.sodalive.explorer.profile.CreatorFollowNotifyFragment
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.extensions.loadUrl
import kr.co.vividnext.sodalive.extensions.moneyFormat
@@ -46,6 +47,8 @@ class CreatorChannelHomeActivity : BaseActivity<ActivityCreatorChannelHomeBindin
private val sectionAdapter = CreatorChannelHomeSectionAdapter(::onScheduleClicked, ::onAudioContentClicked)
private var creatorId: Long = 0L
private var currentHeader: CreatorChannelHeaderUiModel? = null
private var selectedTab: CreatorChannelTab = CreatorChannelTab.Home
private var isFollowInProgress: Boolean = false
private var statusBarHeight: Int = 0
private val baseTitleBarHeight: Int by lazy { 60.dpToPx().toInt() }
@@ -75,6 +78,8 @@ class CreatorChannelHomeActivity : BaseActivity<ActivityCreatorChannelHomeBindin
private fun setupClickListeners() {
binding.ivBack.setOnClickListener { finish() }
binding.ivMore.setOnClickListener { onMoreClicked() }
binding.layoutFollowCapsule.setOnClickListener { onFollowActionClicked() }
binding.ivBell.setOnClickListener { onFollowActionClicked() }
binding.tvChatButton.setOnClickListener {
currentHeader?.characterId?.let { characterId -> viewModel.createChatRoom(characterId) }
}
@@ -103,6 +108,10 @@ class CreatorChannelHomeActivity : BaseActivity<ActivityCreatorChannelHomeBindin
message?.let { text -> Toast.makeText(applicationContext, text, Toast.LENGTH_LONG).show() }
}
}
viewModel.isFollowInProgressLiveData.observe(this) { inProgress ->
isFollowInProgress = inProgress
currentHeader?.let(::bindTitleBar)
}
}
private fun bindContent(content: CreatorChannelHomeUiState.Content) {
@@ -133,7 +142,7 @@ class CreatorChannelHomeActivity : BaseActivity<ActivityCreatorChannelHomeBindin
val titleBarState = CreatorChannelTitleBarState.from(
isFollow = header.isFollow,
isNotify = header.isNotify,
isInProgress = false
isInProgress = isFollowInProgress
)
binding.ivFollow.setImageResource(titleBarState.followIconResId)
binding.layoutFollowCapsule.isEnabled = titleBarState.isActionEnabled
@@ -150,6 +159,7 @@ class CreatorChannelHomeActivity : BaseActivity<ActivityCreatorChannelHomeBindin
binding.tvFollowLabel.isVisible = !header.isFollow
titleBarState.bellIconResId?.let {
binding.ivBell.setImageResource(it)
binding.ivBell.isEnabled = titleBarState.isActionEnabled
binding.ivBell.visibility = View.VISIBLE
} ?: run {
binding.ivBell.visibility = View.GONE
@@ -158,8 +168,8 @@ class CreatorChannelHomeActivity : BaseActivity<ActivityCreatorChannelHomeBindin
private fun bindTabs(tabs: List<CreatorChannelTab>) {
binding.tabContainer.removeAllViews()
tabs.forEachIndexed { index, tab ->
binding.tabContainer.addView(createTabView(tab, isSelected = index == 0))
tabs.forEach { tab ->
binding.tabContainer.addView(createTabView(tab, isSelected = tab == selectedTab))
}
}
@@ -195,9 +205,37 @@ class CreatorChannelHomeActivity : BaseActivity<ActivityCreatorChannelHomeBindin
}
addView(tabText)
addView(indicator)
setOnClickListener { onTabClicked(tab) }
}
}
private fun onFollowActionClicked() {
if (isFollowInProgress) return
val header = currentHeader ?: return
if (!header.isFollow) {
viewModel.follow(follow = true, notify = true)
return
}
showFollowNotifyFragment()
}
private fun showFollowNotifyFragment() {
val notifyFragment = CreatorFollowNotifyFragment(
onClickNotifyAll = { viewModel.follow(follow = true, notify = true) },
onClickNotifyNone = { viewModel.follow(follow = true, notify = false) },
onClickUnFollow = { viewModel.follow(follow = false, notify = false) }
)
notifyFragment.show(supportFragmentManager, CreatorFollowNotifyFragment::class.java.simpleName)
}
private fun onTabClicked(tab: CreatorChannelTab) {
if (tab != CreatorChannelTab.Home) return
selectedTab = CreatorChannelTab.Home
val content = viewModel.homeStateLiveData.value as? CreatorChannelHomeUiState.Content ?: return
bindTabs(content.tabs)
}
private fun setTitleBarTopInset() {
ViewCompat.setOnApplyWindowInsetsListener(binding.titleBarContainer) { view, insets ->
val topInset = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top

View File

@@ -29,6 +29,10 @@ class CreatorChannelHomeViewModel(
val chatRoomIdLiveData: LiveData<CreatorChannelEvent<Long>>
get() = _chatRoomIdLiveData
private val _isFollowInProgressLiveData = MutableLiveData(false)
val isFollowInProgressLiveData: LiveData<Boolean>
get() = _isFollowInProgressLiveData
private var isFollowInProgress = false
private var isCreateChatRoomInProgress = false
@@ -62,6 +66,7 @@ class CreatorChannelHomeViewModel(
if (isFollowInProgress) return
isFollowInProgress = true
_isFollowInProgressLiveData.value = true
compositeDisposable.add(
repository.followCreator(
creatorId = content.header.creatorId,
@@ -74,6 +79,7 @@ class CreatorChannelHomeViewModel(
.subscribe(
{
isFollowInProgress = false
_isFollowInProgressLiveData.value = false
if (it.success) {
_homeStateLiveData.value = content.copy(
header = content.header.copy(isFollow = follow, isNotify = notify)
@@ -84,6 +90,7 @@ class CreatorChannelHomeViewModel(
},
{
isFollowInProgress = false
_isFollowInProgressLiveData.value = false
it.message?.let { message -> Logger.e(message) }
showUnknownErrorToast()
}