From 47d9a62aade5f28700f17b37ed1bd283ba669ae2 Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Mon, 25 Sep 2023 19:56:59 -0700 Subject: [PATCH] Adjust insets easing --- .../composelife/ui/app/action/CellUniverseActionCard.kt | 8 +++++++- .../com/alexvanyo/composelife/ui/util/EasingPiecewise.kt | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ui-app/src/androidMain/kotlin/com/alexvanyo/composelife/ui/app/action/CellUniverseActionCard.kt b/ui-app/src/androidMain/kotlin/com/alexvanyo/composelife/ui/app/action/CellUniverseActionCard.kt index 7c5a4e8ee9..8118abbca6 100644 --- a/ui-app/src/androidMain/kotlin/com/alexvanyo/composelife/ui/app/action/CellUniverseActionCard.kt +++ b/ui-app/src/androidMain/kotlin/com/alexvanyo/composelife/ui/app/action/CellUniverseActionCard.kt @@ -16,6 +16,8 @@ package com.alexvanyo.composelife.ui.app.action +import androidx.compose.animation.core.EaseInOut +import androidx.compose.animation.core.Easing import androidx.compose.animation.core.Spring import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.animateFloatAsState @@ -44,6 +46,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.layoutId import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp @@ -58,6 +61,7 @@ import com.alexvanyo.composelife.ui.app.action.settings.InlineSettingsScreen import com.alexvanyo.composelife.ui.app.action.settings.InlineSettingsScreenInjectEntryPoint import com.alexvanyo.composelife.ui.app.action.settings.InlineSettingsScreenLocalEntryPoint import com.alexvanyo.composelife.ui.util.AnimatedContent +import com.alexvanyo.composelife.ui.util.Easing import com.alexvanyo.composelife.ui.util.Layout import com.alexvanyo.composelife.ui.util.PredictiveNavigationHost import com.alexvanyo.composelife.ui.util.WindowInsets @@ -141,7 +145,7 @@ fun CellUniverseActionCard( val targetWindowInsets = lerp( WindowInsets.safeDrawing.add(WindowInsets(all = 8.dp)), WindowInsets.Zero, - targetWindowInsetsProgressToFullscreen, + Easing(EaseInOut, 0.5f to Easing { 1f }).transform(targetWindowInsetsProgressToFullscreen), ) val cornerSize by animateDpAsState( @@ -192,6 +196,7 @@ fun CellUniverseActionCard( Surface( shape = RoundedCornerShape(cornerSize), tonalElevation = 1.dp, + color = Color.Transparent, modifier = Modifier.windowInsetsPadding( WindowInsets.safeDrawing.add(WindowInsets(all = 8.dp)), ), @@ -336,6 +341,7 @@ fun CellUniverseActionCard( is ActionCardNavigation.FullscreenSettings -> { Surface( shape = RoundedCornerShape(cornerSize), + color = Color.Transparent, tonalElevation = 1.dp, ) { FullscreenSettingsScreen( diff --git a/ui-common/src/commonMain/kotlin/com/alexvanyo/composelife/ui/util/EasingPiecewise.kt b/ui-common/src/commonMain/kotlin/com/alexvanyo/composelife/ui/util/EasingPiecewise.kt index 759f5c21cf..eabd56a706 100644 --- a/ui-common/src/commonMain/kotlin/com/alexvanyo/composelife/ui/util/EasingPiecewise.kt +++ b/ui-common/src/commonMain/kotlin/com/alexvanyo/composelife/ui/util/EasingPiecewise.kt @@ -37,9 +37,10 @@ fun Easing( val easingMap = TreeMap() easingMap[0f] = easing easingMap.putAll(easings) + require(easingMap.size == easings.size + 1) return Easing { val (piecewiseStart, piecewiseEasing) = easingMap.floorEntry(it)!! - val piecewiseEnd = easingMap.ceilingKey(it) ?: 1f + val piecewiseEnd = easingMap.higherKey(it) ?: 1f piecewiseEasing.transform((it - piecewiseStart) / (piecewiseEnd - piecewiseStart)) } }