From 502078382ed7cc0b02a5c46fb7bc84a6668157ff Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Thu, 19 Oct 2023 17:25:17 +0100 Subject: [PATCH] Update to CMP 1.5 and appyx alpha09 --- gradle/libs.versions.toml | 10 ++++----- .../backstackclipper/BackStackClipper.kt | 4 ++-- .../appyx/component/gridpuzzle/GridPuzzle.kt | 2 +- .../gridpuzzle/GridPuzzleVisualisation.kt | 21 +++++++++++-------- .../component/gridpuzzle/TargetUiState.kt | 6 ++++-- .../composable/StarFieldMessageBoard.kt | 1 - .../bumble/puzzyx/node/app/PuzzyxAppNode.kt | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e9cfd860..1194c191 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,18 +8,18 @@ androidMinSdk = "21" androidTargetSdk = "32" androidx-lifecycle = "2.6.1" androidx-navigation-compose = "2.5.1" -appyx = "2.0.0-alpha06" +appyx = "2.0.0-alpha09" coil = "2.2.1" -composePlugin = "1.4.3" +composePlugin = "1.5.3" composeBom = "2023.05.01" -composeCompiler = "1.4.4" +composeCompiler = "1.5.3" coroutines = "1.7.1" dependencyAnalysis = "1.13.1" detekt = "1.22.0" junit5 = "5.8.2" jvmTarget = "17" -kotlin = "1.8.10" -ksp = "1.8.0-1.0.8" +kotlin = "1.9.10" +ksp = "1.9.10-1.0.13" mvicore = "1.2.6" resources = "0.22.3" ribs = "0.39.0" diff --git a/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/backstackclipper/BackStackClipper.kt b/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/backstackclipper/BackStackClipper.kt index ba446de1..71f8ef9f 100644 --- a/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/backstackclipper/BackStackClipper.kt +++ b/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/backstackclipper/BackStackClipper.kt @@ -8,7 +8,7 @@ import com.bumble.appyx.interactions.core.ui.context.UiContext import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.ZIndex import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState -import com.bumble.appyx.transitionmodel.BaseMotionController +import com.bumble.appyx.transitionmodel.BaseVisualisation /** @@ -26,7 +26,7 @@ class BackStackClipper( uiContext: UiContext, private val shape: @Composable (progress: Float) -> Shape, defaultAnimationSpec: SpringSpec = DefaultAnimationSpec -) : BaseMotionController, MutableUiState, TargetUiState>( +) : BaseVisualisation, MutableUiState, TargetUiState>( uiContext = uiContext, defaultAnimationSpec = defaultAnimationSpec, ) { diff --git a/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/GridPuzzle.kt b/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/GridPuzzle.kt index 59d51258..24c0f3f6 100644 --- a/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/GridPuzzle.kt +++ b/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/GridPuzzle.kt @@ -14,6 +14,6 @@ class GridPuzzle( defaultAnimationSpec: SpringSpec = DefaultAnimationSpec ) : BaseAppyxComponent( model = GridPuzzleModel(savedStateMap, gridRows, gridCols, pieces), - motionController = { GridPuzzleVisualisation(it, defaultAnimationSpec) }, + visualisation = { GridPuzzleVisualisation(it, defaultAnimationSpec) }, defaultAnimationSpec = defaultAnimationSpec ) diff --git a/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/GridPuzzleVisualisation.kt b/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/GridPuzzleVisualisation.kt index 5a4f6751..6d584b66 100644 --- a/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/GridPuzzleVisualisation.kt +++ b/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/GridPuzzleVisualisation.kt @@ -13,9 +13,10 @@ import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.RoundedCorners import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.Center import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.fractionAlignment -import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionInside.Target +import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionAlignment +import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionOffset import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState -import com.bumble.appyx.transitionmodel.BaseMotionController +import com.bumble.appyx.transitionmodel.BaseVisualisation import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.ASSEMBLED import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.CAROUSEL import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.FLIPPED @@ -28,7 +29,7 @@ import kotlin.random.Random class GridPuzzleVisualisation( uiContext: UiContext, defaultAnimationSpec: SpringSpec -) : BaseMotionController( +) : BaseVisualisation( uiContext = uiContext, defaultAnimationSpec = defaultAnimationSpec ) { @@ -53,9 +54,11 @@ class GridPuzzleVisualisation( } private fun State.scattered(i: Int, j: Int) = TargetUiState( - position = Target( - alignment = alignment(i, j), - offset = DpOffset( + position = PositionAlignment.Target( + insideAlignment = alignment(i, j) + ), + positionOffset = PositionOffset.Target( + DpOffset( x = offset(i, gridCols, transitionBounds.widthDp), y = offset(j, gridRows, transitionBounds.heightDp), ), @@ -75,8 +78,8 @@ class GridPuzzleVisualisation( } private fun State.assembled(i: Int, j: Int, idx: Int) = TargetUiState( - position = Target( - alignment = alignment(i, j), + position = PositionAlignment.Target( + insideAlignment = alignment(i, j), ), angularPosition = AngularPosition.Target( AngularPosition.Value( @@ -99,7 +102,7 @@ class GridPuzzleVisualisation( val targetRing = idx % maxRings + 2 return flipped.copy( - position = Target(Center), + position = PositionAlignment.Target(Center), rotationZ = RotationZ.Target( (if (Random.nextBoolean()) -1 else 1) * Random.nextInt(1, 3) * 360f ), diff --git a/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/TargetUiState.kt b/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/TargetUiState.kt index 4d7018ff..67f9f29f 100644 --- a/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/TargetUiState.kt +++ b/shared/src/commonMain/kotlin/com/bumble/puzzyx/appyx/component/gridpuzzle/TargetUiState.kt @@ -4,12 +4,14 @@ import com.bumble.appyx.interactions.core.ui.property.impl.AngularPosition import com.bumble.appyx.interactions.core.ui.property.impl.RotationY import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.RoundedCorners -import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionInside +import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionAlignment +import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionOffset import com.bumble.appyx.interactions.core.ui.state.MutableUiStateSpecs @MutableUiStateSpecs data class TargetUiState( - val position: PositionInside.Target, + val position: PositionAlignment.Target, + val positionOffset: PositionOffset.Target = PositionOffset.Target(), val angularPosition: AngularPosition.Target = AngularPosition.Target( AngularPosition.Value.Zero ), diff --git a/shared/src/commonMain/kotlin/com/bumble/puzzyx/composable/StarFieldMessageBoard.kt b/shared/src/commonMain/kotlin/com/bumble/puzzyx/composable/StarFieldMessageBoard.kt index 53bd56f3..925f8839 100644 --- a/shared/src/commonMain/kotlin/com/bumble/puzzyx/composable/StarFieldMessageBoard.kt +++ b/shared/src/commonMain/kotlin/com/bumble/puzzyx/composable/StarFieldMessageBoard.kt @@ -35,7 +35,6 @@ import com.bumble.puzzyx.model.Entry import com.bumble.puzzyx.model.entries import com.bumble.puzzyx.ui.appyx_dark import kotlinx.coroutines.isActive -import org.jetbrains.skia.svg.SVGPreserveAspectRatio import kotlin.math.max import kotlin.math.roundToInt import kotlin.random.Random diff --git a/shared/src/commonMain/kotlin/com/bumble/puzzyx/node/app/PuzzyxAppNode.kt b/shared/src/commonMain/kotlin/com/bumble/puzzyx/node/app/PuzzyxAppNode.kt index 23b344a1..9440332c 100644 --- a/shared/src/commonMain/kotlin/com/bumble/puzzyx/node/app/PuzzyxAppNode.kt +++ b/shared/src/commonMain/kotlin/com/bumble/puzzyx/node/app/PuzzyxAppNode.kt @@ -62,7 +62,7 @@ class PuzzyxAppNode( initialTargets = listOf(screens.first()), savedStateMap = buildContext.savedStateMap, ), - motionController = { BackStackClipper(it, shape = { progress -> clipShape(progress) }) } + visualisation = { BackStackClipper(it, shape = { progress -> clipShape(progress) }) } ) ) : ParentNode( buildContext = buildContext,