Avoid Play Console warning regarding deprecated edge-to-edge API
This commit is contained in:
@@ -19,6 +19,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
|
import androidx.core.view.WindowCompat
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AppTheme(
|
fun AppTheme(
|
||||||
@@ -106,17 +107,23 @@ fun AppTheme(
|
|||||||
DisposableEffect(isDark) {
|
DisposableEffect(isDark) {
|
||||||
val activity = context as? ComponentActivity
|
val activity = context as? ComponentActivity
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
val barStyle = if (isDark)
|
if (VERSION.SDK_INT < 35) {
|
||||||
SystemBarStyle.dark(android.graphics.Color.TRANSPARENT)
|
val barStyle = if (isDark)
|
||||||
else
|
SystemBarStyle.dark(android.graphics.Color.TRANSPARENT)
|
||||||
SystemBarStyle.light(
|
else
|
||||||
android.graphics.Color.TRANSPARENT,
|
SystemBarStyle.light(
|
||||||
android.graphics.Color.TRANSPARENT,
|
android.graphics.Color.TRANSPARENT,
|
||||||
|
android.graphics.Color.TRANSPARENT,
|
||||||
|
)
|
||||||
|
activity.enableEdgeToEdge(
|
||||||
|
statusBarStyle = barStyle,
|
||||||
|
navigationBarStyle = barStyle
|
||||||
)
|
)
|
||||||
activity.enableEdgeToEdge(
|
} else {
|
||||||
statusBarStyle = barStyle,
|
val controller = WindowCompat.getInsetsController(activity.window, view)
|
||||||
navigationBarStyle = barStyle
|
controller.isAppearanceLightStatusBars = !isDark
|
||||||
)
|
controller.isAppearanceLightNavigationBars = !isDark
|
||||||
|
}
|
||||||
if (VERSION.SDK_INT >= 29)
|
if (VERSION.SDK_INT >= 29)
|
||||||
activity.window.isNavigationBarContrastEnforced = false
|
activity.window.isNavigationBarContrastEnforced = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user