|
|
@ -37,6 +37,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import androidx.lifecycle.repeatOnLifecycle
|
|
|
|
import androidx.lifecycle.repeatOnLifecycle
|
|
|
|
import androidx.metrics.performance.JankStats
|
|
|
|
import androidx.metrics.performance.JankStats
|
|
|
|
|
|
|
|
import androidx.tracing.trace
|
|
|
|
import com.google.samples.apps.nowinandroid.MainActivityUiState.Loading
|
|
|
|
import com.google.samples.apps.nowinandroid.MainActivityUiState.Loading
|
|
|
|
import com.google.samples.apps.nowinandroid.MainActivityUiState.Success
|
|
|
|
import com.google.samples.apps.nowinandroid.MainActivityUiState.Success
|
|
|
|
import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper
|
|
|
|
import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper
|
|
|
@ -110,7 +111,7 @@ class MainActivity : ComponentActivity() {
|
|
|
|
// Turn off the decor fitting system windows, which allows us to handle insets,
|
|
|
|
// Turn off the decor fitting system windows, which allows us to handle insets,
|
|
|
|
// including IME animations, and go edge-to-edge
|
|
|
|
// including IME animations, and go edge-to-edge
|
|
|
|
// This also sets up the initial system bar style based on the platform theme
|
|
|
|
// This also sets up the initial system bar style based on the platform theme
|
|
|
|
enableEdgeToEdge()
|
|
|
|
trace("niaEdgeToEdge") { enableEdgeToEdge() }
|
|
|
|
|
|
|
|
|
|
|
|
setContent {
|
|
|
|
setContent {
|
|
|
|
val darkTheme = shouldUseDarkTheme(uiState)
|
|
|
|
val darkTheme = shouldUseDarkTheme(uiState)
|
|
|
@ -120,17 +121,19 @@ class MainActivity : ComponentActivity() {
|
|
|
|
// resolve whether or not to show dark theme using uiState, since it can be different
|
|
|
|
// resolve whether or not to show dark theme using uiState, since it can be different
|
|
|
|
// than the configuration's dark theme value based on the user preference.
|
|
|
|
// than the configuration's dark theme value based on the user preference.
|
|
|
|
DisposableEffect(darkTheme) {
|
|
|
|
DisposableEffect(darkTheme) {
|
|
|
|
enableEdgeToEdge(
|
|
|
|
trace("niaEdgeToEdge") {
|
|
|
|
statusBarStyle = SystemBarStyle.auto(
|
|
|
|
enableEdgeToEdge(
|
|
|
|
android.graphics.Color.TRANSPARENT,
|
|
|
|
statusBarStyle = SystemBarStyle.auto(
|
|
|
|
android.graphics.Color.TRANSPARENT,
|
|
|
|
android.graphics.Color.TRANSPARENT,
|
|
|
|
) { darkTheme },
|
|
|
|
android.graphics.Color.TRANSPARENT,
|
|
|
|
navigationBarStyle = SystemBarStyle.auto(
|
|
|
|
) { darkTheme },
|
|
|
|
lightScrim,
|
|
|
|
navigationBarStyle = SystemBarStyle.auto(
|
|
|
|
darkScrim,
|
|
|
|
lightScrim,
|
|
|
|
) { darkTheme },
|
|
|
|
darkScrim,
|
|
|
|
)
|
|
|
|
) { darkTheme },
|
|
|
|
onDispose {}
|
|
|
|
)
|
|
|
|
|
|
|
|
onDispose {}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val appState = rememberNiaAppState(
|
|
|
|
val appState = rememberNiaAppState(
|
|
|
|