From d3bfc57294b553d73debc1cd6e3da0a6d4c5a058 Mon Sep 17 00:00:00 2001 From: klaus Date: Mon, 15 Jun 2026 19:10:43 +0900 Subject: [PATCH] =?UTF-8?q?feat(creator):=20=EC=B1=84=EB=84=90=20=ED=99=88?= =?UTF-8?q?=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EC=83=81=ED=83=9C=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/CreatorChannelScrollState.kt | 19 +++++++ .../channel/CreatorChannelScrollStateTest.kt | 56 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/model/CreatorChannelScrollState.kt create mode 100644 app/src/test/java/kr/co/vividnext/sodalive/v2/creator/channel/CreatorChannelScrollStateTest.kt 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) + } +}