|
15 | 15 | */ |
16 | 16 | package com.example.affirmations.ui.theme |
17 | 17 |
|
18 | | -import android.app.Activity |
19 | 18 | import android.os.Build |
20 | | -import android.view.View |
21 | 19 | import androidx.compose.foundation.isSystemInDarkTheme |
22 | 20 | import androidx.compose.material3.MaterialTheme |
23 | 21 | import androidx.compose.material3.darkColorScheme |
24 | 22 | import androidx.compose.material3.dynamicDarkColorScheme |
25 | 23 | import androidx.compose.material3.dynamicLightColorScheme |
26 | 24 | import androidx.compose.material3.lightColorScheme |
27 | 25 | import androidx.compose.runtime.Composable |
28 | | -import androidx.compose.runtime.SideEffect |
29 | | -import androidx.compose.ui.graphics.Color |
30 | | -import androidx.compose.ui.graphics.toArgb |
31 | 26 | import androidx.compose.ui.platform.LocalContext |
32 | | -import androidx.compose.ui.platform.LocalView |
33 | | -import androidx.core.view.WindowCompat |
34 | 27 |
|
35 | 28 | private val DarkColorScheme = darkColorScheme( |
36 | 29 | surfaceVariant = md_theme_dark_surfaceVariant, |
@@ -60,35 +53,9 @@ fun AffirmationsTheme( |
60 | 53 | darkTheme -> DarkColorScheme |
61 | 54 | else -> LightColorScheme |
62 | 55 | } |
63 | | - val view = LocalView.current |
64 | | - if (!view.isInEditMode) { |
65 | | - SideEffect { |
66 | | - setUpEdgeToEdge(view, darkTheme) |
67 | | - } |
68 | | - } |
69 | 56 |
|
70 | 57 | MaterialTheme( |
71 | 58 | colorScheme = colorScheme, |
72 | 59 | content = content |
73 | 60 | ) |
74 | 61 | } |
75 | | - |
76 | | -/** |
77 | | - * Sets up edge-to-edge for the window of this [view]. The system icon colors are set to either |
78 | | - * light or dark depending on whether the [darkTheme] is enabled or not. |
79 | | - */ |
80 | | -private fun setUpEdgeToEdge(view: View, darkTheme: Boolean) { |
81 | | - val window = (view.context as Activity).window |
82 | | - WindowCompat.setDecorFitsSystemWindows(window, false) |
83 | | - window.statusBarColor = Color.Transparent.toArgb() |
84 | | - val navigationBarColor = when { |
85 | | - Build.VERSION.SDK_INT >= 29 -> Color.Transparent.toArgb() |
86 | | - Build.VERSION.SDK_INT >= 26 -> Color(0xFF, 0xFF, 0xFF, 0x63).toArgb() |
87 | | - // Min sdk version for this app is 24, this block is for SDK versions 24 and 25 |
88 | | - else -> Color(0x00, 0x00, 0x00, 0x50).toArgb() |
89 | | - } |
90 | | - window.navigationBarColor = navigationBarColor |
91 | | - val controller = WindowCompat.getInsetsController(window, view) |
92 | | - controller.isAppearanceLightStatusBars = !darkTheme |
93 | | - controller.isAppearanceLightNavigationBars = !darkTheme |
94 | | -} |
0 commit comments