diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/components/GradientTopBar.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/components/GradientTopBar.kt index 2b3996e7d..dea75a43d 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/components/GradientTopBar.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/components/GradientTopBar.kt @@ -1,8 +1,7 @@ package com.theveloper.pixelplay.presentation.components import androidx.compose.animation.core.animateFloatAsState -import androidx.compose.animation.core.Spring -import androidx.compose.animation.core.spring +import androidx.compose.animation.core.tween import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row @@ -123,10 +122,7 @@ fun HomeGradientTopBar( val animatedAlpha by animateFloatAsState( targetValue = if (isScrolled) 1f else 0f, - animationSpec = spring( - dampingRatio = Spring.DampingRatioMediumBouncy, - stiffness = Spring.StiffnessLow - ), + animationSpec = tween(durationMillis = 300), label = "topbar_alpha_transition" ) diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/HomeScreen.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/HomeScreen.kt index 18dfecf47..2edc2b4cd 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/HomeScreen.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/HomeScreen.kt @@ -54,6 +54,7 @@ import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.ExperimentalTextApi import androidx.compose.ui.text.TextStyle @@ -229,8 +230,10 @@ fun HomeScreen( val weeklyStats by statsViewModel.weeklyOverview.collectAsStateWithLifecycle() val listState = rememberLazyListState() + val density = LocalDensity.current + val scrollThresholdPx = remember(density) { with(density) { 180.dp.toPx() } } val isScrolledPastThreshold = remember { - derivedStateOf { listState.firstVisibleItemIndex > 0 || listState.firstVisibleItemScrollOffset > 180 } + derivedStateOf { listState.firstVisibleItemIndex > 0 || listState.firstVisibleItemScrollOffset > scrollThresholdPx } } // Drawer state for sidebar