feat(creator): 채널 홈 스크롤 상태 계산을 추가한다
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.creator.channel.model
|
||||||
|
|
||||||
|
object CreatorChannelScrollState {
|
||||||
|
|
||||||
|
fun shouldUseBlackTitleBar(
|
||||||
|
titleBarBottom: Int,
|
||||||
|
tabBarTop: Int,
|
||||||
|
profileImageVisibleHeight: Int,
|
||||||
|
profileImageTotalHeight: Int
|
||||||
|
): Boolean {
|
||||||
|
val isTabBarCloseToTitleBar = tabBarTop <= titleBarBottom
|
||||||
|
val isProfileImageHalfHidden = profileImageVisibleHeight <= profileImageTotalHeight / 2
|
||||||
|
return isTabBarCloseToTitleBar && isProfileImageHalfHidden
|
||||||
|
}
|
||||||
|
|
||||||
|
fun calculateStickyTop(statusBarHeight: Int, titleBarHeight: Int): Int {
|
||||||
|
return statusBarHeight + titleBarHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.creator.channel
|
||||||
|
|
||||||
|
import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelScrollState
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class CreatorChannelScrollStateTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `title bar와 tab bar가 가까워지고 프로필 이미지가 절반 이상 사라지면 black 전환한다`() {
|
||||||
|
val shouldUseBlackTitleBar = CreatorChannelScrollState.shouldUseBlackTitleBar(
|
||||||
|
titleBarBottom = 88,
|
||||||
|
tabBarTop = 88,
|
||||||
|
profileImageVisibleHeight = 200,
|
||||||
|
profileImageTotalHeight = 402
|
||||||
|
)
|
||||||
|
|
||||||
|
assertTrue(shouldUseBlackTitleBar)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `title bar와 tab bar가 떨어져 있으면 프로필 이미지가 절반 이상 사라져도 black 전환하지 않는다`() {
|
||||||
|
val shouldUseBlackTitleBar = CreatorChannelScrollState.shouldUseBlackTitleBar(
|
||||||
|
titleBarBottom = 88,
|
||||||
|
tabBarTop = 120,
|
||||||
|
profileImageVisibleHeight = 200,
|
||||||
|
profileImageTotalHeight = 402
|
||||||
|
)
|
||||||
|
|
||||||
|
assertFalse(shouldUseBlackTitleBar)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `프로필 이미지가 절반보다 많이 보이면 title bar와 tab bar가 가까워져도 black 전환하지 않는다`() {
|
||||||
|
val shouldUseBlackTitleBar = CreatorChannelScrollState.shouldUseBlackTitleBar(
|
||||||
|
titleBarBottom = 88,
|
||||||
|
tabBarTop = 88,
|
||||||
|
profileImageVisibleHeight = 202,
|
||||||
|
profileImageTotalHeight = 402
|
||||||
|
)
|
||||||
|
|
||||||
|
assertFalse(shouldUseBlackTitleBar)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `sticky top은 status bar 높이와 title bar 높이를 합산한다`() {
|
||||||
|
val stickyTop = CreatorChannelScrollState.calculateStickyTop(
|
||||||
|
statusBarHeight = 28,
|
||||||
|
titleBarHeight = 60
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(88, stickyTop)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user