Skip to content

Commit 46cd872

Browse files
committed
Feat: 홈 화면 상태바 콘텐츠 색상 변경 기능 추가
1 parent 297d837 commit 46cd872

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

app/src/main/java/com/threegap/bitnagil/MainActivity.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ class MainActivity : ComponentActivity() {
4646
}
4747

4848
Box(modifier = Modifier.fillMaxSize()) {
49-
MainScreen(
50-
navigator = mainNavigator,
51-
)
49+
MainScreen(navigator = mainNavigator)
5250

5351
BitnagilToastContainer(
5452
state = globalToast,

app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavHost.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package com.threegap.bitnagil.navigation.home
33
import android.annotation.SuppressLint
44
import android.app.Activity
55
import androidx.activity.compose.BackHandler
6+
import androidx.activity.compose.LocalActivity
67
import androidx.compose.foundation.background
78
import androidx.compose.foundation.layout.Box
89
import androidx.compose.foundation.layout.WindowInsets
910
import androidx.compose.foundation.layout.fillMaxSize
1011
import androidx.compose.foundation.layout.padding
1112
import androidx.compose.material3.Scaffold
1213
import androidx.compose.runtime.Composable
14+
import androidx.compose.runtime.SideEffect
1315
import androidx.compose.runtime.getValue
1416
import androidx.compose.runtime.mutableLongStateOf
1517
import androidx.compose.runtime.mutableStateOf
@@ -30,6 +32,7 @@ import com.threegap.bitnagil.presentation.common.toast.GlobalBitnagilToast
3032
import com.threegap.bitnagil.presentation.home.HomeScreenContainer
3133
import com.threegap.bitnagil.presentation.mypage.MyPageScreenContainer
3234
import com.threegap.bitnagil.presentation.recommendroutine.RecommendRoutineScreenContainer
35+
import com.threegap.bitnagil.util.setStatusBarContentColor
3336

3437
@Composable
3538
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@@ -51,6 +54,12 @@ fun HomeNavHost(
5154

5255
DoubleBackButtonPressedHandler()
5356

57+
val activity = LocalActivity.current
58+
val isHomeTab = navigator.isHomeRoute
59+
SideEffect {
60+
activity?.setStatusBarContentColor(isLightContent = isHomeTab)
61+
}
62+
5463
Box(modifier = modifier.fillMaxSize()) {
5564
Scaffold(
5665
modifier = Modifier.fillMaxSize(),

app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavigator.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ class HomeNavigator(
1111
) {
1212
val startDestination = HomeRoute.Home.route
1313

14-
@Composable
15-
fun getCurrentRoute(): String? {
16-
return navController.currentBackStackEntryAsState().value?.destination?.route
17-
}
14+
val currentRoute: String?
15+
@Composable get() = navController.currentBackStackEntryAsState().value?.destination?.route
16+
17+
val isHomeRoute: Boolean
18+
@Composable get() = currentRoute == HomeRoute.Home.route
1819

1920
@Composable
20-
fun shouldShowFloatingAction(): Boolean {
21-
val currentRoute = getCurrentRoute()
22-
return currentRoute == HomeRoute.Home.route || currentRoute == HomeRoute.RecommendRoutine.route
23-
}
21+
fun shouldShowFloatingAction(): Boolean =
22+
currentRoute in setOf(HomeRoute.Home.route, HomeRoute.RecommendRoutine.route)
2423
}
2524

2625
@Composable
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.threegap.bitnagil.util
2+
3+
import android.app.Activity
4+
import androidx.core.view.WindowCompat
5+
6+
fun Activity.setStatusBarContentColor(isLightContent: Boolean) {
7+
val window = this.window
8+
val view = window.decorView
9+
val wic = WindowCompat.getInsetsController(window, view)
10+
11+
wic.isAppearanceLightStatusBars = !isLightContent
12+
}

0 commit comments

Comments
 (0)