fix(widget): CapsuleTab 선택 색상을 보정한다
This commit is contained in:
@@ -70,7 +70,7 @@ class CapsuleTabBarView @JvmOverloads constructor(
|
|||||||
text = label
|
text = label
|
||||||
isSelected = selected
|
isSelected = selected
|
||||||
setTextAppearance(R.style.Typography_Body5)
|
setTextAppearance(R.style.Typography_Body5)
|
||||||
setTextColor(ContextCompat.getColor(context, R.color.white))
|
setTextColor(ContextCompat.getColor(context, if (selected) R.color.black else R.color.white))
|
||||||
background = ContextCompat.getDrawable(
|
background = ContextCompat.getDrawable(
|
||||||
context,
|
context,
|
||||||
if (selected) R.drawable.bg_capsule_tab_selected else R.drawable.bg_capsule_tab_normal
|
if (selected) R.drawable.bg_capsule_tab_selected else R.drawable.bg_capsule_tab_normal
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.widget
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
|
import kr.co.vividnext.sodalive.R
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
import org.robolectric.Shadows.shadowOf
|
||||||
|
import org.robolectric.annotation.Config
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@Config(sdk = [28], application = Application::class)
|
||||||
|
class CapsuleTabBarViewTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `selected tab은 white background와 black text를 사용한다`() {
|
||||||
|
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||||
|
val tabBar = inflateTabBar()
|
||||||
|
|
||||||
|
tabBar.setMenus(listOf("전체", "AI 채팅"), selectedIndex = 0)
|
||||||
|
|
||||||
|
val selectedTab = tabBar.tabAt(0)
|
||||||
|
assertEquals(R.drawable.bg_capsule_tab_selected, shadowOf(selectedTab.background).createdFromResId)
|
||||||
|
assertEquals(context.getColor(R.color.black), selectedTab.currentTextColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `normal tab은 black background와 white text를 사용한다`() {
|
||||||
|
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||||
|
val tabBar = inflateTabBar()
|
||||||
|
|
||||||
|
tabBar.setMenus(listOf("전체", "AI 채팅"), selectedIndex = 0)
|
||||||
|
|
||||||
|
val normalTab = tabBar.tabAt(1)
|
||||||
|
assertEquals(R.drawable.bg_capsule_tab_normal, shadowOf(normalTab.background).createdFromResId)
|
||||||
|
assertEquals(context.getColor(R.color.white), normalTab.currentTextColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun inflateTabBar(): CapsuleTabBarView {
|
||||||
|
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||||
|
return LayoutInflater.from(context).inflate(R.layout.view_capsule_tab_bar, null, false) as CapsuleTabBarView
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun CapsuleTabBarView.tabAt(index: Int): TextView {
|
||||||
|
val container = findViewById<LinearLayout>(R.id.ll_capsule_tab_container)
|
||||||
|
return container.getChildAt(index) as TextView
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user