Skip to content

Commit

Permalink
Update to CMP 1.5 and appyx alpha09
Browse files Browse the repository at this point in the history
  • Loading branch information
KovalevAndrey committed Oct 19, 2023
1 parent 9b590b2 commit 5020783
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 21 deletions.
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


/**
Expand All @@ -26,7 +26,7 @@ class BackStackClipper<InteractionTarget : Any>(
uiContext: UiContext,
private val shape: @Composable (progress: Float) -> Shape,
defaultAnimationSpec: SpringSpec<Float> = DefaultAnimationSpec
) : BaseMotionController<InteractionTarget, BackStackModel.State<InteractionTarget>, MutableUiState, TargetUiState>(
) : BaseVisualisation<InteractionTarget, BackStackModel.State<InteractionTarget>, MutableUiState, TargetUiState>(
uiContext = uiContext,
defaultAnimationSpec = defaultAnimationSpec,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class GridPuzzle(
defaultAnimationSpec: SpringSpec<Float> = DefaultAnimationSpec
) : BaseAppyxComponent<PuzzlePiece, GridPuzzleModel.State>(
model = GridPuzzleModel(savedStateMap, gridRows, gridCols, pieces),
motionController = { GridPuzzleVisualisation(it, defaultAnimationSpec) },
visualisation = { GridPuzzleVisualisation(it, defaultAnimationSpec) },
defaultAnimationSpec = defaultAnimationSpec
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +29,7 @@ import kotlin.random.Random
class GridPuzzleVisualisation(
uiContext: UiContext,
defaultAnimationSpec: SpringSpec<Float>
) : BaseMotionController<PuzzlePiece, State, MutableUiState, TargetUiState>(
) : BaseVisualisation<PuzzlePiece, State, MutableUiState, TargetUiState>(
uiContext = uiContext,
defaultAnimationSpec = defaultAnimationSpec
) {
Expand All @@ -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),
),
Expand All @@ -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(
Expand All @@ -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
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<NavTarget>(
buildContext = buildContext,
Expand Down

0 comments on commit 5020783

Please sign in to comment.