diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowAllButtonBinder.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowAllButtonBinder.kt index 6290462a..87f00175 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowAllButtonBinder.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowAllButtonBinder.kt @@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.v2.main.home.ui import android.view.View import android.widget.ImageView import android.widget.TextView +import androidx.core.content.ContextCompat import kr.co.vividnext.sodalive.R object HomeFollowAllButtonBinder { @@ -14,6 +15,13 @@ object HomeFollowAllButtonBinder { ) { val icon = view.findViewById(R.id.iv_home_follow_all_icon) val text = view.findViewById(R.id.tv_home_follow_all) + view.setBackgroundResource( + if (isFollowCompleted) { + R.drawable.bg_round_corner_999_white + } else { + R.drawable.bg_home_follow_all_button + } + ) icon.setImageResource(if (isFollowCompleted) R.drawable.ic_new_following else R.drawable.ic_new_follow) text.setText( if (isFollowCompleted) { @@ -22,9 +30,15 @@ object HomeFollowAllButtonBinder { R.string.home_recommendation_follow_all } ) - view.isEnabled = !isFollowCompleted + text.setTextColor( + ContextCompat.getColor( + view.context, + if (isFollowCompleted) R.color.black else R.color.white + ) + ) + view.isEnabled = true view.setOnClickListener { - if (creatorIds.isNotEmpty()) onClick(creatorIds) + if (!isFollowCompleted && creatorIds.isNotEmpty()) onClick(creatorIds) } } } diff --git a/app/src/main/res/layout/view_home_follow_all_button.xml b/app/src/main/res/layout/view_home_follow_all_button.xml index 8d008e56..df80cf3a 100644 --- a/app/src/main/res/layout/view_home_follow_all_button.xml +++ b/app/src/main/res/layout/view_home_follow_all_button.xml @@ -5,7 +5,7 @@ android:layout_height="44dp" android:layout_marginHorizontal="@dimen/spacing_20" android:layout_marginTop="@dimen/spacing_16" - android:background="@drawable/bg_round_corner_999_white" + android:background="@drawable/bg_home_follow_all_button" android:clickable="true" android:focusable="true" android:gravity="center" @@ -26,6 +26,6 @@ android:layout_marginStart="@dimen/spacing_6" android:includeFontPadding="false" android:text="@string/home_recommendation_follow_all" - android:textColor="@color/black" + android:textColor="@color/white" tools:text="모두 팔로우 하기" /> diff --git a/app/src/test/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragmentLayoutTest.kt b/app/src/test/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragmentLayoutTest.kt index ec02121a..597da810 100644 --- a/app/src/test/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragmentLayoutTest.kt +++ b/app/src/test/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragmentLayoutTest.kt @@ -19,6 +19,7 @@ import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationFirstAudioC import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationLiveUiModel import kr.co.vividnext.sodalive.v2.main.home.ui.HomeAiCharacterAdapter import kr.co.vividnext.sodalive.v2.main.home.ui.HomeFirstAudioAdapter +import kr.co.vividnext.sodalive.v2.main.home.ui.HomeFollowAllButtonBinder import kr.co.vividnext.sodalive.v2.main.home.ui.HomeLiveAdapter import kr.co.vividnext.sodalive.v2.main.home.ui.HomeRecentDebutCreatorAdapter import kr.co.vividnext.sodalive.v2.widget.AudioContentCardView @@ -112,6 +113,49 @@ class HomeMainFragmentLayoutTest { assertNotNull(followAllButton.findViewById(R.id.tv_home_follow_all)) } + @Test + fun `follow all button default state matches figma active capsule`() { + val context = ApplicationProvider.getApplicationContext() + val followAllButton = inflateView(R.layout.view_home_follow_all_button) + val icon = followAllButton.findViewById(R.id.iv_home_follow_all_icon) + val text = followAllButton.findViewById(R.id.tv_home_follow_all) + + HomeFollowAllButtonBinder.bind( + view = followAllButton, + creatorIds = listOf(1L), + isFollowCompleted = false, + onClick = {} + ) + + assertEquals(R.drawable.ic_new_follow, shadowOf(icon.drawable).createdFromResId) + assertEquals(R.drawable.bg_home_follow_all_button, shadowOf(followAllButton.background).createdFromResId) + assertEquals(context.getString(R.string.home_recommendation_follow_all), text.text.toString()) + assertEquals(context.getColor(R.color.white), text.currentTextColor) + } + + @Test + fun `follow all button completed state matches figma completed capsule and ignores clicks`() { + val context = ApplicationProvider.getApplicationContext() + val followAllButton = inflateView(R.layout.view_home_follow_all_button) + val icon = followAllButton.findViewById(R.id.iv_home_follow_all_icon) + val text = followAllButton.findViewById(R.id.tv_home_follow_all) + var clickCount = 0 + + HomeFollowAllButtonBinder.bind( + view = followAllButton, + creatorIds = listOf(1L), + isFollowCompleted = true, + onClick = { clickCount += 1 } + ) + followAllButton.performClick() + + assertEquals(R.drawable.ic_new_following, shadowOf(icon.drawable).createdFromResId) + assertEquals(R.drawable.bg_round_corner_999_white, shadowOf(followAllButton.background).createdFromResId) + assertEquals(context.getString(R.string.home_recommendation_follow_all_done), text.text.toString()) + assertEquals(context.getColor(R.color.black), text.currentTextColor) + assertEquals(0, clickCount) + } + @Test fun `recent activity creator item matches figma capsule dimensions`() { val recentActivity = inflateViewWithParent(R.layout.item_home_recent_activity_creator)