diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt index 3eee50c..c210add 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt @@ -111,7 +111,8 @@ fun OxygenApp(appState: OxygenAppState) { visible = appState.shouldShowBottomBar && destination != null, enter = slideInVertically { it }) { BottomAppBar( - scrollBehavior = bottomAppBarScrollBehavior + scrollBehavior = bottomAppBarScrollBehavior, + windowInsets = WindowInsets(0) ) { OxygenBottomBar( destinations = appState.topLevelDestinations, @@ -154,7 +155,8 @@ fun OxygenApp(appState: OxygenAppState) { actionIcon = OxygenIcons.MoreVert, actionIconContentDescription = stringResource(R.string.feature_settings_top_app_bar_action_icon_description), colors = TopAppBarDefaults.centerAlignedTopAppBarColors( - containerColor = Color.Transparent + containerColor = Color.Transparent, + scrolledContainerColor = Color.Transparent ), onNavigationClick = { appState.navigateToSearch() }, onActionClick = { showSettingsDialog = true } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/OxygenTopAppBar.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/OxygenTopAppBar.kt index 3cb8b1a..0792310 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/OxygenTopAppBar.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/OxygenTopAppBar.kt @@ -1,6 +1,8 @@ package top.fatweb.oxygen.toolbox.ui.component import androidx.annotation.StringRes +import androidx.compose.animation.core.animateIntAsState +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.material3.CenterAlignedTopAppBar import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon @@ -11,10 +13,13 @@ import androidx.compose.material3.TopAppBarColors import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import top.fatweb.oxygen.toolbox.icon.OxygenIcons import top.fatweb.oxygen.toolbox.ui.theme.OxygenTheme import android.R as androidR @@ -33,6 +38,10 @@ fun OxygenTopAppBar( onNavigationClick: () -> Unit = {}, onActionClick: () -> Unit = {} ) { + val topInset by animateIntAsState( + if (-scrollBehavior?.state?.heightOffset!! >= with(LocalDensity.current) { 64.0.dp.toPx() }) 0 + else TopAppBarDefaults.windowInsets.getTop(LocalDensity.current), label = "" + ) CenterAlignedTopAppBar( modifier = modifier, scrollBehavior = scrollBehavior, @@ -55,7 +64,8 @@ fun OxygenTopAppBar( ) } }, - colors = colors + colors = colors, + windowInsets = WindowInsets(top = topInset) ) }