feat(creator): 후원 empty 표시 위치를 보정한다

This commit is contained in:
2026-06-22 23:55:50 +09:00
parent 7a705b4355
commit c25acea5d4
5 changed files with 34 additions and 101 deletions

View File

@@ -18,7 +18,12 @@ class CreatorChannelDonationFragment : BaseFragment<FragmentCreatorChannelDonati
private val viewModel: CreatorChannelDonationViewModel by viewModel() private val viewModel: CreatorChannelDonationViewModel by viewModel()
private val donationAdapter = CreatorChannelDonationAdapter( private val donationAdapter = CreatorChannelDonationAdapter(
onRankingAllClick = { host.onCreatorChannelDonationRankingAllClicked() } onRankingAllClick = { host.onCreatorChannelDonationRankingAllClicked() },
onEmptyDonationClick = {
host.onCreatorChannelDonationRequested { can, isSecret, message ->
viewModel.postChannelDonation(can, isSecret, message)
}
}
) )
private var lastContentLayoutKey: CreatorChannelDonationContentLayoutKey? = null private var lastContentLayoutKey: CreatorChannelDonationContentLayoutKey? = null
private val creatorId: Long by lazy { arguments?.getLong(ARG_CREATOR_ID) ?: 0L } private val creatorId: Long by lazy { arguments?.getLong(ARG_CREATOR_ID) ?: 0L }
@@ -56,9 +61,7 @@ class CreatorChannelDonationFragment : BaseFragment<FragmentCreatorChannelDonati
viewModel.refreshDonations() viewModel.refreshDonations()
} }
fun onCreatorChannelDonationViewportHeightChanged(minHeight: Int) { fun onCreatorChannelDonationViewportHeightChanged(minHeight: Int) = Unit
binding.root.minimumHeight = minHeight
}
fun onCreatorChannelDonationFloatingButtonClicked() { fun onCreatorChannelDonationFloatingButtonClicked() {
host.onCreatorChannelDonationRequested { can, isSecret, message -> host.onCreatorChannelDonationRequested { can, isSecret, message ->
@@ -75,11 +78,6 @@ class CreatorChannelDonationFragment : BaseFragment<FragmentCreatorChannelDonati
btnCreatorChannelDonationRetry.setOnClickListener { btnCreatorChannelDonationRetry.setOnClickListener {
viewModel.retryDonations() viewModel.retryDonations()
} }
btnCreatorChannelDonationEmptyWrite.setOnClickListener {
host.onCreatorChannelDonationRequested { can, isSecret, message ->
viewModel.postChannelDonation(can, isSecret, message)
}
}
} }
private fun observeViewModel() { private fun observeViewModel() {
@@ -99,8 +97,6 @@ class CreatorChannelDonationFragment : BaseFragment<FragmentCreatorChannelDonati
lastContentLayoutKey = null lastContentLayoutKey = null
layoutCreatorChannelDonationCountBar.isVisible = false layoutCreatorChannelDonationCountBar.isVisible = false
rvCreatorChannelDonation.isVisible = false rvCreatorChannelDonation.isVisible = false
layoutCreatorChannelDonationEmpty.isVisible = false
btnCreatorChannelDonationEmptyWrite.isVisible = false
tvCreatorChannelDonationErrorMessage.isVisible = false tvCreatorChannelDonationErrorMessage.isVisible = false
btnCreatorChannelDonationRetry.isVisible = false btnCreatorChannelDonationRetry.isVisible = false
host.onCreatorChannelDonationFloatingButtonVisibilityChanged(false) host.onCreatorChannelDonationFloatingButtonVisibilityChanged(false)
@@ -109,16 +105,8 @@ class CreatorChannelDonationFragment : BaseFragment<FragmentCreatorChannelDonati
private fun bindEmpty(state: CreatorChannelDonationUiState.Empty) = with(binding) { private fun bindEmpty(state: CreatorChannelDonationUiState.Empty) = with(binding) {
lastContentLayoutKey = null lastContentLayoutKey = null
layoutCreatorChannelDonationCountBar.isVisible = false layoutCreatorChannelDonationCountBar.isVisible = false
rvCreatorChannelDonation.isVisible = false rvCreatorChannelDonation.isVisible = true
layoutCreatorChannelDonationEmpty.isVisible = true donationAdapter.submitEmpty(state.rankings, state.isOwner)
btnCreatorChannelDonationEmptyWrite.isVisible = !state.isOwner
tvCreatorChannelDonationEmptyMessage.setText(
if (state.isOwner) {
R.string.creator_channel_donation_empty_owner_title
} else {
R.string.creator_channel_donation_empty_title
}
)
tvCreatorChannelDonationErrorMessage.isVisible = false tvCreatorChannelDonationErrorMessage.isVisible = false
btnCreatorChannelDonationRetry.isVisible = false btnCreatorChannelDonationRetry.isVisible = false
host.onCreatorChannelDonationFloatingButtonVisibilityChanged(false) host.onCreatorChannelDonationFloatingButtonVisibilityChanged(false)
@@ -129,8 +117,6 @@ class CreatorChannelDonationFragment : BaseFragment<FragmentCreatorChannelDonati
lastContentLayoutKey = null lastContentLayoutKey = null
layoutCreatorChannelDonationCountBar.isVisible = false layoutCreatorChannelDonationCountBar.isVisible = false
rvCreatorChannelDonation.isVisible = false rvCreatorChannelDonation.isVisible = false
layoutCreatorChannelDonationEmpty.isVisible = false
btnCreatorChannelDonationEmptyWrite.isVisible = false
tvCreatorChannelDonationErrorMessage.isVisible = true tvCreatorChannelDonationErrorMessage.isVisible = true
tvCreatorChannelDonationErrorMessage.text = state.message ?: getString(R.string.creator_channel_donation_error_message) tvCreatorChannelDonationErrorMessage.text = state.message ?: getString(R.string.creator_channel_donation_error_message)
btnCreatorChannelDonationRetry.isVisible = true btnCreatorChannelDonationRetry.isVisible = true
@@ -143,8 +129,6 @@ class CreatorChannelDonationFragment : BaseFragment<FragmentCreatorChannelDonati
tvCreatorChannelDonationTotalCount.text = state.donationCount.moneyFormat() tvCreatorChannelDonationTotalCount.text = state.donationCount.moneyFormat()
rvCreatorChannelDonation.isVisible = true rvCreatorChannelDonation.isVisible = true
donationAdapter.submitItems(state.rankings, state.donations) donationAdapter.submitItems(state.rankings, state.donations)
layoutCreatorChannelDonationEmpty.isVisible = false
btnCreatorChannelDonationEmptyWrite.isVisible = false
tvCreatorChannelDonationErrorMessage.isVisible = false tvCreatorChannelDonationErrorMessage.isVisible = false
btnCreatorChannelDonationRetry.isVisible = false btnCreatorChannelDonationRetry.isVisible = false
host.onCreatorChannelDonationFloatingButtonVisibilityChanged(!state.isOwner) host.onCreatorChannelDonationFloatingButtonVisibilityChanged(!state.isOwner)

View File

@@ -50,63 +50,6 @@
tools:itemCount="3" tools:itemCount="3"
tools:listitem="@layout/item_creator_channel_donation" /> tools:listitem="@layout/item_creator_channel_donation" />
<LinearLayout
android:id="@+id/layout_creator_channel_donation_empty"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:orientation="vertical"
android:paddingHorizontal="@dimen/spacing_14"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<TextView
android:id="@+id/tv_creator_channel_donation_empty_message"
style="@style/Typography.Body3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:includeFontPadding="false"
android:lineSpacingMultiplier="1.45"
android:text="@string/creator_channel_donation_empty_title"
android:textColor="@color/gray_500" />
<LinearLayout
android:id="@+id/btn_creator_channel_donation_empty_write"
android:layout_width="wrap_content"
android:layout_height="44dp"
android:layout_marginTop="@dimen/spacing_14"
android:background="@drawable/bg_creator_channel_donation_empty_button"
android:gravity="center"
android:orientation="horizontal"
android:paddingHorizontal="@dimen/spacing_12"
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@+id/iv_creator_channel_donation_empty_write"
android:layout_width="@dimen/spacing_20"
android:layout_height="@dimen/spacing_20"
android:contentDescription="@null"
android:src="@drawable/ic_new_donation"
app:tint="@color/white" />
<TextView
android:id="@+id/tv_creator_channel_donation_empty_write"
style="@style/Typography.Body2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/spacing_6"
android:gravity="center"
android:text="@string/creator_channel_donation_action"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
<TextView <TextView
android:id="@+id/tv_creator_channel_donation_error_message" android:id="@+id/tv_creator_channel_donation_error_message"
style="@style/Typography.Body3" style="@style/Typography.Body3"

View File

@@ -430,6 +430,7 @@ class CreatorChannelActivitySourceTest {
).readText() ).readText()
val activityLayout = projectFile("app/src/main/res/layout/activity_creator_channel.xml").readText() val activityLayout = projectFile("app/src/main/res/layout/activity_creator_channel.xml").readText()
val donationFragmentLayout = projectFile("app/src/main/res/layout/fragment_creator_channel_donation.xml").readText() val donationFragmentLayout = projectFile("app/src/main/res/layout/fragment_creator_channel_donation.xml").readText()
val donationEmptyItemLayout = projectFile("app/src/main/res/layout/item_creator_channel_donation_empty.xml").readText()
assertTrue(adapter.contains("CreatorChannelDonationFragment.newInstance(creatorId)")) assertTrue(adapter.contains("CreatorChannelDonationFragment.newInstance(creatorId)"))
assertTrue(source.contains("CreatorChannelDonationFragment.Host")) assertTrue(source.contains("CreatorChannelDonationFragment.Host"))
@@ -458,7 +459,7 @@ class CreatorChannelActivitySourceTest {
assertTrue(source.contains("private var isDonationFloatingButtonVisible: Boolean = false")) assertTrue(source.contains("private var isDonationFloatingButtonVisible: Boolean = false"))
assertTrue(source.contains("updateDonationFloatingButtonVisibility()")) assertTrue(source.contains("updateDonationFloatingButtonVisibility()"))
assertTrue(source.contains("findDonationFragment()?.onCreatorChannelDonationFloatingButtonClicked()")) assertTrue(source.contains("findDonationFragment()?.onCreatorChannelDonationFloatingButtonClicked()"))
assertTrue(donationFragmentLayout.contains("btn_creator_channel_donation_empty_write")) assertTrue(donationEmptyItemLayout.contains("btn_creator_channel_donation_empty_write"))
assertFalse(donationFragmentLayout.contains("btn_creator_channel_donation_write")) assertFalse(donationFragmentLayout.contains("btn_creator_channel_donation_write"))
} }

View File

@@ -29,7 +29,8 @@ class CreatorChannelDonationActionTest {
assertTrue(fragment.contains("viewModel.loadDonations(creatorId, isOwner = host.isCreatorChannelOwner())")) assertTrue(fragment.contains("viewModel.loadDonations(creatorId, isOwner = host.isCreatorChannelOwner())"))
assertTrue(fragment.contains("viewModel.loadMore()")) assertTrue(fragment.contains("viewModel.loadMore()"))
assertTrue(fragment.contains("viewModel.refreshDonations()")) assertTrue(fragment.contains("viewModel.refreshDonations()"))
assertTrue(fragment.contains("binding.root.minimumHeight = minHeight")) assertTrue(fragment.contains("fun onCreatorChannelDonationViewportHeightChanged(minHeight: Int)"))
assertFalse(fragment.contains("binding.root.minimumHeight = minHeight"))
} }
@Test @Test
@@ -48,16 +49,14 @@ class CreatorChannelDonationActionTest {
} }
@Test @Test
fun `후원 fragment source는 empty 중앙 button을 타인 채널에서만 표시하고 동일 후원 요청을 전달한다`() { fun `후원 fragment source는 empty 상태를 adapter item으로 표시하고 floating button은 숨긴다`() {
val fragment = projectFile( val fragment = projectFile(
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/donation/CreatorChannelDonationFragment.kt" "app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/donation/CreatorChannelDonationFragment.kt"
).readText() ).readText()
assertTrue(fragment.contains("btnCreatorChannelDonationEmptyWrite.setOnClickListener")) assertTrue(fragment.contains("donationAdapter.submitEmpty(state.rankings, state.isOwner)"))
assertTrue(fragment.contains("btnCreatorChannelDonationEmptyWrite.isVisible = !state.isOwner"))
assertTrue(fragment.contains("host.onCreatorChannelDonationFloatingButtonVisibilityChanged(false)")) assertTrue(fragment.contains("host.onCreatorChannelDonationFloatingButtonVisibilityChanged(false)"))
assertTrue(fragment.contains("host.onCreatorChannelDonationRequested { can, isSecret, message ->")) assertFalse(fragment.contains("btnCreatorChannelDonationEmptyWrite"))
assertTrue(fragment.contains("viewModel.postChannelDonation(can, isSecret, message)"))
} }
@Test @Test
@@ -85,9 +84,14 @@ class CreatorChannelDonationActionTest {
assertTrue(adapter.contains("ItemCreatorChannelDonationBinding")) assertTrue(adapter.contains("ItemCreatorChannelDonationBinding"))
assertTrue(adapter.contains("ItemCreatorChannelDonationRankingBinding")) assertTrue(adapter.contains("ItemCreatorChannelDonationRankingBinding"))
assertTrue(adapter.contains("ItemCreatorChannelDonationEmptyBinding"))
assertTrue(adapter.contains("submitItems")) assertTrue(adapter.contains("submitItems"))
assertTrue(adapter.contains("submitEmpty"))
assertTrue(adapter.contains("onRankingAllClick")) assertTrue(adapter.contains("onRankingAllClick"))
assertTrue(adapter.contains("onEmptyDonationClick"))
assertTrue(adapter.contains("btnCreatorChannelDonationRankingAll.setOnClickListener")) assertTrue(adapter.contains("btnCreatorChannelDonationRankingAll.setOnClickListener"))
assertTrue(adapter.contains("btnCreatorChannelDonationEmptyWrite.isVisible = !isOwner"))
assertTrue(adapter.contains("btnCreatorChannelDonationEmptyWrite.setOnClickListener"))
assertTrue(adapter.contains("setBackgroundColor(root.context.getColor(item.headerColorResId))")) assertTrue(adapter.contains("setBackgroundColor(root.context.getColor(item.headerColorResId))"))
assertTrue(adapter.contains("R.string.creator_channel_donation_can_format")) assertTrue(adapter.contains("R.string.creator_channel_donation_can_format"))
assertTrue(adapter.contains("GridLayoutManager(itemView.context, 4)")) assertTrue(adapter.contains("GridLayoutManager(itemView.context, 4)"))

View File

@@ -23,38 +23,33 @@ import java.io.File
class CreatorChannelDonationFragmentLayoutTest { class CreatorChannelDonationFragmentLayoutTest {
@Test @Test
fun `후원 fragment layout은 list empty error retry floating button을 제공한다`() { fun `후원 fragment layout은 list error retry를 제공하고 empty overlay를 만들지 않는다`() {
val root = inflateView(R.layout.fragment_creator_channel_donation) val root = inflateView(R.layout.fragment_creator_channel_donation)
val layout = projectFile("app/src/main/res/layout/fragment_creator_channel_donation.xml").readText() val layout = projectFile("app/src/main/res/layout/fragment_creator_channel_donation.xml").readText()
val countBar = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_donation_count_bar)) val countBar = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_donation_count_bar))
val donationList = requireNotNull(root.findViewById<RecyclerView>(R.id.rv_creator_channel_donation)) val donationList = requireNotNull(root.findViewById<RecyclerView>(R.id.rv_creator_channel_donation))
val emptyContainer = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_donation_empty))
val emptyMessage = requireNotNull(root.findViewById<TextView>(R.id.tv_creator_channel_donation_empty_message))
val emptyDonationButton = requireNotNull(root.findViewById<LinearLayout>(R.id.btn_creator_channel_donation_empty_write))
val errorMessage = requireNotNull(root.findViewById<TextView>(R.id.tv_creator_channel_donation_error_message)) val errorMessage = requireNotNull(root.findViewById<TextView>(R.id.tv_creator_channel_donation_error_message))
val retryButton = requireNotNull(root.findViewById<TextView>(R.id.btn_creator_channel_donation_retry)) val retryButton = requireNotNull(root.findViewById<TextView>(R.id.btn_creator_channel_donation_retry))
assertSame(root, countBar.parent) assertSame(root, countBar.parent)
assertSame(root, donationList.parent) assertSame(root, donationList.parent)
assertSame(root, emptyContainer.parent)
assertSame(emptyContainer, emptyMessage.parent)
assertSame(emptyContainer, emptyDonationButton.parent)
assertSame(root, errorMessage.parent) assertSame(root, errorMessage.parent)
assertSame(root, retryButton.parent) assertSame(root, retryButton.parent)
assertTrue(layout.contains("android:background=\"@color/black\"")) assertTrue(layout.contains("android:background=\"@color/black\""))
assertTrue(layout.contains("tools:listitem=\"@layout/item_creator_channel_donation\"")) assertTrue(layout.contains("tools:listitem=\"@layout/item_creator_channel_donation\""))
assertTrue(!layout.contains("layout_creator_channel_donation_empty"))
assertTrue(!layout.contains("btn_creator_channel_donation_write")) assertTrue(!layout.contains("btn_creator_channel_donation_write"))
assertTrue(!layout.contains("creator_channel_donation_sort")) assertTrue(!layout.contains("creator_channel_donation_sort"))
} }
@Test @Test
fun `후원 empty layout은 Figma 중앙 capsule 후원하기 button을 제공다`() { fun `후원 empty item layout은 Figma capsule 후원하기 button을 제공하고 minHeight를 쓰지 않는다`() {
val root = inflateView(R.layout.fragment_creator_channel_donation) val item = inflateView(R.layout.item_creator_channel_donation_empty)
val layout = projectFile("app/src/main/res/layout/fragment_creator_channel_donation.xml").readText() val layout = projectFile("app/src/main/res/layout/item_creator_channel_donation_empty.xml").readText()
val emptyContainer = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_donation_empty)) val emptyContainer = requireNotNull(item.findViewById<View>(R.id.layout_creator_channel_donation_empty))
val emptyDonationButton = requireNotNull(root.findViewById<LinearLayout>(R.id.btn_creator_channel_donation_empty_write)) val emptyDonationButton = requireNotNull(item.findViewById<LinearLayout>(R.id.btn_creator_channel_donation_empty_write))
assertSame(emptyContainer, emptyDonationButton.parent) assertSame(emptyContainer, emptyDonationButton.parent)
assertNotNull(emptyDonationButton.findViewById<ImageView>(R.id.iv_creator_channel_donation_empty_write)) assertNotNull(emptyDonationButton.findViewById<ImageView>(R.id.iv_creator_channel_donation_empty_write))
@@ -64,6 +59,8 @@ class CreatorChannelDonationFragmentLayoutTest {
assertTrue(layout.contains("android:background=\"@drawable/bg_creator_channel_donation_empty_button\"")) assertTrue(layout.contains("android:background=\"@drawable/bg_creator_channel_donation_empty_button\""))
assertTrue(layout.contains("android:layout_marginTop=\"@dimen/spacing_14\"")) assertTrue(layout.contains("android:layout_marginTop=\"@dimen/spacing_14\""))
assertTrue(layout.contains("android:src=\"@drawable/ic_new_donation\"")) assertTrue(layout.contains("android:src=\"@drawable/ic_new_donation\""))
assertTrue(layout.contains("android:paddingTop=\"@dimen/spacing_48\""))
assertTrue(!layout.contains("minHeight"))
assertTrue( assertTrue(
projectFile("app/src/main/res/drawable/bg_creator_channel_donation_empty_button.xml") projectFile("app/src/main/res/drawable/bg_creator_channel_donation_empty_button.xml")
.readText() .readText()
@@ -91,6 +88,8 @@ class CreatorChannelDonationFragmentLayoutTest {
val adapter = projectFile( val adapter = projectFile(
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/donation/ui/CreatorChannelDonationAdapter.kt" "app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/donation/ui/CreatorChannelDonationAdapter.kt"
).readText() ).readText()
val rankingIndex = adapter.indexOf("add(CreatorChannelDonationListItem.Ranking(rankings))")
val emptyIndex = adapter.indexOf("add(CreatorChannelDonationListItem.Empty(isOwner))")
assertNotNull(item.findViewById<TextView>(R.id.tv_creator_channel_donation_ranking_title)) assertNotNull(item.findViewById<TextView>(R.id.tv_creator_channel_donation_ranking_title))
assertNotNull(item.findViewById<RecyclerView>(R.id.rv_creator_channel_donation_ranking_members)) assertNotNull(item.findViewById<RecyclerView>(R.id.rv_creator_channel_donation_ranking_members))
@@ -104,6 +103,8 @@ class CreatorChannelDonationFragmentLayoutTest {
assertTrue(adapter.contains("CreatorChannelDonationRankingItemDecoration(itemView.context, spanCount = 4)")) assertTrue(adapter.contains("CreatorChannelDonationRankingItemDecoration(itemView.context, spanCount = 4)"))
assertTrue(adapter.contains("column * spacing / spanCount")) assertTrue(adapter.contains("column * spacing / spanCount"))
assertTrue(adapter.contains("spacing - (column + 1) * spacing / spanCount")) assertTrue(adapter.contains("spacing - (column + 1) * spacing / spanCount"))
assertTrue(rankingIndex >= 0)
assertTrue(emptyIndex > rankingIndex)
} }
@Test @Test