diff --git a/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelScrollState.kt b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelScrollState.kt new file mode 100644 index 00000000..ee95cf15 --- /dev/null +++ b/app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelScrollState.kt @@ -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 + } +} diff --git a/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/CreatorChannelScrollStateTest.kt b/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/CreatorChannelScrollStateTest.kt new file mode 100644 index 00000000..37528795 --- /dev/null +++ b/app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/CreatorChannelScrollStateTest.kt @@ -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) + } +}