mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 16:55:26 +02:00
Using SideEffect to set system bars color
This commit is contained in:
parent
daeaf749fd
commit
984ee4439b
@ -22,6 +22,7 @@ import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import com.sadellie.unitto.data.preferences.AppTheme
|
||||
@ -34,6 +35,7 @@ fun UnittoTheme(
|
||||
) {
|
||||
// Dynamic color is only for Android 12 and higher
|
||||
val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
|
||||
val sysUiController = rememberSystemUiController()
|
||||
|
||||
val colors = when (currentAppTheme) {
|
||||
AppTheme.DARK -> DarkThemeColors
|
||||
@ -54,13 +56,15 @@ fun UnittoTheme(
|
||||
}
|
||||
}
|
||||
|
||||
rememberSystemUiController().setSystemBarsColor(
|
||||
color = colors.background
|
||||
)
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colors,
|
||||
typography = AppTypography,
|
||||
content = content
|
||||
)
|
||||
|
||||
SideEffect {
|
||||
sysUiController.setSystemBarsColor(
|
||||
color = colors.background
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user