[Fix/#182] 홈 탭 진입 시 상태바 아이콘 색상이 변경되도록 합니다.#183
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
Walkthrough홈 탭 진입 여부를 HomeNavigator의 새 컴포저블 속성으로 노출하고, Activity 확장 함수로 상태바 아이콘 색상 변경을 구현한 뒤 HomeNavHost의 LaunchedEffect에서 해당 함수를 호출하도록 추가했습니다. MainScreen 호출 서식만 간소화되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant HomeNavHost as HomeNavHost (Composable)
participant HomeNavigator as HomeNavigator
participant Activity as Android Activity
participant UIExt as UiExtensions.setStatusBarContentColor
HomeNavHost->>HomeNavigator: 읽기 -> currentRoute / isHomeRoute
Note right of HomeNavigator: composable getters
HomeNavHost->>HomeNavHost: LaunchedEffect(isHomeTab)
HomeNavHost->>Activity: activity?.setStatusBarContentColor(isLightContent = isHomeTab)
Activity->>UIExt: WindowCompat.getInsetsController(...)
UIExt-->>Activity: isAppearanceLightStatusBars 업데이트
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavigator.kt (1)
14-22:currentRoutegetter 중복 구독 및setOf매 리컴포지션 할당
isHomeRoute와shouldShowFloatingAction()모두currentRoute의@Composablegetter를 독립적으로 호출하므로,currentBackStackEntryAsState()가 서로 다른 컴포지션 슬롯에서 두 번 실행되어 동일한 flow에 대한 별도의State객체가 생성됩니다. 또한setOf(...)리터럴이 매 리컴포지션마다 새로 할당됩니다.
currentRoute를 companion object 상수 set과 함께 사용하면 두 문제를 함께 해결할 수 있습니다.♻️ 리팩토링 제안
+ companion object { + private val FLOATING_ACTION_ROUTES = setOf( + HomeRoute.Home.route, + HomeRoute.RecommendRoutine.route, + ) + } + val currentRoute: String? `@Composable` get() = navController.currentBackStackEntryAsState().value?.destination?.route val isHomeRoute: Boolean `@Composable` get() = currentRoute == HomeRoute.Home.route `@Composable` - fun shouldShowFloatingAction(): Boolean = - currentRoute in setOf(HomeRoute.Home.route, HomeRoute.RecommendRoutine.route) + fun shouldShowFloatingAction(): Boolean = + currentRoute in FLOATING_ACTION_ROUTES🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavigator.kt` around lines 14 - 22, Both isHomeRoute and shouldShowFloatingAction independently call the `@Composable` getter currentRoute, causing duplicate subscriptions and setOf(...) to be reallocated on every recomposition; fix by reading currentRoute once in a single `@Composable` scope and reusing it, and move the routing set to a companion object constant to avoid repeated allocations. Specifically, in the composable usage of HomeNavigator (or inside a new `@Composable` wrapper), call val route = homeNavigator.currentRoute once, then compute isHomeRoute as route == HomeRoute.Home.route and shouldShowFloatingAction as route in FLOATING_ACTION_ROUTES, where FLOATING_ACTION_ROUTES is a companion object val = setOf(HomeRoute.Home.route, HomeRoute.RecommendRoutine.route). Ensure currentRoute remains a `@Composable` getter but is read only once per composition.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavigator.kt`:
- Around line 14-22: Both isHomeRoute and shouldShowFloatingAction independently
call the `@Composable` getter currentRoute, causing duplicate subscriptions and
setOf(...) to be reallocated on every recomposition; fix by reading currentRoute
once in a single `@Composable` scope and reusing it, and move the routing set to a
companion object constant to avoid repeated allocations. Specifically, in the
composable usage of HomeNavigator (or inside a new `@Composable` wrapper), call
val route = homeNavigator.currentRoute once, then compute isHomeRoute as route
== HomeRoute.Home.route and shouldShowFloatingAction as route in
FLOATING_ACTION_ROUTES, where FLOATING_ACTION_ROUTES is a companion object val =
setOf(HomeRoute.Home.route, HomeRoute.RecommendRoutine.route). Ensure
currentRoute remains a `@Composable` getter but is read only once per composition.
[ PR Content ]
홈 탭 여부에 따라 상태바 아이콘 색상이 동적으로 변경되도록 구현했습니다.
Related issue
Screenshot 📸
Screen_recording_20260222_140034.mp4
Work Description
setStatusBarContentColor-> 공식문서 linkTo Reviewers 📢
HomeNavigator클래스에 사용중이던getCurrentRoute()가 동작보단 상태가 더 맞다고 생각하여 메소드에서 프로퍼티 방식으로 변경했습니다.Summary by CodeRabbit
릴리스 노트
새로운 기능
리팩토링