From 2c609836fd5f2975b4e0c5e97c949159e2af2c62 Mon Sep 17 00:00:00 2001 From: klaus Date: Mon, 13 Jul 2026 16:17:12 +0900 Subject: [PATCH] =?UTF-8?q?fix(home):=20=ED=8C=94=EB=A1=9C=EC=9E=89=20empt?= =?UTF-8?q?y=20=EB=AC=B8=EA=B5=AC=EB=A5=BC=20=EC=A4=91=EC=95=99=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/v2/main/home/HomeMainFragment.kt | 8 +++-- .../main/res/layout/fragment_v2_main_home.xml | 11 +++++++ .../home/HomeFollowingFragmentSourceTest.kt | 32 +++++++++++++++++-- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt index 3e2994b9..186f8472 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt @@ -313,9 +313,9 @@ class HomeMainFragment : BaseFragment( homeFollowingViewModel.followingStateLiveData.observe(viewLifecycleOwner) { state -> when (state) { is HomeFollowingUiState.Content -> bindHomeFollowingContent(state) + HomeFollowingUiState.Empty -> bindHomeFollowingEmpty(showEmptyMessage = true) HomeFollowingUiState.LoginRequired, - HomeFollowingUiState.Empty, - is HomeFollowingUiState.Error -> bindHomeFollowingEmpty() + is HomeFollowingUiState.Error -> bindHomeFollowingEmpty(showEmptyMessage = false) HomeFollowingUiState.Loading -> Unit } @@ -378,6 +378,7 @@ class HomeMainFragment : BaseFragment( } private fun bindHomeFollowingContent(content: HomeFollowingUiState.Content) { + binding.tvHomeFollowingEmpty.visibility = View.GONE bindFollowingCreatorSection(content.followingCreators) bindFollowingLiveSection(content.onAirLives) bindFollowingChatSection(content.recentChats) @@ -385,7 +386,8 @@ class HomeMainFragment : BaseFragment( bindFollowingNewsSection(content.recentNews) } - private fun bindHomeFollowingEmpty() { + private fun bindHomeFollowingEmpty(showEmptyMessage: Boolean) { + binding.tvHomeFollowingEmpty.visibility = if (showEmptyMessage) View.VISIBLE else View.GONE binding.llHomeFollowingCreatorsSection.visibility = View.GONE binding.llHomeFollowingOnAirSection.visibility = View.GONE binding.llHomeFollowingRecentChatsSection.visibility = View.GONE diff --git a/app/src/main/res/layout/fragment_v2_main_home.xml b/app/src/main/res/layout/fragment_v2_main_home.xml index da243f7f..efa033e5 100644 --- a/app/src/main/res/layout/fragment_v2_main_home.xml +++ b/app/src/main/res/layout/fragment_v2_main_home.xml @@ -236,6 +236,17 @@ android:orientation="vertical" android:paddingBottom="@dimen/spacing_28"> + + bindHomeFollowingContent(state)")) + assertTrue(source.contains("HomeFollowingUiState.Empty -> bindHomeFollowingEmpty(showEmptyMessage = true)")) assertTrue(source.contains("HomeFollowingUiState.LoginRequired,")) - assertTrue(source.contains("HomeFollowingUiState.Empty,")) - assertTrue(source.contains("is HomeFollowingUiState.Error -> bindHomeFollowingEmpty()")) + assertTrue(source.contains("is HomeFollowingUiState.Error -> bindHomeFollowingEmpty(showEmptyMessage = false)")) assertTrue(source.contains("followingCreatorAdapter.submitItems(emptyList())")) assertTrue(source.contains("followingLiveAdapter.submitItems(emptyList())")) assertTrue(source.contains("followingChatAdapter.submitItems(emptyList())")) @@ -97,6 +97,34 @@ class HomeFollowingFragmentSourceTest { assertTrue(source.contains("bindFollowingNewsSection(content.recentNews)")) } + @Test + fun `following empty state shows centered reusable empty string only for all empty content`() { + val layout = homeMainLayoutSource() + val emptyText = layout.substringAfter("@+id/tv_home_following_empty") + .substringBefore("@+id/ll_home_following_creators_section") + val source = homeMainFragmentSource() + val strings = projectFile("app/src/main/res/values/strings.xml").readText() + val stringsEn = projectFile("app/src/main/res/values-en/strings.xml").readText() + val stringsJa = projectFile("app/src/main/res/values-ja/strings.xml").readText() + + assertTrue(layout.contains("@+id/tv_home_following_empty")) + assertTrue(emptyText.contains("android:layout_width=\"match_parent\"")) + assertTrue(emptyText.contains("android:layout_height=\"match_parent\"")) + assertTrue(emptyText.contains("android:gravity=\"center\"")) + assertTrue(emptyText.contains("android:textAlignment=\"center\"")) + assertTrue(emptyText.contains("android:text=\"@string/screen_home_following_empty\"")) + assertTrue(emptyText.contains("android:visibility=\"gone\"")) + + assertTrue(strings.contains("아직 팔로잉 소식이 없어요.\\n관심 있는 크리에이터를 팔로우해 보세요.")) + assertTrue(stringsEn.contains("No following updates yet.\\nFollow creators you are interested in.")) + assertTrue(stringsJa.contains("フォロー中のお知らせはまだありません。\\n気になるクリエイターをフォローしてみましょう。")) + + assertTrue(source.contains("binding.tvHomeFollowingEmpty.visibility = View.GONE")) + assertTrue(source.contains("binding.tvHomeFollowingEmpty.visibility = if (showEmptyMessage) View.VISIBLE else View.GONE")) + assertTrue(source.contains("HomeFollowingUiState.Empty -> bindHomeFollowingEmpty(showEmptyMessage = true)")) + assertTrue(source.contains("is HomeFollowingUiState.Error -> bindHomeFollowingEmpty(showEmptyMessage = false)")) + } + @Test fun `following adapters bind figma required item fields`() { val liveAdapter = projectFile(