Skip to content

Commit

Permalink
style(theme): 沉浸式状态栏
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaoyaning committed Aug 20, 2022
1 parent 297d867 commit 89d6f06
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/src/main/java/com/jyn/composecalculator/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.tooling.preview.Preview
import androidx.core.view.WindowCompat
import androidx.lifecycle.viewmodel.compose.viewModel
import com.apkfuns.logutils.LogUtils
import com.google.accompanist.systemuicontroller.rememberSystemUiController
Expand All @@ -35,6 +36,8 @@ var isDark = false //暗黑模式
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)

LogUtils.getLogConfig().configShowBorders(false)
setContent {
ComposeCalculatorTheme {
Expand All @@ -48,7 +51,7 @@ class MainActivity : ComponentActivity() {
val systemUiController = rememberSystemUiController()
val useDarkIcons = isSystemInDarkTheme()
SideEffect {
systemUiController.setSystemBarsColor(
systemUiController.setStatusBarColor(
color = myTheme.topBg,
darkIcons = !useDarkIcons
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fun TopResultView() {
),
velocityThreshold = 60.dp
),
color = myTheme.topBg,
shape = RoundedCornerShape(bottomStart = 25.dp, bottomEnd = 25.dp),
tonalElevation = 3.dp,
shadowElevation = 3.dp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fun ComposeCalculatorTheme(
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
(view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
(view.context as Activity).window.statusBarColor = myTheme.topBg.toArgb()
ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme
}
}
Expand Down

0 comments on commit 89d6f06

Please sign in to comment.