From e076bf819de5239e51fb24021b7942428bc1bf7f Mon Sep 17 00:00:00 2001 From: sychic <47618543+Sychic@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:35:23 -0700 Subject: [PATCH] layoutdsl: migrate `size.kt` to statev2 Source-Commit: 220d821dd9b2e90f182eea3c18907f4474797bb8 --- .../kotlin/gg/essential/elementa/layoutdsl/size.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/unstable/layoutdsl/src/main/kotlin/gg/essential/elementa/layoutdsl/size.kt b/unstable/layoutdsl/src/main/kotlin/gg/essential/elementa/layoutdsl/size.kt index 8980568c..74d882b1 100644 --- a/unstable/layoutdsl/src/main/kotlin/gg/essential/elementa/layoutdsl/size.kt +++ b/unstable/layoutdsl/src/main/kotlin/gg/essential/elementa/layoutdsl/size.kt @@ -5,8 +5,8 @@ import gg.essential.elementa.constraints.* import gg.essential.elementa.constraints.animation.* import gg.essential.elementa.dsl.* import gg.essential.elementa.common.constraints.FillConstraintIncludingPadding -import gg.essential.elementa.common.onSetValueAndNow import gg.essential.elementa.state.v2.State +import gg.essential.elementa.state.v2.effect import gg.essential.elementa.state.v2.stateOf import gg.essential.elementa.util.hasWindow @@ -95,7 +95,9 @@ private class AnimateWidthModifier(private val newWidth: State<() -> WidthConstr } } - val removeListenerCallback = newWidth.onSetValueAndNow(component) { animate(it()) } + val removeListenerCallback = effect(component) { + animate(newWidth()()) + } return { removeListenerCallback() @@ -118,7 +120,9 @@ private class AnimateHeightModifier(private val newHeight: State<() -> HeightCon } } - val removeListenerCallback = newHeight.onSetValueAndNow(component) { animate(it()) } + val removeListenerCallback = effect(component) { + animate(newHeight()()) + } return { removeListenerCallback()