fix(home): 모두 팔로우 완료 상태를 반영한다
This commit is contained in:
@@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.v2.main.home.ui
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
|
|
||||||
object HomeFollowAllButtonBinder {
|
object HomeFollowAllButtonBinder {
|
||||||
@@ -14,6 +15,13 @@ object HomeFollowAllButtonBinder {
|
|||||||
) {
|
) {
|
||||||
val icon = view.findViewById<ImageView>(R.id.iv_home_follow_all_icon)
|
val icon = view.findViewById<ImageView>(R.id.iv_home_follow_all_icon)
|
||||||
val text = view.findViewById<TextView>(R.id.tv_home_follow_all)
|
val text = view.findViewById<TextView>(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)
|
icon.setImageResource(if (isFollowCompleted) R.drawable.ic_new_following else R.drawable.ic_new_follow)
|
||||||
text.setText(
|
text.setText(
|
||||||
if (isFollowCompleted) {
|
if (isFollowCompleted) {
|
||||||
@@ -22,9 +30,15 @@ object HomeFollowAllButtonBinder {
|
|||||||
R.string.home_recommendation_follow_all
|
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 {
|
view.setOnClickListener {
|
||||||
if (creatorIds.isNotEmpty()) onClick(creatorIds)
|
if (!isFollowCompleted && creatorIds.isNotEmpty()) onClick(creatorIds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
android:layout_height="44dp"
|
android:layout_height="44dp"
|
||||||
android:layout_marginHorizontal="@dimen/spacing_20"
|
android:layout_marginHorizontal="@dimen/spacing_20"
|
||||||
android:layout_marginTop="@dimen/spacing_16"
|
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:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
@@ -26,6 +26,6 @@
|
|||||||
android:layout_marginStart="@dimen/spacing_6"
|
android:layout_marginStart="@dimen/spacing_6"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:text="@string/home_recommendation_follow_all"
|
android:text="@string/home_recommendation_follow_all"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/white"
|
||||||
tools:text="모두 팔로우 하기" />
|
tools:text="모두 팔로우 하기" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -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.model.HomeRecommendationLiveUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeAiCharacterAdapter
|
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.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.HomeLiveAdapter
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeRecentDebutCreatorAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeRecentDebutCreatorAdapter
|
||||||
import kr.co.vividnext.sodalive.v2.widget.AudioContentCardView
|
import kr.co.vividnext.sodalive.v2.widget.AudioContentCardView
|
||||||
@@ -112,6 +113,49 @@ class HomeMainFragmentLayoutTest {
|
|||||||
assertNotNull(followAllButton.findViewById<TextView>(R.id.tv_home_follow_all))
|
assertNotNull(followAllButton.findViewById<TextView>(R.id.tv_home_follow_all))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `follow all button default state matches figma active capsule`() {
|
||||||
|
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||||
|
val followAllButton = inflateView(R.layout.view_home_follow_all_button)
|
||||||
|
val icon = followAllButton.findViewById<ImageView>(R.id.iv_home_follow_all_icon)
|
||||||
|
val text = followAllButton.findViewById<TextView>(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<Context>()
|
||||||
|
val followAllButton = inflateView(R.layout.view_home_follow_all_button)
|
||||||
|
val icon = followAllButton.findViewById<ImageView>(R.id.iv_home_follow_all_icon)
|
||||||
|
val text = followAllButton.findViewById<TextView>(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
|
@Test
|
||||||
fun `recent activity creator item matches figma capsule dimensions`() {
|
fun `recent activity creator item matches figma capsule dimensions`() {
|
||||||
val recentActivity = inflateViewWithParent(R.layout.item_home_recent_activity_creator)
|
val recentActivity = inflateViewWithParent(R.layout.item_home_recent_activity_creator)
|
||||||
|
|||||||
Reference in New Issue
Block a user