From f1e391ccda54632863fa9b9fd61072e9d50ff897 Mon Sep 17 00:00:00 2001 From: ulfrxdev Date: Mon, 18 May 2026 21:54:42 +0200 Subject: [PATCH] Adjust dock overlay --- .../recipe/ui/screens/shell/dock/DockBar.kt | 1 + .../ui/screens/shell/dock/DockGesture.kt | 19 +++++++++++++++++++ .../ui/screens/shell/dock/DockLayers.kt | 6 ++++-- .../dev/ulfrx/recipe/ui/theme/RecipeColors.kt | 7 +++++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockBar.kt b/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockBar.kt index 71d5cf6..86c11eb 100644 --- a/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockBar.kt +++ b/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockBar.kt @@ -122,6 +122,7 @@ private fun DockBarExpanded( overlayCenterX = anim.overlayCenterX, overlayWidthPx = anim.overlayWidthPx, overlayAlpha = anim.overlayAlpha, + overlayPeakProgress = anim.overlayPeakProgress, dockWidthPx = dockWidthPx, dockHeight = height, ) diff --git a/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockGesture.kt b/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockGesture.kt index b1bd819..61a0d46 100644 --- a/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockGesture.kt +++ b/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockGesture.kt @@ -38,6 +38,7 @@ internal data class DockOverlayAnimations( val overlayCenterX: Float, val overlayWidthPx: Float, val overlayAlpha: Float, + val overlayPeakProgress: Float, val activeIndicatorAlpha: Float, ) @@ -93,8 +94,10 @@ internal fun rememberDockOverlayAnimations( val pressing = pressState is DockPressState.Pressing val activeCenterXState = rememberUpdatedState(activeCenterX) + var releaseSlideStartX by remember { mutableStateOf(null) } LaunchedEffect(pressing) { if (pressing) { + releaseSlideStartX = null activeAlphaAnim.snapTo(0f) overlayAlphaAnim.animateTo( targetValue = 1f, @@ -102,6 +105,7 @@ internal fun rememberDockOverlayAnimations( ) } else { if (overlayAlphaAnim.value <= 0f) return@LaunchedEffect + releaseSlideStartX = centerAnim.value if (overlayAlphaAnim.value < 1f) { val tailMs = ((1f - overlayAlphaAnim.value) * OverlayFadeInDurationMs) .toInt() @@ -128,13 +132,28 @@ internal fun rememberDockOverlayAnimations( ) } } + releaseSlideStartX = null } } + val releaseSlideProgress = run { + val start = releaseSlideStartX + if (start == null) { + 0f + } else { + val target = activeCenterXState.value + val total = abs(target - start) + if (total < 1f) 0f + else (abs(centerAnim.value - start) / total).coerceIn(0f, 1f) + } + } + val overlayPeakProgress = overlayAlphaAnim.value * (1f - releaseSlideProgress) + return DockOverlayAnimations( overlayCenterX = centerAnim.value, overlayWidthPx = overlayWidthPx, overlayAlpha = overlayAlphaAnim.value, + overlayPeakProgress = overlayPeakProgress, activeIndicatorAlpha = activeAlphaAnim.value, ) } diff --git a/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockLayers.kt b/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockLayers.kt index 4890d02..95e130b 100644 --- a/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockLayers.kt +++ b/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/screens/shell/dock/DockLayers.kt @@ -67,6 +67,7 @@ internal fun DockPressOverlayLayer( overlayCenterX: Float, overlayWidthPx: Float, overlayAlpha: Float, + overlayPeakProgress: Float, dockWidthPx: Float, dockHeight: Dp, ) { @@ -76,8 +77,8 @@ internal fun DockPressOverlayLayer( val dockHeightPx = with(density) { dockHeight.toPx() } val activeInsetPx = with(density) { ActiveIndicatorVerticalInset.toPx() } val activeStartScaleY = if (dockHeightPx > 0f) (dockHeightPx - 2 * activeInsetPx) / dockHeightPx else 1f - val scaleX = lerp(1f, PressOverlayScale, overlayAlpha) - val scaleY = lerp(activeStartScaleY, PressOverlayScale, overlayAlpha) + val scaleX = lerp(1f, PressOverlayScale, overlayPeakProgress) + val scaleY = lerp(activeStartScaleY, PressOverlayScale, overlayPeakProgress) val cornerRadius = (dockHeight - 2 * PressOverlayVerticalInset) / 2 val leftPx = overlayCenterX - overlayWidthPx / 2f @@ -94,5 +95,6 @@ internal fun DockPressOverlayLayer( .alpha(overlayAlpha), cornerRadius = cornerRadius, glassStyle = RecipeTheme.glass.dockPress, + tint = RecipeTheme.colors.surfaceGlassOverlay, ) {} } diff --git a/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/theme/RecipeColors.kt b/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/theme/RecipeColors.kt index f90599e..43e0607 100644 --- a/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/theme/RecipeColors.kt +++ b/composeApp/src/commonMain/kotlin/dev/ulfrx/recipe/ui/theme/RecipeColors.kt @@ -10,6 +10,7 @@ public data class RecipeColors( val background: Color, val surface: Color, val surfaceGlass: Color, + val surfaceGlassOverlay: Color, val content: Color, val contentMuted: Color, val accent: Color, @@ -21,9 +22,10 @@ public data class RecipeColors( public val LightRecipeColors: RecipeColors = RecipeColors( - background = Color(0xFFF7F5F1), + background = Color(0xFFEAE6DF), surface = Color(0xFFFFFFFF), surfaceGlass = Color(0xFFFFFFFF).copy(alpha = 0.42f), + surfaceGlassOverlay = Color(0xFFFFFFFF).copy(alpha = 0.20f), content = Color(0xFF0F1113), contentMuted = Color(0xFF6B6E73), accent = Color(0xFFD97757), @@ -37,7 +39,8 @@ public val DarkRecipeColors: RecipeColors = RecipeColors( background = Color(0xFF0F1113), surface = Color(0xFF1A1D21), - surfaceGlass = Color(0xFFFFFFFF).copy(alpha = 0.18f), + surfaceGlass = Color(0xFF3A3D42).copy(alpha = 0.55f), + surfaceGlassOverlay = Color(0xFFFFFFFF).copy(alpha = 0.12f), content = Color(0xFFF1EFEA), contentMuted = Color(0xFF9AA0A6), accent = Color(0xFFE48A6E),