Optimize - NavigationBarStyle - remove navigation bar white background

This commit is contained in:
2024-03-26 18:52:18 +08:00
parent 1bd81cdf6c
commit 4cc1c0f68b
3 changed files with 5 additions and 21 deletions

View File

@@ -2,7 +2,6 @@ package top.fatweb.oxygen.toolbox
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
@@ -96,9 +95,7 @@ class MainActivity : ComponentActivity() {
android.graphics.Color.TRANSPARENT, android.graphics.Color.TRANSPARENT,
android.graphics.Color.TRANSPARENT android.graphics.Color.TRANSPARENT
) { darkTheme }, ) { darkTheme },
navigationBarStyle = SystemBarStyle.auto( navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT)
lightScrim, darkScrim
) { darkTheme }
) )
} }
@@ -122,10 +119,7 @@ class MainActivity : ComponentActivity() {
OxygenApp(appState) OxygenApp(appState)
} }
} }
Log.d(TAG, "onCreate: C")
} }
Log.d(TAG, "onCreate: D")
} }
@EntryPoint @EntryPoint
@@ -189,15 +183,3 @@ private fun whatLaunchPage(
MainActivityUiState.Loading -> LaunchPageConfig.TOOLS MainActivityUiState.Loading -> LaunchPageConfig.TOOLS
is MainActivityUiState.Success -> uiState.userData.launchPageConfig is MainActivityUiState.Success -> uiState.userData.launchPageConfig
} }
/**
* The default light scrim, as defined by androidx and the platform:
* https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity/activity/src/main/java/androidx/activity/EdgeToEdge.kt;l=35-38;drc=27e7d52e8604a080133e8b842db10c89b4482598
*/
private val lightScrim = android.graphics.Color.argb(0xe6, 0xFF, 0xFF, 0xFF)
/**
* The default dark scrim, as defined by androidx and the platform:
* https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity/activity/src/main/java/androidx/activity/EdgeToEdge.kt;l=40-44;drc=27e7d52e8604a080133e8b842db10c89b4482598
*/
private val darkScrim = android.graphics.Color.argb(0x80, 0x1b, 0x1b, 0x1b)

View File

@@ -63,6 +63,8 @@ class OxygenAppState(
val navController: NavHostController, val navController: NavHostController,
val launchPageConfig: LaunchPageConfig val launchPageConfig: LaunchPageConfig
) { ) {
val topLevelDestinations: List<TopLevelDestination> = TopLevelDestination.entries
val currentDestination: NavDestination? val currentDestination: NavDestination?
@Composable get() = navController @Composable get() = navController
.currentBackStackEntryAsState().value?.destination .currentBackStackEntryAsState().value?.destination
@@ -88,8 +90,6 @@ class OxygenAppState(
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds) started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
) )
val topLevelDestinations: List<TopLevelDestination> = TopLevelDestination.entries
val currentTimeZone = timeZoneMonitor.currentTimeZone val currentTimeZone = timeZoneMonitor.currentTimeZone
.stateIn( .stateIn(
scope = coroutineScope, scope = coroutineScope,

View File

@@ -13,6 +13,7 @@ object ResourcesUtils {
fun getDisplayMetrics(context: Context) = context.resources.displayMetrics fun getDisplayMetrics(context: Context) = context.resources.displayMetrics
@Suppress("DEPRECATION")
fun getAppLocale(context: Context): Locale = fun getAppLocale(context: Context): Locale =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) getConfiguration(context).locales.get(0) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) getConfiguration(context).locales.get(0)
else getConfiguration(context).locale else getConfiguration(context).locale
@@ -27,6 +28,7 @@ object ResourcesUtils {
"Unknown" "Unknown"
} }
@Suppress("DEPRECATION")
fun getAppVersionCode(context: Context): Long = fun getAppVersionCode(context: Context): Long =
try { try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)