Repository navigation
fix(core-ui,app): 다크 팔레트 확정까지 팔레트·시스템바를 라이트로 잠근다 (#1873) #1723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b5f0b1
fix(core-ui): 다크 팔레트 확정 전까지 라이트로 잠근다 (#1719)
Sadturtleman f610b08
fix(app): 시스템바 아이콘도 라이트로 잠근다 (#1719)
Sadturtleman db5d2fd
fix(konsist): 헬퍼 제외를 파일명이 아니라 경로로 판정한다 (#1719)
Sadturtleman f331cbf
fix(app): API 27 속성을 values-v27 로 옮긴다 (#1873)
Sadturtleman 2ebb573
Merge remote-tracking branch 'origin/develop' into fix/1719-lock-ligh…
Sadturtleman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/afternote/afternote_fe/LightEdgeToEdge.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.afternote.afternote_fe | ||
|
|
||
| import android.graphics.Color | ||
| import androidx.activity.ComponentActivity | ||
| import androidx.activity.SystemBarStyle | ||
| import androidx.activity.enableEdgeToEdge | ||
|
|
||
| /** | ||
| * 시스템바 아이콘까지 라이트로 고정한 edge-to-edge (#1719). | ||
| * | ||
| * 무인자 [enableEdgeToEdge] 는 `SystemBarStyle.auto` 라 `uiMode == NIGHT_YES` 면 | ||
| * `isAppearanceLightStatusBars` 를 `false` 로 잡아 **흰 아이콘**을 고른다. 그런데 | ||
| * `AfternoteTheme` 이 라이트로 잠긴 뒤로 Compose 는 다크 기기에서도 `gray1`(#FAFAFA) 을 | ||
| * 상태바 밑까지 그린다. 둘을 그대로 두면 밝은 배경 위에 흰 시계·배터리·제스처 바가 얹혀 | ||
| * 모든 화면에서 보이지 않는다. | ||
| * | ||
| * 그래서 시스템바 스타일도 함께 라이트로 못박는다. **`AfternoteTheme` 의 `isDarkTheme` | ||
| * 기본값을 시스템 추종으로 되돌릴 때 이 함수도 같이 되돌린다** — 두 자리는 한 쌍이다. | ||
| */ | ||
| fun ComponentActivity.enableLightEdgeToEdge() { | ||
| enableEdgeToEdge( | ||
| statusBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT), | ||
| navigationBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT), | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
|
|
||
| <!-- | ||
| `android:windowLightNavigationBar` 는 API 27 부터다. minSdk 26 이라 기본 values/ 에 두면 | ||
| `:app:lintDebug` 가 NewApi 로 죽는다 (#1873). | ||
|
|
||
| 내용은 values/ 의 같은 스타일과 한 쌍이다 — 앱이 라이트로 잠긴 동안 스플래시의 밝은 배경 | ||
| (#FAFAFA) 위에 흰 시스템바 아이콘이 얹히지 않게 한다. 다크 팔레트를 되살릴 때 | ||
| AfternoteTheme 의 isDarkTheme·enableLightEdgeToEdge·values/themes.xml 과 함께 되돌린다. | ||
| --> | ||
| <style name="Theme.Afternotefe.Starting" parent="Theme.SplashScreen"> | ||
| <item name="windowSplashScreenBackground">@color/splash_background</item> | ||
| <item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item> | ||
| <item name="postSplashScreenTheme">@style/Theme.Afternotefe.Main</item> | ||
| <item name="android:windowLightStatusBar">true</item> | ||
| <item name="android:windowLightNavigationBar">true</item> | ||
| </style> | ||
| </resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
core/ui/src/test/kotlin/com/afternote/core/ui/theme/ThemeDarkModeLockTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package com.afternote.core.ui.theme | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.test.junit4.v2.createComposeRule | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import org.robolectric.RobolectricTestRunner | ||
| import org.robolectric.annotation.Config | ||
|
|
||
| /** | ||
| * 시스템 다크모드를 따라가지 않는다는 계약 (#1719). | ||
| * | ||
| * 종전 기본값은 `isSystemInDarkTheme()` 이었는데, 다크 팔레트를 물려도 **화면이 따라오지 | ||
| * 않았다** — 색을 토큰이 아니라 코드에 박은 자리가 반전되지 않아, 「마음의 기록」 헤더가 | ||
| * 검정 배경에 검정 글자로 남고 주간 요약 카드는 배경만 밝은 채로 라벨이 흐려졌다. | ||
| * 「배선은 됐고 화면은 안 맞은」 중간 상태가 라이트 고정보다도, 완전한 다크 지원보다도 | ||
| * 나빴다. 그래서 팔레트가 확정될 때까지 라이트로 잠근다. | ||
| * | ||
| * 이 테스트가 지키는 것은 **잠금이 조용히 풀리지 않는 것**이다. 기본값을 | ||
| * `isSystemInDarkTheme()` 으로 되돌리면 첫 번째 테스트가 night 한정자에서 실패한다. | ||
| * 되돌릴 때는 하드코딩 색 29곳을 토큰으로 옮긴 뒤 이 테스트도 같이 고쳐야 한다. | ||
| */ | ||
| @RunWith(RobolectricTestRunner::class) | ||
| @Config(sdk = [35]) | ||
| class ThemeDarkModeLockTest { | ||
| @get:Rule | ||
| val composeRule = createComposeRule() | ||
|
|
||
| private fun resolveIsLightMode(theme: @Composable (@Composable () -> Unit) -> Unit): Boolean { | ||
| var isLightMode: Boolean? = null | ||
| composeRule.setContent { | ||
| theme { isLightMode = AfternoteDesign.colors.isLightMode } | ||
| } | ||
| composeRule.waitForIdle() | ||
| return requireNotNull(isLightMode) { "테마가 content 를 부르지 않았다" } | ||
| } | ||
|
|
||
| @Test | ||
| @Config(qualifiers = "night") | ||
| fun `시스템이 다크여도 기본값은 라이트 팔레트다`() { | ||
| assertEquals(true, resolveIsLightMode { content -> AfternoteTheme(content = content) }) | ||
| } | ||
|
|
||
| @Test | ||
| @Config(qualifiers = "notnight") | ||
| fun `시스템이 라이트일 때도 당연히 라이트 팔레트다`() { | ||
| assertEquals(true, resolveIsLightMode { content -> AfternoteTheme(content = content) }) | ||
| } | ||
|
|
||
| /** | ||
| * 잠금은 **기본값** 에만 걸린다. 다크 팔레트와 파라미터는 팔레트 확정 뒤를 위해 살아 있어야 | ||
| * 하고, 그때 이 값을 다시 시스템에 묶는 것으로 되돌린다. | ||
| */ | ||
| @Test | ||
| @Config(qualifiers = "notnight") | ||
| fun `명시로 넘기면 다크 팔레트를 여전히 그릴 수 있다`() { | ||
| assertEquals( | ||
| false, | ||
| resolveIsLightMode { content -> AfternoteTheme(isDarkTheme = true, content = content) }, | ||
| ) | ||
| } | ||
| } | ||
38 changes: 38 additions & 0 deletions
38
konsist/src/test/kotlin/com/afternote/konsist/LightSystemBarLockKonsistTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package com.afternote.konsist | ||
|
|
||
| import com.lemonappdev.konsist.api.verify.assertFalse | ||
| import org.junit.Test | ||
|
|
||
| /** | ||
| * 시스템바가 라이트로 잠긴 채 남는지 (#1719). | ||
| * | ||
| * `AfternoteTheme` 이 라이트로 잠긴 동안 Compose 는 다크 기기에서도 `gray1`(#FAFAFA) 을 | ||
| * 상태바 밑까지 그린다. 무인자 `enableEdgeToEdge()` 는 `SystemBarStyle.auto` 라 그 기기에서 | ||
| * 흰 아이콘을 고르므로, 밝은 배경 위에 흰 시계·배터리가 얹혀 사라진다. | ||
| * | ||
| * 그래서 `app` 의 호출부는 [com.afternote.afternote_fe.enableLightEdgeToEdge] 하나로 모았다. | ||
| * 이 가드는 **무인자 호출이 다시 스며드는 것**을 막는다 — 새 Activity 를 만들 때 손이 먼저 | ||
| * 기억하는 형태가 그쪽이라서다. | ||
| * | ||
| * 다크 팔레트가 확정돼 잠금을 풀 때는 이 가드도 함께 지운다. 되돌릴 자리는 셋이다 — | ||
| * `AfternoteTheme` 의 `isDarkTheme` 기본값 · `enableLightEdgeToEdge()` · `themes.xml` 의 | ||
| * `windowLightStatusBar`. | ||
| */ | ||
| class LightSystemBarLockKonsistTest { | ||
| @Test | ||
| fun `app 은 무인자 enableEdgeToEdge 를 쓰지 않는다`() { | ||
| AfternoteKonsistScope | ||
| .files | ||
| .filter { file -> file.path.contains("/app/src/") } | ||
| .filterNot { file -> file.path.endsWith("/$HELPER_FILE") } | ||
| .assertFalse { file -> BARE_CALL.containsMatchIn(file.text) } | ||
| } | ||
|
|
||
| private companion object { | ||
| /** 잠금을 실제로 거는 자리. 여기만 `enableEdgeToEdge` 를 인자와 함께 부른다. */ | ||
| const val HELPER_FILE = "LightEdgeToEdge.kt" | ||
|
|
||
| /** `enableEdgeToEdge()` — 인자 없는 호출. 공백만 허용한다. */ | ||
| val BARE_CALL = Regex("""\benableEdgeToEdge\s*\(\s*\)""") | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] 클래스
@Config(sdk=[35])와 메서드@Config(sdk=[35], qualifiers=…)의 sdk 가 중복입니다 — 메서드엔qualifiers만 둬도 병합됩니다. 무해합니다.