From e3aafe0b73081b3debfcd42f16794917b3c46d3c Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Mon, 18 Dec 2023 12:57:44 +0000 Subject: [PATCH 1/9] Do not apply gesture modifier if no gestures are supplied. Refactor AppyxComponent's child composable. --- .../experimental/cards/android/DatingCards.kt | 7 +- .../cards/ui/CardsVisualisation.kt | 2 +- .../promoter/android/PromoterExperiment.kt | 2 +- .../promoter/ui/PromoterVisualisation.kt | 2 +- .../experimental/puzzle15/ui/Puzzle15Ui.kt | 84 ++----- .../puzzle15/ui/Puzzle15Visualisation.kt | 2 +- .../internal/testdrive/TestDriveExperiment.kt | 7 +- .../TestDriveRotationVisualisation.kt | 2 +- .../ui/simple/TestDriveSimpleVisualisation.kt | 2 +- .../backstack/ui/fader/BackStackFader.kt | 2 +- .../ui/parallax/BackStackParallax.kt | 2 +- .../spotlight/android/utils/SpotlightUtils.kt | 24 +- .../spotlight/ui/fader/SpotlightFader.kt | 2 +- .../sample/android/SampleChildren.kt | 19 +- .../appyx/interactions/testing/Utils.kt | 7 +- .../appyx/interactions/core/AppyxComponent.kt | 221 +++++++++++------- .../core/model/BaseAppyxComponent.kt | 7 +- .../core/ui/gesture/GestureSettleConfig.kt | 5 +- .../interactions/core/ui/helper/Gestures.kt | 39 ---- .../appyx/interactions/sample/Children.kt | 160 ++++++------- .../transitionmodel/BaseVisualisation.kt | 2 +- .../progress/DragProgressControllerTest.kt | 2 +- .../navigation/composable/AppyxComponent.kt | 19 +- .../appyx/navigation/composable/Child.kt | 28 +-- .../benchmark/app/mosaic/MosaicComponent.kt | 2 +- .../interactions/sample/ModalExperiment.kt | 6 +- .../sample/SpotlightExperiment.kt | 62 ++--- .../sample/SpotlightExperimentDebug.kt | 7 +- .../appyx/interactions/widgets/Widgets.kt | 2 +- .../DragPredictionVisualisation.kt | 2 +- .../IncompleteDragVisualisation.kt | 2 +- .../demos/sample1/Sample1Visualisation.kt | 2 +- .../demos/sample2/Sample2Visualisation.kt | 2 +- .../demos/sample3/Sample3Visualisation.kt | 2 +- .../node/backstack/BackStackNode.kt | 2 - 35 files changed, 333 insertions(+), 407 deletions(-) delete mode 100644 appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/helper/Gestures.kt diff --git a/appyx-components/experimental/cards/android/src/main/kotlin/com/bumble/appyx/components/experimental/cards/android/DatingCards.kt b/appyx-components/experimental/cards/android/src/main/kotlin/com/bumble/appyx/components/experimental/cards/android/DatingCards.kt index 5872fba4b..208c0a9a8 100644 --- a/appyx-components/experimental/cards/android/src/main/kotlin/com/bumble/appyx/components/experimental/cards/android/DatingCards.kt +++ b/appyx-components/experimental/cards/android/src/main/kotlin/com/bumble/appyx/components/experimental/cards/android/DatingCards.kt @@ -47,10 +47,11 @@ fun DatingCards(modifier: Modifier = Modifier) { screenHeightPx = (LocalConfiguration.current.screenHeightDp * LocalDensity.current.density).roundToInt(), appyxComponent = cards, gestureValidator = permissiveValidator, - ) { elementUiModel -> + ) { element -> ProfileCard( - profile = elementUiModel.element.interactionTarget.profile, - modifier = Modifier.fillMaxSize().then(elementUiModel.modifier) + profile = element.interactionTarget.profile, + modifier = Modifier + .fillMaxSize() ) } } diff --git a/appyx-components/experimental/cards/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/cards/ui/CardsVisualisation.kt b/appyx-components/experimental/cards/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/cards/ui/CardsVisualisation.kt index 41b2971c3..aaf046836 100644 --- a/appyx-components/experimental/cards/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/cards/ui/CardsVisualisation.kt +++ b/appyx-components/experimental/cards/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/cards/ui/CardsVisualisation.kt @@ -13,7 +13,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragHorizontalDirection -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.Scale import com.bumble.appyx.interactions.core.ui.property.impl.ZIndex diff --git a/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt b/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt index 0604fac04..62307da50 100644 --- a/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt +++ b/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt @@ -82,7 +82,7 @@ fun PromoterExperiment(modifier: Modifier = Modifier) { horizontal = 64.dp, vertical = 12.dp ), - element = { + child = { Element( elementUiModel = it, modifier = Modifier.size(100.dp) diff --git a/appyx-components/experimental/promoter/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/promoter/ui/PromoterVisualisation.kt b/appyx-components/experimental/promoter/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/promoter/ui/PromoterVisualisation.kt index a57f582df..765399c60 100644 --- a/appyx-components/experimental/promoter/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/promoter/ui/PromoterVisualisation.kt +++ b/appyx-components/experimental/promoter/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/promoter/ui/PromoterVisualisation.kt @@ -9,7 +9,7 @@ import com.bumble.appyx.components.experimental.promoter.PromoterModel import com.bumble.appyx.components.experimental.promoter.PromoterModel.State.ElementState import com.bumble.appyx.interactions.core.ui.context.TransitionBounds 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.gesture.DefaultAnimationSpec 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 diff --git a/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Ui.kt b/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Ui.kt index 0d9cb7958..9af42a28f 100644 --- a/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Ui.kt +++ b/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Ui.kt @@ -2,7 +2,6 @@ package com.bumble.appyx.components.experimental.puzzle15.ui import androidx.compose.foundation.background import androidx.compose.foundation.border -import androidx.compose.foundation.gestures.detectDragGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -28,7 +27,6 @@ import androidx.compose.ui.input.key.KeyEventType import androidx.compose.ui.input.key.key import androidx.compose.ui.input.key.onKeyEvent import androidx.compose.ui.input.key.type -import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.bumble.appyx.components.experimental.puzzle15.Puzzle15 @@ -39,8 +37,9 @@ import com.bumble.appyx.components.experimental.puzzle15.operation.Swap.Directio import com.bumble.appyx.components.experimental.puzzle15.operation.Swap.Direction.LEFT import com.bumble.appyx.components.experimental.puzzle15.operation.Swap.Direction.RIGHT import com.bumble.appyx.components.experimental.puzzle15.operation.Swap.Direction.UP +import com.bumble.appyx.interactions.core.AppyxComponent +import com.bumble.appyx.interactions.core.gesture.GestureValidator import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup -import com.bumble.appyx.interactions.sample.Children @Suppress("MagicNumber", "LongMethod") @Composable @@ -83,74 +82,31 @@ fun Puzzle15Ui( .size(240.dp) .border(4.dp, accentColor) ) { - Children( + AppyxComponent( + gestureValidator = GestureValidator.permissiveValidator, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, appyxComponent = puzzle15, - ) { elementUiModel -> - if (elementUiModel.element.interactionTarget == Puzzle15Model.Tile.EmptyTile) { + ) { element -> + if (element.interactionTarget == Puzzle15Model.Tile.EmptyTile) { Box( - modifier = Modifier.size(60.dp) - .then( - elementUiModel.modifier - .background(color = Color.Transparent) - ) + modifier = Modifier + .size(60.dp) + .background(color = Color.Transparent) + ) } else { - val state = model.output.value - val element = - state.currentTargetState.items.find { it.id == elementUiModel.element.id } - val index = state.currentTargetState.items.indexOf(element) - val emptyTileIndex = state.currentTargetState.emptyTileIndex - - @Suppress("ComplexCondition") - if (index == emptyTileIndex - 1 || - index == emptyTileIndex + 1 || - index == emptyTileIndex - 4 || - index == emptyTileIndex + 4 + Box( + modifier = Modifier + .size(60.dp) + .background(color = Color.White) ) { - Box( - modifier = Modifier.size(60.dp) - .then( - elementUiModel - .modifier - .background(color = Color.White) - ) - .pointerInput(elementUiModel.element.id) { - this.interceptOutOfBoundsChildEvents = true - detectDragGestures( - onDrag = { change, dragAmount -> - change.consume() - puzzle15.onDrag(dragAmount, this) - }, - onDragEnd = { - puzzle15.onDragEnd() - } - ) - } - ) { - Text( - color = Color.Black, - text = elementUiModel.element.interactionTarget.textValue(), - modifier = Modifier.align(Alignment.Center), - fontSize = 24.sp, - ) - } - } else { - Box( - modifier = Modifier.size(60.dp) - .then( - elementUiModel.modifier - .background(color = Color.White) - ) - ) { - Text( - color = Color.Black, - text = elementUiModel.element.interactionTarget.textValue(), - modifier = Modifier.align(Alignment.Center), - fontSize = 24.sp, - ) - } + Text( + color = Color.Black, + text = element.interactionTarget.textValue(), + modifier = Modifier.align(Alignment.Center), + fontSize = 24.sp, + ) } } } diff --git a/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Visualisation.kt b/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Visualisation.kt index 5db9d1fdd..cf4ebc642 100644 --- a/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Visualisation.kt +++ b/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Visualisation.kt @@ -13,7 +13,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection4 -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.fractionAlignment import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionAlignment import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState diff --git a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt index b70c4c139..e1d7b1734 100644 --- a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt +++ b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt @@ -139,10 +139,11 @@ fun TestDriveUi( screenHeightPx = screenHeightPx, appyxComponent = testDrive, gestureValidator = gestureValidator, - ) { elementUiModel -> + isGestureBoundingBoxTransformed = true + ) { Box( - modifier = Modifier.size(60.dp) - .then(elementUiModel.modifier) + modifier = Modifier + .size(60.dp) ) } diff --git a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/rotation/TestDriveRotationVisualisation.kt b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/rotation/TestDriveRotationVisualisation.kt index bda5c9c86..31053fab5 100644 --- a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/rotation/TestDriveRotationVisualisation.kt +++ b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/rotation/TestDriveRotationVisualisation.kt @@ -11,7 +11,7 @@ import com.bumble.appyx.components.internal.testdrive.ui.md_light_green_500 import com.bumble.appyx.components.internal.testdrive.ui.md_red_500 import com.bumble.appyx.components.internal.testdrive.ui.md_yellow_500 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.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment diff --git a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/simple/TestDriveSimpleVisualisation.kt b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/simple/TestDriveSimpleVisualisation.kt index 3d619438a..673041989 100644 --- a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/simple/TestDriveSimpleVisualisation.kt +++ b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/simple/TestDriveSimpleVisualisation.kt @@ -26,7 +26,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionAlignment diff --git a/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/fader/BackStackFader.kt b/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/fader/BackStackFader.kt index a0f751c48..0606f884b 100644 --- a/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/fader/BackStackFader.kt +++ b/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/fader/BackStackFader.kt @@ -3,7 +3,7 @@ package com.bumble.appyx.components.backstack.ui.fader import androidx.compose.animation.core.SpringSpec import com.bumble.appyx.components.backstack.BackStackModel 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.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.Alpha import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState import com.bumble.appyx.transitionmodel.BaseVisualisation diff --git a/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/parallax/BackStackParallax.kt b/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/parallax/BackStackParallax.kt index cbb5e3a36..7984eed91 100644 --- a/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/parallax/BackStackParallax.kt +++ b/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/parallax/BackStackParallax.kt @@ -12,7 +12,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragHorizontalDirection -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.Alpha import com.bumble.appyx.interactions.core.ui.property.impl.ColorOverlay import com.bumble.appyx.interactions.core.ui.property.impl.Shadow diff --git a/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt b/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt index 6bee27d98..c9cf5ff1c 100644 --- a/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt +++ b/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt @@ -3,14 +3,12 @@ package com.bumble.appyx.components.spotlight.android.utils import androidx.compose.animation.core.AnimationSpec import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.tween -import androidx.compose.foundation.gestures.detectDragGestures import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.unit.dp import com.bumble.appyx.components.spotlight.Spotlight @@ -21,7 +19,6 @@ import com.bumble.appyx.interactions.sample.InteractionTarget import com.bumble.appyx.interactions.sample.android.Element import com.bumble.appyx.interactions.sample.android.SampleChildren import com.bumble.appyx.interactions.theme.appyx_dark -import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -77,26 +74,13 @@ fun SpotlightUi( horizontal = 64.dp, vertical = 12.dp ), - element = { elementUiModel -> + child = { element, childModifier -> Element( color = color, - elementUiModel = elementUiModel, + element = element, contentDescription = - "${SPOTLIGHT_EXPERIMENT_TEST_HELPER}_${elementUiModel.element.id}", - modifier = Modifier - .fillMaxSize() - .pointerInput(elementUiModel.element.id) { - detectDragGestures( - onDrag = { change, dragAmount -> - change.consume() - spotlight.onDrag(dragAmount, this) - }, - onDragEnd = { - AppyxLogger.d("drag", "end") - spotlight.onDragEnd() - } - ) - } + "${SPOTLIGHT_EXPERIMENT_TEST_HELPER}_${element.id}", + modifier = childModifier ) } ) diff --git a/appyx-components/stable/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/ui/fader/SpotlightFader.kt b/appyx-components/stable/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/ui/fader/SpotlightFader.kt index 3de5a14cc..4b59c7a14 100644 --- a/appyx-components/stable/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/ui/fader/SpotlightFader.kt +++ b/appyx-components/stable/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/ui/fader/SpotlightFader.kt @@ -6,7 +6,7 @@ import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.C import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.DESTROYED import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.STANDARD 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.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.Alpha import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState import com.bumble.appyx.transitionmodel.BaseVisualisation diff --git a/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/android/SampleChildren.kt b/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/android/SampleChildren.kt index 1974ad3b1..53cb4d465 100644 --- a/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/android/SampleChildren.kt +++ b/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/android/SampleChildren.kt @@ -1,13 +1,14 @@ package com.bumble.appyx.interactions.sample.android +import androidx.compose.foundation.layout.BoxScope import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalDensity +import com.bumble.appyx.interactions.core.AppyxComponent +import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.model.BaseAppyxComponent -import com.bumble.appyx.interactions.core.ui.output.ElementUiModel -import com.bumble.appyx.interactions.sample.Children import com.bumble.appyx.interactions.sample.SampleElement import com.bumble.appyx.interactions.sample.colors import kotlin.math.roundToInt @@ -22,31 +23,29 @@ fun SampleChildren( appyxComponent: BaseAppyxComponent, modifier: Modifier = Modifier, clipToBounds: Boolean = false, - element: @Composable (ElementUiModel) -> Unit = { - SampleElement(colors = colors, elementUiModel = it) + child: @Composable BoxScope.(Element) -> Unit = { element -> + SampleElement(colors = colors, element = element) }, ) { - Children( + AppyxComponent( appyxComponent = appyxComponent, screenWidthPx = (LocalConfiguration.current.screenWidthDp * LocalDensity.current.density).roundToInt(), screenHeightPx = (LocalConfiguration.current.screenHeightDp * LocalDensity.current.density).roundToInt(), modifier = modifier, clipToBounds = clipToBounds, - childWrapper = { elementUiModel -> - element(elementUiModel) - }, + child = child ) } @Composable fun Element( - elementUiModel: ElementUiModel<*>, + element: Element<*>, modifier: Modifier = Modifier, color: Color? = Color.Unspecified, contentDescription: String? = null ) { SampleElement( - elementUiModel = elementUiModel, + element = element, modifier = modifier, colors = colors, color = color, diff --git a/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/testing/Utils.kt b/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/testing/Utils.kt index c2d1191d4..ba590b3d2 100644 --- a/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/testing/Utils.kt +++ b/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/testing/Utils.kt @@ -63,14 +63,15 @@ private fun TestChildrenUi( ), appyxComponent = appyxComponent, clipToBounds = clipToBounds, - ) { + ) { element -> Box( modifier = Modifier .fillMaxSize() ) { Text( - text = "${it.element.interactionTarget}", - modifier = Modifier.align(Alignment.Center), + text = "${element.interactionTarget}", + modifier = Modifier + .align(Alignment.Center), color = Color.White ) } diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt index 51c1fc66d..9fc9a3fa8 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt @@ -1,6 +1,7 @@ package com.bumble.appyx.interactions.core import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.offset import androidx.compose.material.Text @@ -8,6 +9,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.SideEffect +import androidx.compose.runtime.State import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.key @@ -58,24 +60,20 @@ fun AppyxComponent( clipToBounds: Boolean = false, gestureValidator: GestureValidator = defaultValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, - element: @Composable (ElementUiModel) -> Unit = { elementUiModel -> - Box( - modifier = Modifier.fillMaxSize() - .then(elementUiModel.modifier) - ) { - Text( - modifier = Modifier.align(Alignment.Center), - text = "Customise this composable", - ) - } + isGestureBoundingBoxTransformed: Boolean = false, + child: @Composable BoxScope.(Element) -> Unit = { _ -> + Text( + modifier = Modifier + .align(Alignment.Center), + text = "Customise this composable", + ) }, ) { val density = LocalDensity.current val elementUiModels by appyxComponent.uiModels.collectAsState() val coroutineScope = rememberCoroutineScope() val gestureExtraTouchAreaPx = with(density) { gestureExtraTouchArea.toPx() } - var containerSize by remember { mutableStateOf(IntSize.Zero) } - + val containerSize = remember { mutableStateOf(IntSize.Zero) } val saveableStateHolder = rememberSaveableStateHolder() LaunchedEffect(appyxComponent) { @@ -101,7 +99,7 @@ fun AppyxComponent( .fillMaxSize() .then(if (clipToBounds) Modifier.clipToBounds() else Modifier) .onPlaced { - containerSize = it.size + containerSize.value = it.size appyxComponent.updateBounds( TransitionBounds( density = density, @@ -120,71 +118,41 @@ fun AppyxComponent( ) { CompositionLocalProvider(LocalBoxScope provides this) { elementUiModels.forEach { elementUiModel -> - val id = elementUiModel.element.id - key(id) { - var transformedBoundingBox by remember(id) { mutableStateOf(Rect.Zero) } - var elementSize by remember(id) { mutableStateOf(IntSize.Zero) } - var offsetCenter by remember(id) { mutableStateOf(Offset.Zero) } - val isVisible by elementUiModel.visibleState.collectAsState() + val isGesturesEnabled = appyxComponent.isGesturesEnabled + + key(elementUiModel.element.id) { + val isVisible by elementUiModel.visibleState.collectAsState() elementUiModel.persistentContainer() + saveableStateHolder.SaveableStateProvider(key = elementUiModel.element) { + if (isVisible) { + CompositionLocalProvider( + LocalMotionProperties provides elementUiModel.motionProperties, + ) { + when { + !isGesturesEnabled -> { + Box(modifier = elementUiModel.modifier) { + child(elementUiModel.element) + } + } - if (isVisible) { - CompositionLocalProvider( - LocalMotionProperties provides elementUiModel.motionProperties - ) { - val elementOffset = - offsetCenter.round() - elementOffset(elementSize, containerSize) - - saveableStateHolder.SaveableStateProvider(key = elementUiModel.element) { - element.invoke( - elementUiModel.copy( - modifier = Modifier - .offset { elementOffset } - .pointerInput(appyxComponent) { - detectDragGesturesOrCancellation( - onDragStart = { position -> - appyxComponent.onStartDrag(position) - }, - onDrag = { change, dragAmount -> - if (gestureValidator.isGestureValid( - change.position, - transformedBoundingBox.translate(-offsetCenter) - ) - ) { - change.consume() - appyxComponent.onDrag( - dragAmount, - density - ) - true - } else { - appyxComponent.onDragEnd() - false - } - }, - onDragEnd = { - appyxComponent.onDragEnd() - }, - ) - } - .offset { -elementOffset } - .then(elementUiModel.modifier) - .onPlaced { - elementSize = it.size - val localCenter = Offset( - it.size.width.toFloat(), - it.size.height.toFloat() - ) / 2f - - transformedBoundingBox = - it.boundsInParent() - .inflate(gestureExtraTouchAreaPx) - offsetCenter = - transformedBoundingBox.center - localCenter - } - ) - ) + isGesturesEnabled && isGestureBoundingBoxTransformed -> + ChildGestureSupportTransformBoundingBox( + appyxComponent = appyxComponent, + containerSize = containerSize, + gestureExtraTouchAreaPx = gestureExtraTouchAreaPx, + gestureValidator = gestureValidator, + elementUiModel = elementUiModel, + child = child + ) + + isGesturesEnabled && !isGestureBoundingBoxTransformed -> + ChildGestureSupportWithoutTransformation( + appyxComponent = appyxComponent, + elementUiModel = elementUiModel, + child = child + ) + } } } } @@ -194,17 +162,114 @@ fun AppyxComponent( } } +@Composable +private fun ChildGestureSupportWithoutTransformation( + appyxComponent: BaseAppyxComponent, + elementUiModel: ElementUiModel, + child: @Composable BoxScope.(Element) -> Unit +) { + val density = LocalDensity.current + Box(modifier = Modifier + .pointerInput(appyxComponent) { + detectDragGesturesOrCancellation( + onDragStart = { position -> + appyxComponent.onStartDrag(position) + }, + onDrag = { change, dragAmount -> + change.consume() + appyxComponent.onDrag( + dragAmount, + density + ) + true + }, + onDragEnd = { + appyxComponent.onDragEnd() + } + ) + } + .then(elementUiModel.modifier) + ) { + child(elementUiModel.element) + } +} + +@Composable +private fun ChildGestureSupportTransformBoundingBox( + appyxComponent: BaseAppyxComponent, + containerSize: State, + gestureExtraTouchAreaPx: Float, + gestureValidator: GestureValidator, + elementUiModel: ElementUiModel, + child: @Composable BoxScope.(Element) -> Unit +) { + var transformedBoundingBox by remember(elementUiModel.element.id) { mutableStateOf(Rect.Zero) } + var elementSize by remember(elementUiModel.element.id) { mutableStateOf(IntSize.Zero) } + var offsetCenter by remember(elementUiModel.element.id) { mutableStateOf(Offset.Zero) } + val density = LocalDensity.current + val elementOffset = + offsetCenter.round() - elementOffset(elementSize, containerSize) + + Box(modifier = Modifier + .offset { elementOffset } + .pointerInput(appyxComponent) { + detectDragGesturesOrCancellation( + onDragStart = { position -> + appyxComponent.onStartDrag(position) + }, + onDrag = { change, dragAmount -> + if (gestureValidator.isGestureValid( + change.position, + transformedBoundingBox.translate(-offsetCenter) + ) + ) { + change.consume() + appyxComponent.onDrag( + dragAmount, + density + ) + true + } else { + appyxComponent.onDragEnd() + false + } + }, + onDragEnd = { + appyxComponent.onDragEnd() + } + ) + } + .offset { -elementOffset } + .then(elementUiModel.modifier) + .onPlaced { + elementSize = it.size + val localCenter = Offset( + it.size.width.toFloat(), + it.size.height.toFloat() + ) / 2f + + transformedBoundingBox = + it.boundsInParent() + .inflate(gestureExtraTouchAreaPx) + offsetCenter = + transformedBoundingBox.center - localCenter + } + ) { + child(elementUiModel.element) + } +} @Composable fun elementOffset( elementSize: IntSize, - containerSize: IntSize, + containerSize: State, ): IntOffset { - val positionAlignment = motionPropertyRenderValue() + val positionAlignment = + motionPropertyRenderValue() val layoutDirection = LocalLayoutDirection.current val alignmentOffset = positionAlignment?.let { - it.align(elementSize, containerSize, layoutDirection) + it.align(elementSize, containerSize.value, layoutDirection) } ?: IntOffset.Zero return alignmentOffset diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseAppyxComponent.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseAppyxComponent.kt index bbe26a781..eb48e41a4 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseAppyxComponent.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseAppyxComponent.kt @@ -22,10 +22,9 @@ import com.bumble.appyx.interactions.core.ui.context.TransitionBounds import com.bumble.appyx.interactions.core.ui.context.TransitionBoundsAware import com.bumble.appyx.interactions.core.ui.context.UiContext import com.bumble.appyx.interactions.core.ui.context.UiContextAware +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec -import com.bumble.appyx.interactions.core.ui.helper.DisableAnimations import com.bumble.appyx.interactions.core.ui.output.ElementUiModel import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlinx.coroutines.CoroutineScope @@ -90,6 +89,8 @@ open class BaseAppyxComponent( defaultAnimationSpec = defaultAnimationSpec, ) + val isGesturesEnabled = _gestureFactory !is GestureFactory.Noop + private val _uiModels: MutableStateFlow>> = MutableStateFlow(emptyList()) val uiModels: StateFlow>> = _uiModels @@ -240,7 +241,7 @@ open class BaseAppyxComponent( val debugSource = debug when { (isDebug && debugSource != null) -> debugSource.operation(operation) - animatedSource == null || DisableAnimations || disableAnimations -> instant.operation( + animatedSource == null || disableAnimations -> instant.operation( operation ) diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/gesture/GestureSettleConfig.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/gesture/GestureSettleConfig.kt index 110c25585..713355ed8 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/gesture/GestureSettleConfig.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/gesture/GestureSettleConfig.kt @@ -1,8 +1,9 @@ package com.bumble.appyx.interactions.core.ui.gesture import androidx.compose.animation.core.AnimationSpec +import androidx.compose.animation.core.SpringSpec +import androidx.compose.animation.core.spring import androidx.compose.runtime.Immutable -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec @Immutable data class GestureSettleConfig( @@ -10,3 +11,5 @@ data class GestureSettleConfig( val completeGestureSpec: AnimationSpec = DefaultAnimationSpec, val revertGestureSpec: AnimationSpec = DefaultAnimationSpec, ) + +val DefaultAnimationSpec: SpringSpec = spring() diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/helper/Gestures.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/helper/Gestures.kt deleted file mode 100644 index ddcbc3e6e..000000000 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/helper/Gestures.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.bumble.appyx.interactions.core.ui.helper - -import androidx.compose.animation.core.SpringSpec -import androidx.compose.animation.core.spring -import androidx.compose.foundation.gestures.detectDragGestures -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.composed -import androidx.compose.ui.input.pointer.pointerInput -import androidx.compose.ui.platform.LocalDensity -import com.bumble.appyx.interactions.core.model.BaseAppyxComponent - -// TODO consider where to keep these - -var DisableAnimations = false - -val DefaultAnimationSpec: SpringSpec = spring() - -@Composable -@Suppress("UnnecessaryComposedModifier", "ModifierComposable") -fun Modifier.gestureModifier( - appyxComponent: BaseAppyxComponent, - key: Any, -) = this.composed { - - val density = LocalDensity.current - - pointerInput(key) { - detectDragGestures( - onDragStart = { position -> appyxComponent.onStartDrag(position) }, - onDrag = { change, dragAmount -> - change.consume() - appyxComponent.onDrag(dragAmount, density) - }, - onDragEnd = { appyxComponent.onDragEnd() } - ) - } -} - diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt index 305b6d236..1f205eccf 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt @@ -7,99 +7,84 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.SideEffect -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue -import androidx.compose.runtime.key import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.draw.clipToBounds import androidx.compose.ui.graphics.Color -import androidx.compose.ui.input.pointer.PointerEventType -import androidx.compose.ui.layout.onPlaced -import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.bumble.appyx.interactions.core.model.BaseAppyxComponent -import com.bumble.appyx.interactions.core.modifiers.onPointerEvent -import com.bumble.appyx.interactions.core.ui.LocalBoxScope -import com.bumble.appyx.interactions.core.ui.LocalMotionProperties -import com.bumble.appyx.interactions.core.ui.context.TransitionBounds -import com.bumble.appyx.interactions.core.ui.context.UiContext +import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.ui.output.ElementUiModel - -@Composable -fun Children( - appyxComponent: BaseAppyxComponent, - screenWidthPx: Int, - screenHeightPx: Int, - modifier: Modifier = Modifier, - clipToBounds: Boolean = false, - childContent: @Composable (ElementUiModel) -> Unit = {}, - childWrapper: @Composable (ElementUiModel) -> Unit = { frameModel -> - ChildWrapper(frameModel) { - childContent(frameModel) - } - }, -) { - val density = LocalDensity.current - val elementUiModels by appyxComponent.uiModels.collectAsState() - val coroutineScope = rememberCoroutineScope() - - SideEffect { - appyxComponent.updateContext( - UiContext( - coroutineScope = coroutineScope, - clipToBounds = clipToBounds - ) - ) - } - Box( - modifier = modifier - .fillMaxSize() - .then(if (clipToBounds) Modifier.clipToBounds() else Modifier) - .onPlaced { - appyxComponent.updateBounds( - TransitionBounds( - density = density, - widthPx = it.size.width, - heightPx = it.size.height, - screenWidthPx = screenWidthPx, - screenHeightPx = screenHeightPx - ) - ) - } - .onPointerEvent { - if (it.type == PointerEventType.Release) { - appyxComponent.onRelease() - } - } - ) { - CompositionLocalProvider(LocalBoxScope provides this) { - elementUiModels - .forEach { elementUiModel -> - key(elementUiModel.element.id) { - elementUiModel.persistentContainer() - val isVisible by elementUiModel.visibleState.collectAsState() - if (isVisible) { - CompositionLocalProvider( - LocalMotionProperties provides elementUiModel.motionProperties - ) { - childWrapper.invoke(elementUiModel) - } - } - } - } - } - } -} +// +//@Composable +//fun Children( +// appyxComponent: BaseAppyxComponent, +// screenWidthPx: Int, +// screenHeightPx: Int, +// modifier: Modifier = Modifier, +// clipToBounds: Boolean = false, +// childContent: @Composable (ElementUiModel) -> Unit = {}, +// childWrapper: @Composable (ElementUiModel) -> Unit = { frameModel -> +// ChildWrapper(frameModel) { +// childContent(frameModel) +// } +// }, +//) { +// val density = LocalDensity.current +// val elementUiModels by appyxComponent.uiModels.collectAsState() +// val coroutineScope = rememberCoroutineScope() +// +// SideEffect { +// appyxComponent.updateContext( +// UiContext( +// coroutineScope = coroutineScope, +// clipToBounds = clipToBounds +// ) +// ) +// } +// Box( +// modifier = modifier +// .fillMaxSize() +// .then(if (clipToBounds) Modifier.clipToBounds() else Modifier) +// .onPlaced { +// appyxComponent.updateBounds( +// TransitionBounds( +// density = density, +// widthPx = it.size.width, +// heightPx = it.size.height, +// screenWidthPx = screenWidthPx, +// screenHeightPx = screenHeightPx +// ) +// ) +// } +// .onPointerEvent { +// if (it.type == PointerEventType.Release) { +// appyxComponent.onRelease() +// } +// } +// ) { +// CompositionLocalProvider(LocalBoxScope provides this) { +// elementUiModels +// .forEach { elementUiModel -> +// key(elementUiModel.element.id) { +// elementUiModel.persistentContainer() +// val isVisible by elementUiModel.visibleState.collectAsState() +// if (isVisible) { +// CompositionLocalProvider( +// LocalMotionProperties provides elementUiModel.motionProperties +// ) { +// childWrapper.invoke(elementUiModel) +// } +// } +// } +// } +// } +// } +//} @Composable fun ChildWrapper( @@ -126,9 +111,9 @@ fun ChildWrapper( ) @Composable fun SampleElement( - elementUiModel: ElementUiModel<*>, + element: Element<*>, colors: List, - modifier: Modifier = Modifier.fillMaxSize(), + modifier: Modifier = Modifier, color: Color? = Color.Unspecified, contentDescription: String? = null ) { @@ -137,11 +122,10 @@ fun SampleElement( } Box( - modifier = Modifier - .then(elementUiModel.modifier) + modifier = modifier + .fillMaxSize() .clip(RoundedCornerShape(5)) .then(if (color == null) Modifier else Modifier.background(backgroundColor)) - .then(modifier) .padding(24.dp) .semantics { contentDescription?.let { this.contentDescription = it } @@ -149,7 +133,7 @@ fun SampleElement( ) { Text( - text = elementUiModel.element.interactionTarget.toString(), + text = element.interactionTarget.toString(), fontSize = 21.sp, color = Color.Black, fontWeight = FontWeight.Bold diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseVisualisation.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseVisualisation.kt index 338425cfd..4789f7803 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseVisualisation.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseVisualisation.kt @@ -14,7 +14,7 @@ import com.bumble.appyx.interactions.core.model.transition.Update import com.bumble.appyx.interactions.core.ui.Visualisation import com.bumble.appyx.interactions.core.ui.context.TransitionBounds 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.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.math.lerpFloat import com.bumble.appyx.interactions.core.ui.output.ElementUiModel import com.bumble.appyx.interactions.core.ui.property.impl.GenericFloatProperty diff --git a/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressControllerTest.kt b/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressControllerTest.kt index 51b895bac..2220cd68c 100644 --- a/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressControllerTest.kt +++ b/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressControllerTest.kt @@ -6,7 +6,7 @@ import com.bumble.appyx.InteractionTarget.Child1 import com.bumble.appyx.InteractionTarget.Child2 import com.bumble.appyx.interactions.core.TestGestures import com.bumble.appyx.interactions.core.TestTransitionModel -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import kotlin.test.Test import kotlin.test.asserter diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxComponent.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxComponent.kt index eb08e4d3a..29a76e806 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxComponent.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxComponent.kt @@ -5,9 +5,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.gesture.GestureValidator import com.bumble.appyx.interactions.core.model.BaseAppyxComponent -import com.bumble.appyx.interactions.core.ui.output.ElementUiModel import com.bumble.appyx.navigation.integration.LocalScreenSize import com.bumble.appyx.navigation.node.ParentNode import kotlin.math.roundToInt @@ -20,12 +20,12 @@ fun ParentNode.Ap appyxComponent: BaseAppyxComponent, modifier: Modifier = Modifier, clipToBounds: Boolean = false, - gestureValidator: GestureValidator = GestureValidator.defaultValidator, + gestureValidator: GestureValidator = GestureValidator.permissiveValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, - decorator: (@Composable ( - child: ChildRenderer, - elementUiModel: ElementUiModel - ) -> Unit) = { child, _ -> child() } + isGestureBoundingBoxTransformed: Boolean = false, + decorator: @Composable (child: ChildRenderer, element: Element) -> Unit = { child, _ -> + child() + } ) { val density = LocalDensity.current val screenWidthPx = (LocalScreenSize.current.widthDp * density.density).value.roundToInt() @@ -38,8 +38,9 @@ fun ParentNode.Ap modifier, clipToBounds, gestureValidator, - gestureExtraTouchArea - ) { elementUiModel -> - Child(elementUiModel, decorator) + gestureExtraTouchArea, + isGestureBoundingBoxTransformed + ) { element -> + Child(element, decorator) } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Child.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Child.kt index 63ecabbee..a74612601 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Child.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Child.kt @@ -1,47 +1,39 @@ package com.bumble.appyx.navigation.composable -import androidx.compose.foundation.layout.Box import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import com.bumble.appyx.interactions.core.ui.output.ElementUiModel +import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.ParentNode @Composable fun ParentNode.Child( - elementUiModel: ElementUiModel, - decorator: @Composable (child: ChildRenderer, elementUiModel: ElementUiModel) -> Unit + element: Element, + decorator: @Composable (child: ChildRenderer, element: Element) -> Unit ) { - val navElement = elementUiModel.element - val childEntry = remember(navElement.id) { childOrCreate(navElement) } + val childEntry = remember(element.id) { childOrCreate(element) } decorator( ChildRendererImpl( - node = childEntry.node, - elementUiModel = elementUiModel + node = childEntry.node ), - elementUiModel + element ) } -private class ChildRendererImpl( - private val node: Node, - private val elementUiModel: ElementUiModel +private class ChildRendererImpl( + private val node: Node ) : ChildRenderer { @Suppress("ComposableNaming") // This wants to be 'Invoke' but that won't work with 'operator'. @Composable override operator fun invoke(modifier: Modifier) { - Box(modifier = elementUiModel.modifier) { - node.Compose(modifier = modifier) - } + node.Compose(modifier = modifier) } @Suppress("ComposableNaming") // This wants to be 'Invoke' but that won't work with 'operator'. @Composable override operator fun invoke() { - Box(modifier = elementUiModel.modifier) { - node.Compose(modifier = Modifier) - } + node.Compose(modifier = Modifier) } } diff --git a/benchmark/benchmark-app/src/main/kotlin/com/bumble/appyx/benchmark/app/mosaic/MosaicComponent.kt b/benchmark/benchmark-app/src/main/kotlin/com/bumble/appyx/benchmark/app/mosaic/MosaicComponent.kt index 50986718c..67caa5d8a 100644 --- a/benchmark/benchmark-app/src/main/kotlin/com/bumble/appyx/benchmark/app/mosaic/MosaicComponent.kt +++ b/benchmark/benchmark-app/src/main/kotlin/com/bumble/appyx/benchmark/app/mosaic/MosaicComponent.kt @@ -3,7 +3,7 @@ package com.bumble.appyx.benchmark.app.mosaic import androidx.compose.animation.core.SpringSpec import com.bumble.appyx.benchmark.app.mosaic.MosaicModel.State import com.bumble.appyx.interactions.core.model.BaseAppyxComponent -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.navigation.state.SavedStateMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/ModalExperiment.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/ModalExperiment.kt index a9e64dded..73da8093e 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/ModalExperiment.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/ModalExperiment.kt @@ -3,7 +3,6 @@ package com.bumble.appyx.interactions.sample import androidx.compose.animation.core.spring import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.Button @@ -90,11 +89,10 @@ fun ModalUi( clipToBounds = false, appyxComponent = modal, modifier = modifier, - element = { elementUiModel -> + child = { element -> Element( color = color, - elementUiModel = elementUiModel, - modifier = Modifier.fillMaxSize() + element = element ) } ) diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt index 62229c112..c7221f288 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt @@ -4,19 +4,17 @@ import androidx.compose.animation.core.Spring import androidx.compose.animation.core.spring import androidx.compose.foundation.background import androidx.compose.foundation.gestures.Orientation -import androidx.compose.foundation.gestures.detectDragGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.Button import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.unit.dp import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel @@ -26,15 +24,11 @@ import com.bumble.appyx.components.spotlight.operation.next import com.bumble.appyx.components.spotlight.operation.previous import com.bumble.appyx.components.spotlight.operation.updateElements import com.bumble.appyx.components.spotlight.ui.slider.SpotlightSlider -import com.bumble.appyx.components.spotlight.ui.sliderrotation.SpotlightSliderRotation -import com.bumble.appyx.interactions.core.ui.context.UiContext import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup -import com.bumble.appyx.interactions.sample.InteractionTarget import com.bumble.appyx.interactions.sample.android.Element import com.bumble.appyx.interactions.sample.android.SampleChildren import com.bumble.appyx.interactions.theme.appyx_dark -import com.bumble.appyx.utils.multiplatform.AppyxLogger import com.bumble.appyx.interactions.sample.InteractionTarget as Target @Composable @@ -68,21 +62,25 @@ fun SpotlightExperiment( Target.Child6, Target.Child7, ) - val model = SpotlightModel( - items = items, - savedStateMap = null, - ) - val spotlight = Spotlight( - model = model, - visualisation = { visualisationType.toVisualisation(it, model.currentState) }, - gestureFactory = { SpotlightSlider.Gestures(it, orientation, reverseOrientation) }, - animationSpec = spring(stiffness = Spring.StiffnessVeryLow / 4), - gestureSettleConfig = GestureSettleConfig( - completionThreshold = 0.2f, - completeGestureSpec = spring(), - revertGestureSpec = spring(), - ), - ) + val model = remember { + SpotlightModel( + items = items, + savedStateMap = null, + ) + } + val spotlight = remember { + Spotlight( + model = model, + visualisation = { visualisationType.toVisualisation(it, model.currentState) }, + gestureFactory = { SpotlightSlider.Gestures(it, orientation, reverseOrientation) }, + animationSpec = spring(stiffness = Spring.StiffnessVeryLow / 4), + gestureSettleConfig = GestureSettleConfig( + completionThreshold = 0.2f, + completeGestureSpec = spring(), + revertGestureSpec = spring(), + ), + ) + } AppyxComponentSetup(spotlight) @@ -141,26 +139,12 @@ fun SpotlightUi( horizontal = 64.dp, vertical = 12.dp ), - element = { elementUiModel -> + child = { element -> Element( color = color, - elementUiModel = elementUiModel, + element = element, contentDescription = - "${SPOTLIGHT_EXPERIMENT_TEST_HELPER}_${elementUiModel.element.id}", - modifier = Modifier - .fillMaxSize() - .pointerInput(elementUiModel.element.id) { - detectDragGestures( - onDrag = { change, dragAmount -> - change.consume() - spotlight.onDrag(dragAmount, this) - }, - onDragEnd = { - AppyxLogger.d("drag", "end") - spotlight.onDragEnd() - } - ) - } + "${SPOTLIGHT_EXPERIMENT_TEST_HELPER}_${element.id}" ) } ) diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperimentDebug.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperimentDebug.kt index 2847613bd..c30da9d7c 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperimentDebug.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperimentDebug.kt @@ -2,7 +2,6 @@ package com.bumble.appyx.interactions.sample import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.ExperimentalMaterialApi @@ -76,11 +75,9 @@ fun SpotlightExperimentDebug(modifier: Modifier = Modifier) { vertical = 12.dp ), appyxComponent = spotlight, - element = { + child = { element -> Element( - elementUiModel = it, - modifier = Modifier - .fillMaxSize() + element = element ) } ) diff --git a/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt b/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt index 1276eb800..311befd1b 100644 --- a/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt +++ b/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt @@ -104,7 +104,7 @@ private fun WidgetsUi( ), screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - element = { elementUiModel -> + child = { elementUiModel -> WidgetTypeElement( elementUiModel = elementUiModel, modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPredictionVisualisation.kt b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPredictionVisualisation.kt index 6c7cf693b..404b57124 100644 --- a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPredictionVisualisation.kt +++ b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPredictionVisualisation.kt @@ -23,7 +23,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPLEFT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.Scale diff --git a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDragVisualisation.kt b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDragVisualisation.kt index d2749c5a2..807ba1ea2 100644 --- a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDragVisualisation.kt +++ b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDragVisualisation.kt @@ -24,7 +24,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.BottomEnd diff --git a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1Visualisation.kt b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1Visualisation.kt index 7dd0e02b8..de5838d89 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1Visualisation.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1Visualisation.kt @@ -24,7 +24,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.BottomEnd diff --git a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2Visualisation.kt b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2Visualisation.kt index dbff301f8..bb6e28593 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2Visualisation.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2Visualisation.kt @@ -24,7 +24,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment diff --git a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3Visualisation.kt b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3Visualisation.kt index e7f0895aa..92cae39c4 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3Visualisation.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3Visualisation.kt @@ -24,7 +24,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.BottomEnd import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.BottomStart diff --git a/demos/sandbox-appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt b/demos/sandbox-appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt index d360e4433..3781f776f 100644 --- a/demos/sandbox-appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt +++ b/demos/sandbox-appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt @@ -30,7 +30,6 @@ import com.bumble.appyx.interactions.core.ui.context.TransitionBounds import com.bumble.appyx.interactions.core.ui.context.UiContext import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig -import com.bumble.appyx.interactions.core.ui.helper.gestureModifier import com.bumble.appyx.navigation.ColorSaver import com.bumble.appyx.navigation.colors import com.bumble.appyx.navigation.composable.AppyxComponent @@ -89,7 +88,6 @@ class BackStackNode( ) .background(backgroundColor) .padding(24.dp) - .gestureModifier(backStack, interactionTarget.index.toString()) ) { Text( text = interactionTarget.index.toString(), From 64798bacc60ec8d46df1180c84df98ebdad41ad5 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Tue, 19 Dec 2023 09:21:24 +0000 Subject: [PATCH 2/9] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d8752e27..7c0bce8d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#630](https://github.com/bumble-tech/appyx/pull/630) – Pass initial state into Spotlights visualisations - [#643](https://github.com/bumble-tech/appyx/pull/643) – Unify AppyxComponent composable between appyx-navigation and appyx-interactions modules +- [#644](https://github.com/bumble-tech/appyx/pull/644) – Refactor AppyxComponent and application of draggable modifier ### Fixed From f9d9988b8013c244ca35cc25c928611c969579ea Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Tue, 19 Dec 2023 12:18:45 +0000 Subject: [PATCH 3/9] Fix compilation issue --- .../components/spotlight/android/utils/SpotlightUtils.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt b/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt index c9cf5ff1c..3bc207584 100644 --- a/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt +++ b/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt @@ -74,13 +74,12 @@ fun SpotlightUi( horizontal = 64.dp, vertical = 12.dp ), - child = { element, childModifier -> + child = { element -> Element( color = color, element = element, contentDescription = - "${SPOTLIGHT_EXPERIMENT_TEST_HELPER}_${element.id}", - modifier = childModifier + "${SPOTLIGHT_EXPERIMENT_TEST_HELPER}_${element.id}" ) } ) From 241bef0aa9c62092434ffa323013324909807722 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Tue, 19 Dec 2023 14:44:12 +0000 Subject: [PATCH 4/9] Fix compilation issues --- .../promoter/android/PromoterExperiment.kt | 2 +- .../appyx/interactions/widgets/Widgets.kt | 23 ++++++++----------- .../appyx/demos/common/AppyxWebSample.kt | 20 ++++++++-------- .../demos/dragprediction/DragPrediction.kt | 4 ++-- .../demos/incompletedrag/IncompleteDrag.kt | 4 ++-- .../ObserveMotionPropertiesSample.kt | 9 ++++---- .../com/bumble/appyx/demos/sample1/Sample1.kt | 3 +-- .../com/bumble/appyx/demos/sample2/Sample2.kt | 4 ++-- .../com/bumble/appyx/demos/sample3/Sample3.kt | 3 +-- 9 files changed, 31 insertions(+), 41 deletions(-) diff --git a/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt b/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt index 62307da50..0d35107d6 100644 --- a/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt +++ b/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt @@ -84,7 +84,7 @@ fun PromoterExperiment(modifier: Modifier = Modifier) { ), child = { Element( - elementUiModel = it, + element = it, modifier = Modifier.size(100.dp) ) }, diff --git a/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt b/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt index 311befd1b..4f0154ba4 100644 --- a/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt +++ b/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt @@ -1,4 +1,5 @@ @file:Suppress("MatchingDeclarationName") + package com.bumble.appyx.interactions.widgets import androidx.compose.animation.core.Spring @@ -20,9 +21,9 @@ import com.bumble.appyx.components.spotlight.operation.previous import com.bumble.appyx.components.spotlight.ui.slider.SpotlightSlider import com.bumble.appyx.interactions.Events import com.bumble.appyx.interactions.core.AppyxComponent +import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup -import com.bumble.appyx.interactions.core.ui.output.ElementUiModel import com.bumble.appyx.interactions.widgets.ui.WidgetsStack3D import com.bumble.appyx.samples.common.widget.CalendarWidget import com.bumble.appyx.samples.common.widget.TimerWidget @@ -104,9 +105,9 @@ private fun WidgetsUi( ), screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - child = { elementUiModel -> + child = { WidgetTypeElement( - elementUiModel = elementUiModel, + element = it, modifier = Modifier .fillMaxWidth() .requiredHeight(240.dp) @@ -117,33 +118,27 @@ private fun WidgetsUi( @Composable private fun WidgetTypeElement( - elementUiModel: ElementUiModel, + element: Element, modifier: Modifier = Modifier, ) { - when (elementUiModel.element.interactionTarget) { + when (element.interactionTarget) { WidgetsType.Weather -> WeatherWidget( currentTemperature = 22.3f, lowTemperature = 16.7f, highTemperature = 31.4f, painterResource("sky.png"), - modifier = Modifier - .then(elementUiModel.modifier) - .then(modifier) + modifier = modifier ) WidgetsType.Timer -> TimerWidget( - modifier = Modifier - .then(elementUiModel.modifier) - .then(modifier) + modifier = modifier ) WidgetsType.Calendar -> CalendarWidget( - modifier = Modifier - .then(elementUiModel.modifier) - .then(modifier) + modifier = modifier ) } } diff --git a/demos/mkdocs/appyx-components/common/src/commonMain/kotlin/com/bumble/appyx/demos/common/AppyxWebSample.kt b/demos/mkdocs/appyx-components/common/src/commonMain/kotlin/com/bumble/appyx/demos/common/AppyxWebSample.kt index de9eeb0f4..8a1f6b0e4 100644 --- a/demos/mkdocs/appyx-components/common/src/commonMain/kotlin/com/bumble/appyx/demos/common/AppyxWebSample.kt +++ b/demos/mkdocs/appyx-components/common/src/commonMain/kotlin/com/bumble/appyx/demos/common/AppyxWebSample.kt @@ -24,11 +24,10 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.bumble.appyx.demos.common.InteractionTarget.Element import com.bumble.appyx.interactions.core.AppyxComponent +import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.model.BaseAppyxComponent import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup -import com.bumble.appyx.interactions.core.ui.output.ElementUiModel import kotlin.random.Random sealed class InteractionTarget { @@ -55,9 +54,9 @@ fun AppyxWebSample( actions: Map Unit>, modifier: Modifier = Modifier, childSize: ChildSize = ChildSize.SMALL, - element: @Composable (ElementUiModel) -> Unit = { + child: @Composable (Element) -> Unit = { ModalUi( - elementUiModel = it, + element = it, isChildMaxSize = childSize == ChildSize.MAX ) } @@ -89,8 +88,8 @@ fun AppyxWebSample( appyxComponent = appyxComponent, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - ) { elementUiModel -> - element(elementUiModel) + ) { + child(it) } } } @@ -127,7 +126,7 @@ val colors = listOf( @Composable fun ModalUi( - elementUiModel: ElementUiModel, + element: Element, isChildMaxSize: Boolean, modifier: Modifier = Modifier ) { @@ -135,10 +134,9 @@ fun ModalUi( modifier = modifier .fillMaxSize() .padding(if (isChildMaxSize) 0.dp else 8.dp) - .then(elementUiModel.modifier) .background( - color = when (val target = elementUiModel.element.interactionTarget) { - is Element -> colors.getOrElse(target.idx % colors.size) { Color.Cyan } + color = when (val target = element.interactionTarget) { + is com.bumble.appyx.demos.common.InteractionTarget.Element -> colors.getOrElse(target.idx % colors.size) { Color.Cyan } else -> { Color.Cyan } @@ -148,7 +146,7 @@ fun ModalUi( ) { Text( modifier = Modifier.align(Alignment.Center), - text = elementUiModel.element.interactionTarget.toString(), + text = element.interactionTarget.toString(), fontSize = 12.sp, color = Color.White ) diff --git a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt index 128e5d703..49fce746b 100644 --- a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt +++ b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt @@ -1,4 +1,5 @@ @file:Suppress("MatchingDeclarationName") + package com.bumble.appyx.demos.dragprediction import androidx.compose.animation.animateColorAsState @@ -195,10 +196,9 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - ) { elementUiModel -> + ) { Box( modifier = Modifier.size(60.dp) - .then(elementUiModel.modifier) ) { Text( modifier = Modifier.align(Alignment.Center), diff --git a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt index b781b8fb4..7c930eeda 100644 --- a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt +++ b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt @@ -1,4 +1,5 @@ @file:Suppress("MatchingDeclarationName") + package com.bumble.appyx.demos.incompletedrag import androidx.compose.animation.animateColorAsState @@ -146,11 +147,10 @@ fun ModelUi( screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, ) - { elementUiModel -> + { Box( modifier = Modifier .size(60.dp) - .then(elementUiModel.modifier) ) { Text( modifier = Modifier.align(Alignment.Center), diff --git a/demos/mkdocs/appyx-interactions/interactions/observemp/web/src/jsMain/kotlin/com/bumble/appyx/demos/observemp/ObserveMotionPropertiesSample.kt b/demos/mkdocs/appyx-interactions/interactions/observemp/web/src/jsMain/kotlin/com/bumble/appyx/demos/observemp/ObserveMotionPropertiesSample.kt index 7475dd849..46b3e2629 100644 --- a/demos/mkdocs/appyx-interactions/interactions/observemp/web/src/jsMain/kotlin/com/bumble/appyx/demos/observemp/ObserveMotionPropertiesSample.kt +++ b/demos/mkdocs/appyx-interactions/interactions/observemp/web/src/jsMain/kotlin/com/bumble/appyx/demos/observemp/ObserveMotionPropertiesSample.kt @@ -27,7 +27,7 @@ import com.bumble.appyx.components.spotlight.ui.sliderrotation.SpotlightSliderRo import com.bumble.appyx.demos.common.AppyxWebSample import com.bumble.appyx.demos.common.InteractionTarget import com.bumble.appyx.demos.common.colors -import com.bumble.appyx.interactions.core.ui.output.ElementUiModel +import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.ui.property.impl.RotationY import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionAlignment import com.bumble.appyx.interactions.core.ui.property.motionPropertyRenderValue @@ -75,16 +75,15 @@ fun ObserveMotionPropertiesSample( @Composable fun ModalUi( - elementUiModel: ElementUiModel, + element: Element, isChildMaxSize: Boolean, modifier: Modifier = Modifier ) { Box( modifier = modifier .fillMaxSize(if (isChildMaxSize) 1f else 0.9f) - .then(elementUiModel.modifier) .background( - color = when (val target = elementUiModel.element.interactionTarget) { + color = when (val target = element.interactionTarget) { is com.bumble.appyx.demos.common.InteractionTarget.Element -> colors.getOrElse( target.idx % colors.size ) { Color.Cyan } @@ -102,7 +101,7 @@ fun ModalUi( verticalArrangement = Arrangement.spacedBy(8.dp) ) { Text( - text = elementUiModel.element.interactionTarget.toString(), + text = element.interactionTarget.toString(), fontSize = 12.sp, color = Color.White ) diff --git a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt index 9120adcb7..b22f31ca9 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt @@ -143,11 +143,10 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - ) { elementUiModel -> + ) { Box( modifier = Modifier .size(60.dp) - .then(elementUiModel.modifier) ) { Text( modifier = Modifier.align(Alignment.Center), diff --git a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt index 192d88768..ab85c9181 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt @@ -1,4 +1,5 @@ @file:Suppress("MatchingDeclarationName") + package com.bumble.appyx.demos.sample2 import androidx.compose.animation.animateColorAsState @@ -143,11 +144,10 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - ) { elementUiModel -> + ) { Box( modifier = Modifier .size(60.dp) - .then(elementUiModel.modifier) ) { Text( modifier = Modifier.align(Alignment.Center), diff --git a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt index a5c19ab59..db04c1a79 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt @@ -199,10 +199,9 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - ) { elementUiModel -> + ) { Box( modifier = Modifier.size(60.dp) - .then(elementUiModel.modifier) ) { Text( modifier = Modifier.align(Alignment.Center), From d8b17c0896c9d16a872744fdde7525039ac737f3 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Thu, 11 Jan 2024 14:57:13 +0100 Subject: [PATCH 5/9] Fix param naming for AppyxComponent and TestDrive samples --- .../cards/ui/CardsVisualisation.kt | 2 +- .../promoter/android/PromoterExperiment.kt | 2 +- .../promoter/ui/PromoterVisualisation.kt | 2 +- .../puzzle15/ui/Puzzle15Visualisation.kt | 2 +- .../TestDriveRotationVisualisation.kt | 2 +- .../ui/simple/TestDriveSimpleVisualisation.kt | 2 +- .../backstack/ui/fader/BackStackFader.kt | 2 +- .../ui/parallax/BackStackParallax.kt | 2 +- .../spotlight/android/utils/SpotlightUtils.kt | 6 +- .../spotlight/ui/fader/SpotlightFader.kt | 2 +- .../sample/android/SampleChildren.kt | 6 +- .../appyx/interactions/testing/Utils.kt | 4 +- .../appyx/interactions/core/AppyxComponent.kt | 16 ++-- .../core/model/BaseAppyxComponent.kt | 2 +- .../appyx/interactions/core/ui/Defaults.kt | 6 ++ .../core/ui/gesture/GestureSettleConfig.kt | 5 +- .../appyx/interactions/sample/Children.kt | 87 ------------------- .../transitionmodel/BaseVisualisation.kt | 2 +- .../progress/DragProgressControllerTest.kt | 2 +- .../benchmark/app/mosaic/MosaicComponent.kt | 2 +- .../sample/BackstackExperimentDebug.kt | 4 +- .../interactions/sample/ModalExperiment.kt | 2 +- .../sample/SpotlightExperiment.kt | 6 +- .../sample/SpotlightExperimentDebug.kt | 6 +- .../appyx/interactions/widgets/Widgets.kt | 2 +- .../demos/dragprediction/DragPrediction.kt | 2 + .../DragPredictionVisualisation.kt | 2 +- .../demos/incompletedrag/IncompleteDrag.kt | 2 + .../IncompleteDragVisualisation.kt | 2 +- .../com/bumble/appyx/demos/sample1/Sample1.kt | 1 + .../demos/sample1/Sample1Visualisation.kt | 2 +- .../com/bumble/appyx/demos/sample2/Sample2.kt | 1 + .../demos/sample2/Sample2Visualisation.kt | 2 +- .../com/bumble/appyx/demos/sample3/Sample3.kt | 2 + .../demos/sample3/Sample3Visualisation.kt | 2 +- 35 files changed, 59 insertions(+), 135 deletions(-) create mode 100644 appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/Defaults.kt diff --git a/appyx-components/experimental/cards/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/cards/ui/CardsVisualisation.kt b/appyx-components/experimental/cards/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/cards/ui/CardsVisualisation.kt index aaf046836..4d6a109c0 100644 --- a/appyx-components/experimental/cards/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/cards/ui/CardsVisualisation.kt +++ b/appyx-components/experimental/cards/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/cards/ui/CardsVisualisation.kt @@ -13,7 +13,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragHorizontalDirection -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.Scale import com.bumble.appyx.interactions.core.ui.property.impl.ZIndex diff --git a/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt b/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt index 0d35107d6..f543dd2db 100644 --- a/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt +++ b/appyx-components/experimental/promoter/android/src/main/kotlin/com/bumble/appyx/components/experimental/promoter/android/PromoterExperiment.kt @@ -82,7 +82,7 @@ fun PromoterExperiment(modifier: Modifier = Modifier) { horizontal = 64.dp, vertical = 12.dp ), - child = { + elementUi = { Element( element = it, modifier = Modifier.size(100.dp) diff --git a/appyx-components/experimental/promoter/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/promoter/ui/PromoterVisualisation.kt b/appyx-components/experimental/promoter/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/promoter/ui/PromoterVisualisation.kt index 765399c60..87d3eafc0 100644 --- a/appyx-components/experimental/promoter/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/promoter/ui/PromoterVisualisation.kt +++ b/appyx-components/experimental/promoter/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/promoter/ui/PromoterVisualisation.kt @@ -9,7 +9,7 @@ import com.bumble.appyx.components.experimental.promoter.PromoterModel import com.bumble.appyx.components.experimental.promoter.PromoterModel.State.ElementState import com.bumble.appyx.interactions.core.ui.context.TransitionBounds import com.bumble.appyx.interactions.core.ui.context.UiContext -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec 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 diff --git a/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Visualisation.kt b/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Visualisation.kt index cf4ebc642..7462f52bf 100644 --- a/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Visualisation.kt +++ b/appyx-components/experimental/puzzle15/common/src/commonMain/kotlin/com/bumble/appyx/components/experimental/puzzle15/ui/Puzzle15Visualisation.kt @@ -13,7 +13,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection4 -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.fractionAlignment import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionAlignment import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState diff --git a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/rotation/TestDriveRotationVisualisation.kt b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/rotation/TestDriveRotationVisualisation.kt index 31053fab5..477e888b8 100644 --- a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/rotation/TestDriveRotationVisualisation.kt +++ b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/rotation/TestDriveRotationVisualisation.kt @@ -11,7 +11,7 @@ import com.bumble.appyx.components.internal.testdrive.ui.md_light_green_500 import com.bumble.appyx.components.internal.testdrive.ui.md_red_500 import com.bumble.appyx.components.internal.testdrive.ui.md_yellow_500 import com.bumble.appyx.interactions.core.ui.context.UiContext -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment diff --git a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/simple/TestDriveSimpleVisualisation.kt b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/simple/TestDriveSimpleVisualisation.kt index 673041989..bc6f08e7c 100644 --- a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/simple/TestDriveSimpleVisualisation.kt +++ b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/simple/TestDriveSimpleVisualisation.kt @@ -26,7 +26,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionAlignment diff --git a/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/fader/BackStackFader.kt b/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/fader/BackStackFader.kt index 0606f884b..363508248 100644 --- a/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/fader/BackStackFader.kt +++ b/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/fader/BackStackFader.kt @@ -3,7 +3,7 @@ package com.bumble.appyx.components.backstack.ui.fader import androidx.compose.animation.core.SpringSpec import com.bumble.appyx.components.backstack.BackStackModel import com.bumble.appyx.interactions.core.ui.context.UiContext -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.Alpha import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState import com.bumble.appyx.transitionmodel.BaseVisualisation diff --git a/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/parallax/BackStackParallax.kt b/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/parallax/BackStackParallax.kt index 7984eed91..0de01eb7f 100644 --- a/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/parallax/BackStackParallax.kt +++ b/appyx-components/stable/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/ui/parallax/BackStackParallax.kt @@ -12,7 +12,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragHorizontalDirection -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.Alpha import com.bumble.appyx.interactions.core.ui.property.impl.ColorOverlay import com.bumble.appyx.interactions.core.ui.property.impl.Shadow diff --git a/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt b/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt index 3bc207584..00af0fe3b 100644 --- a/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt +++ b/appyx-components/stable/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/android/utils/SpotlightUtils.kt @@ -17,7 +17,7 @@ import com.bumble.appyx.components.spotlight.ui.slider.SpotlightSlider import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup import com.bumble.appyx.interactions.sample.InteractionTarget import com.bumble.appyx.interactions.sample.android.Element -import com.bumble.appyx.interactions.sample.android.SampleChildren +import com.bumble.appyx.interactions.sample.android.SampleAppyxComponent import com.bumble.appyx.interactions.theme.appyx_dark import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -67,14 +67,14 @@ fun SpotlightUi( modifier: Modifier = Modifier, color: Color = Color.Unspecified ) { - SampleChildren( + SampleAppyxComponent( appyxComponent = spotlight, modifier = modifier .padding( horizontal = 64.dp, vertical = 12.dp ), - child = { element -> + elementUi = { element -> Element( color = color, element = element, diff --git a/appyx-components/stable/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/ui/fader/SpotlightFader.kt b/appyx-components/stable/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/ui/fader/SpotlightFader.kt index 4b59c7a14..101035007 100644 --- a/appyx-components/stable/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/ui/fader/SpotlightFader.kt +++ b/appyx-components/stable/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/ui/fader/SpotlightFader.kt @@ -6,7 +6,7 @@ import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.C import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.DESTROYED import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.STANDARD import com.bumble.appyx.interactions.core.ui.context.UiContext -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.Alpha import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState import com.bumble.appyx.transitionmodel.BaseVisualisation diff --git a/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/android/SampleChildren.kt b/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/android/SampleChildren.kt index 53cb4d465..b3b414e3a 100644 --- a/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/android/SampleChildren.kt +++ b/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/android/SampleChildren.kt @@ -19,11 +19,11 @@ import kotlin.math.roundToInt * For real-life use-cases use the [Children] wrapper directly. */ @Composable -fun SampleChildren( +fun SampleAppyxComponent( appyxComponent: BaseAppyxComponent, modifier: Modifier = Modifier, clipToBounds: Boolean = false, - child: @Composable BoxScope.(Element) -> Unit = { element -> + elementUi: @Composable BoxScope.(Element) -> Unit = { element -> SampleElement(colors = colors, element = element) }, ) { @@ -33,7 +33,7 @@ fun SampleChildren( screenHeightPx = (LocalConfiguration.current.screenHeightDp * LocalDensity.current.density).roundToInt(), modifier = modifier, clipToBounds = clipToBounds, - child = child + elementUi = elementUi ) } diff --git a/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/testing/Utils.kt b/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/testing/Utils.kt index ba590b3d2..42e8266aa 100644 --- a/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/testing/Utils.kt +++ b/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/testing/Utils.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.test.junit4.ComposeContentTestRule import com.bumble.appyx.interactions.core.model.BaseAppyxComponent import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup -import com.bumble.appyx.interactions.sample.android.SampleChildren +import com.bumble.appyx.interactions.sample.android.SampleAppyxComponent import com.bumble.appyx.interactions.theme.appyx_dark import kotlin.random.Random @@ -54,7 +54,7 @@ private fun TestChildrenUi( ) { BoxWithConstraints { val padding = this.maxWidth * (1.0f - fraction) / 2 - SampleChildren( + SampleAppyxComponent( modifier = Modifier .align(Alignment.Center) .padding(horizontal = padding) diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt index 9fc9a3fa8..091cae762 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt @@ -61,7 +61,7 @@ fun AppyxComponent( gestureValidator: GestureValidator = defaultValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, isGestureBoundingBoxTransformed: Boolean = false, - child: @Composable BoxScope.(Element) -> Unit = { _ -> + elementUi: @Composable BoxScope.(Element) -> Unit = { _ -> Text( modifier = Modifier .align(Alignment.Center), @@ -132,25 +132,25 @@ fun AppyxComponent( when { !isGesturesEnabled -> { Box(modifier = elementUiModel.modifier) { - child(elementUiModel.element) + elementUi(elementUiModel.element) } } isGesturesEnabled && isGestureBoundingBoxTransformed -> - ChildGestureSupportTransformBoundingBox( + ChildWithGestureTransformedBoundingBox( appyxComponent = appyxComponent, containerSize = containerSize, gestureExtraTouchAreaPx = gestureExtraTouchAreaPx, gestureValidator = gestureValidator, elementUiModel = elementUiModel, - child = child + child = elementUi ) isGesturesEnabled && !isGestureBoundingBoxTransformed -> - ChildGestureSupportWithoutTransformation( + ChildWithGesture( appyxComponent = appyxComponent, elementUiModel = elementUiModel, - child = child + child = elementUi ) } } @@ -163,7 +163,7 @@ fun AppyxComponent( } @Composable -private fun ChildGestureSupportWithoutTransformation( +private fun ChildWithGesture( appyxComponent: BaseAppyxComponent, elementUiModel: ElementUiModel, child: @Composable BoxScope.(Element) -> Unit @@ -195,7 +195,7 @@ private fun ChildGestureSupportWitho } @Composable -private fun ChildGestureSupportTransformBoundingBox( +private fun ChildWithGestureTransformedBoundingBox( appyxComponent: BaseAppyxComponent, containerSize: State, gestureExtraTouchAreaPx: Float, diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseAppyxComponent.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseAppyxComponent.kt index eb48e41a4..0990c6c62 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseAppyxComponent.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseAppyxComponent.kt @@ -22,7 +22,7 @@ import com.bumble.appyx.interactions.core.ui.context.TransitionBounds import com.bumble.appyx.interactions.core.ui.context.TransitionBoundsAware import com.bumble.appyx.interactions.core.ui.context.UiContext import com.bumble.appyx.interactions.core.ui.context.UiContextAware -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig import com.bumble.appyx.interactions.core.ui.output.ElementUiModel diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/Defaults.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/Defaults.kt new file mode 100644 index 000000000..9f077d5c6 --- /dev/null +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/Defaults.kt @@ -0,0 +1,6 @@ +package com.bumble.appyx.interactions.core.ui + +import androidx.compose.animation.core.SpringSpec +import androidx.compose.animation.core.spring + +val DefaultAnimationSpec: SpringSpec = spring() diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/gesture/GestureSettleConfig.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/gesture/GestureSettleConfig.kt index 713355ed8..76286232c 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/gesture/GestureSettleConfig.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/gesture/GestureSettleConfig.kt @@ -1,9 +1,8 @@ package com.bumble.appyx.interactions.core.ui.gesture import androidx.compose.animation.core.AnimationSpec -import androidx.compose.animation.core.SpringSpec -import androidx.compose.animation.core.spring import androidx.compose.runtime.Immutable +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec @Immutable data class GestureSettleConfig( @@ -11,5 +10,3 @@ data class GestureSettleConfig( val completeGestureSpec: AnimationSpec = DefaultAnimationSpec, val revertGestureSpec: AnimationSpec = DefaultAnimationSpec, ) - -val DefaultAnimationSpec: SpringSpec = spring() diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt index 1f205eccf..9df8dbba5 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt @@ -17,93 +17,6 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.bumble.appyx.interactions.core.Element -import com.bumble.appyx.interactions.core.ui.output.ElementUiModel - -// -//@Composable -//fun Children( -// appyxComponent: BaseAppyxComponent, -// screenWidthPx: Int, -// screenHeightPx: Int, -// modifier: Modifier = Modifier, -// clipToBounds: Boolean = false, -// childContent: @Composable (ElementUiModel) -> Unit = {}, -// childWrapper: @Composable (ElementUiModel) -> Unit = { frameModel -> -// ChildWrapper(frameModel) { -// childContent(frameModel) -// } -// }, -//) { -// val density = LocalDensity.current -// val elementUiModels by appyxComponent.uiModels.collectAsState() -// val coroutineScope = rememberCoroutineScope() -// -// SideEffect { -// appyxComponent.updateContext( -// UiContext( -// coroutineScope = coroutineScope, -// clipToBounds = clipToBounds -// ) -// ) -// } -// Box( -// modifier = modifier -// .fillMaxSize() -// .then(if (clipToBounds) Modifier.clipToBounds() else Modifier) -// .onPlaced { -// appyxComponent.updateBounds( -// TransitionBounds( -// density = density, -// widthPx = it.size.width, -// heightPx = it.size.height, -// screenWidthPx = screenWidthPx, -// screenHeightPx = screenHeightPx -// ) -// ) -// } -// .onPointerEvent { -// if (it.type == PointerEventType.Release) { -// appyxComponent.onRelease() -// } -// } -// ) { -// CompositionLocalProvider(LocalBoxScope provides this) { -// elementUiModels -// .forEach { elementUiModel -> -// key(elementUiModel.element.id) { -// elementUiModel.persistentContainer() -// val isVisible by elementUiModel.visibleState.collectAsState() -// if (isVisible) { -// CompositionLocalProvider( -// LocalMotionProperties provides elementUiModel.motionProperties -// ) { -// childWrapper.invoke(elementUiModel) -// } -// } -// } -// } -// } -// } -//} - -@Composable -fun ChildWrapper( - elementUiModel: ElementUiModel<*>, - modifier: Modifier = Modifier.fillMaxSize(), - contentDescription: String? = null, - content: @Composable () -> Unit -) { - Box( - modifier = Modifier - .then(elementUiModel.modifier) - .then(modifier) - .semantics { - contentDescription?.let { this.contentDescription = it } - } - ) { - content() - } -} @Suppress( "MagicNumber", diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseVisualisation.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseVisualisation.kt index 4789f7803..4314eb6cb 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseVisualisation.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseVisualisation.kt @@ -14,7 +14,7 @@ import com.bumble.appyx.interactions.core.model.transition.Update import com.bumble.appyx.interactions.core.ui.Visualisation import com.bumble.appyx.interactions.core.ui.context.TransitionBounds import com.bumble.appyx.interactions.core.ui.context.UiContext -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.math.lerpFloat import com.bumble.appyx.interactions.core.ui.output.ElementUiModel import com.bumble.appyx.interactions.core.ui.property.impl.GenericFloatProperty diff --git a/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressControllerTest.kt b/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressControllerTest.kt index 2220cd68c..b5cafca18 100644 --- a/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressControllerTest.kt +++ b/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressControllerTest.kt @@ -6,7 +6,7 @@ import com.bumble.appyx.InteractionTarget.Child1 import com.bumble.appyx.InteractionTarget.Child2 import com.bumble.appyx.interactions.core.TestGestures import com.bumble.appyx.interactions.core.TestTransitionModel -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import kotlin.test.Test import kotlin.test.asserter diff --git a/benchmark/benchmark-app/src/main/kotlin/com/bumble/appyx/benchmark/app/mosaic/MosaicComponent.kt b/benchmark/benchmark-app/src/main/kotlin/com/bumble/appyx/benchmark/app/mosaic/MosaicComponent.kt index 67caa5d8a..31e9cbf8a 100644 --- a/benchmark/benchmark-app/src/main/kotlin/com/bumble/appyx/benchmark/app/mosaic/MosaicComponent.kt +++ b/benchmark/benchmark-app/src/main/kotlin/com/bumble/appyx/benchmark/app/mosaic/MosaicComponent.kt @@ -3,7 +3,7 @@ package com.bumble.appyx.benchmark.app.mosaic import androidx.compose.animation.core.SpringSpec import com.bumble.appyx.benchmark.app.mosaic.MosaicModel.State import com.bumble.appyx.interactions.core.model.BaseAppyxComponent -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.navigation.state.SavedStateMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/BackstackExperimentDebug.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/BackstackExperimentDebug.kt index 170d4b337..1359b1570 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/BackstackExperimentDebug.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/BackstackExperimentDebug.kt @@ -18,7 +18,7 @@ import com.bumble.appyx.components.backstack.BackStackModel import com.bumble.appyx.components.backstack.operation.pop import com.bumble.appyx.components.backstack.ui.fader.BackStackFader import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.interactions.sample.android.SampleChildren +import com.bumble.appyx.interactions.sample.android.SampleAppyxComponent import com.bumble.appyx.interactions.theme.appyx_dark @@ -66,7 +66,7 @@ fun BackStackExperimentDebug(modifier: Modifier = Modifier) { Text("POP") } - SampleChildren( + SampleAppyxComponent( modifier = Modifier .padding( horizontal = 64.dp, diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/ModalExperiment.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/ModalExperiment.kt index 73da8093e..608799b0a 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/ModalExperiment.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/ModalExperiment.kt @@ -89,7 +89,7 @@ fun ModalUi( clipToBounds = false, appyxComponent = modal, modifier = modifier, - child = { element -> + elementUi = { element -> Element( color = color, element = element diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt index c7221f288..ddeb6a00c 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt @@ -27,7 +27,7 @@ import com.bumble.appyx.components.spotlight.ui.slider.SpotlightSlider import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup import com.bumble.appyx.interactions.sample.android.Element -import com.bumble.appyx.interactions.sample.android.SampleChildren +import com.bumble.appyx.interactions.sample.android.SampleAppyxComponent import com.bumble.appyx.interactions.theme.appyx_dark import com.bumble.appyx.interactions.sample.InteractionTarget as Target @@ -131,7 +131,7 @@ fun SpotlightUi( modifier: Modifier = Modifier, color: Color = Color.Unspecified ) { - SampleChildren( + SampleAppyxComponent( clipToBounds = false, appyxComponent = spotlight, modifier = modifier @@ -139,7 +139,7 @@ fun SpotlightUi( horizontal = 64.dp, vertical = 12.dp ), - child = { element -> + elementUi = { element -> Element( color = color, element = element, diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperimentDebug.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperimentDebug.kt index c30da9d7c..d0258bdeb 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperimentDebug.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperimentDebug.kt @@ -19,7 +19,7 @@ import com.bumble.appyx.components.spotlight.operation.previous import com.bumble.appyx.components.spotlight.ui.slider.SpotlightSlider import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup import com.bumble.appyx.interactions.sample.android.Element -import com.bumble.appyx.interactions.sample.android.SampleChildren +import com.bumble.appyx.interactions.sample.android.SampleAppyxComponent import com.bumble.appyx.interactions.theme.appyx_dark @ExperimentalMaterialApi @@ -69,13 +69,13 @@ fun SpotlightExperimentDebug(modifier: Modifier = Modifier) { spotlight.setNormalisedProgress(it) }) - SampleChildren( + SampleAppyxComponent( modifier = Modifier.padding( horizontal = 64.dp, vertical = 12.dp ), appyxComponent = spotlight, - child = { element -> + elementUi = { element -> Element( element = element ) diff --git a/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt b/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt index 4f0154ba4..b435ddb6e 100644 --- a/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt +++ b/demos/appyx-interactions/desktop/src/desktopMain/kotlin/com/bumble/appyx/interactions/widgets/Widgets.kt @@ -105,7 +105,7 @@ private fun WidgetsUi( ), screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - child = { + elementUi = { WidgetTypeElement( element = it, modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt index 49fce746b..36ff494dc 100644 --- a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt +++ b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt @@ -196,6 +196,8 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, + isGestureBoundingBoxTransformed = true, + modifier = modifier ) { Box( modifier = Modifier.size(60.dp) diff --git a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPredictionVisualisation.kt b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPredictionVisualisation.kt index 404b57124..f859d8399 100644 --- a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPredictionVisualisation.kt +++ b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPredictionVisualisation.kt @@ -23,7 +23,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPLEFT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.Scale diff --git a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt index 7c930eeda..e05c1d20c 100644 --- a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt +++ b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt @@ -146,6 +146,8 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, + isGestureBoundingBoxTransformed = true, + modifier = modifier ) { Box( diff --git a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDragVisualisation.kt b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDragVisualisation.kt index 807ba1ea2..0c47ff2c6 100644 --- a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDragVisualisation.kt +++ b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDragVisualisation.kt @@ -24,7 +24,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.BottomEnd diff --git a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt index b22f31ca9..5594e6efb 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt @@ -143,6 +143,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, + isGestureBoundingBoxTransformed = true ) { Box( modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1Visualisation.kt b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1Visualisation.kt index de5838d89..09f0aa921 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1Visualisation.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1Visualisation.kt @@ -24,7 +24,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.BottomEnd diff --git a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt index ab85c9181..ad8a5c9db 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt @@ -144,6 +144,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, + isGestureBoundingBoxTransformed = true ) { Box( modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2Visualisation.kt b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2Visualisation.kt index bb6e28593..49b72f4ad 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2Visualisation.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2Visualisation.kt @@ -24,7 +24,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.RotationZ import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment diff --git a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt index db04c1a79..7319655ae 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt @@ -199,6 +199,8 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, + isGestureBoundingBoxTransformed = true, + modifier = modifier ) { Box( modifier = Modifier.size(60.dp) diff --git a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3Visualisation.kt b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3Visualisation.kt index 92cae39c4..d15c2f351 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3Visualisation.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3Visualisation.kt @@ -24,7 +24,7 @@ import com.bumble.appyx.interactions.core.ui.gesture.Drag.Direction8.UPRIGHT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.gesture.dragDirection8 -import com.bumble.appyx.interactions.core.ui.gesture.DefaultAnimationSpec +import com.bumble.appyx.interactions.core.ui.DefaultAnimationSpec import com.bumble.appyx.interactions.core.ui.property.impl.BackgroundColor import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.BottomEnd import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignment.InsideAlignment.Companion.BottomStart From 4e01e43807054b22601f449eaf4f2ba96d6ee2c1 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Thu, 11 Jan 2024 16:27:57 +0100 Subject: [PATCH 6/9] Rename composable func prefix from Child to Element --- .../appyx/interactions/core/AppyxComponent.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt index 091cae762..eb7424e07 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxComponent.kt @@ -137,20 +137,20 @@ fun AppyxComponent( } isGesturesEnabled && isGestureBoundingBoxTransformed -> - ChildWithGestureTransformedBoundingBox( + ElementWithGestureTransformedBoundingBox( appyxComponent = appyxComponent, containerSize = containerSize, gestureExtraTouchAreaPx = gestureExtraTouchAreaPx, gestureValidator = gestureValidator, elementUiModel = elementUiModel, - child = elementUi + elementUi = elementUi ) isGesturesEnabled && !isGestureBoundingBoxTransformed -> - ChildWithGesture( + ElementWithGesture( appyxComponent = appyxComponent, elementUiModel = elementUiModel, - child = elementUi + elementUi = elementUi ) } } @@ -163,10 +163,10 @@ fun AppyxComponent( } @Composable -private fun ChildWithGesture( +private fun ElementWithGesture( appyxComponent: BaseAppyxComponent, elementUiModel: ElementUiModel, - child: @Composable BoxScope.(Element) -> Unit + elementUi: @Composable BoxScope.(Element) -> Unit ) { val density = LocalDensity.current Box(modifier = Modifier @@ -190,18 +190,18 @@ private fun ChildWithGesture( } .then(elementUiModel.modifier) ) { - child(elementUiModel.element) + elementUi(elementUiModel.element) } } @Composable -private fun ChildWithGestureTransformedBoundingBox( +private fun ElementWithGestureTransformedBoundingBox( appyxComponent: BaseAppyxComponent, containerSize: State, gestureExtraTouchAreaPx: Float, gestureValidator: GestureValidator, elementUiModel: ElementUiModel, - child: @Composable BoxScope.(Element) -> Unit + elementUi: @Composable BoxScope.(Element) -> Unit ) { var transformedBoundingBox by remember(elementUiModel.element.id) { mutableStateOf(Rect.Zero) } var elementSize by remember(elementUiModel.element.id) { mutableStateOf(IntSize.Zero) } @@ -255,7 +255,7 @@ private fun ChildWithGestureTransfor transformedBoundingBox.center - localCenter } ) { - child(elementUiModel.element) + elementUi(elementUiModel.element) } } From 16774f3203cb8414d003487e3aedbe4b6d3141c0 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Fri, 19 Jan 2024 09:53:25 +0000 Subject: [PATCH 7/9] Replace boolean flag isGestureBoundingBoxTransformed with enum GesturesRelation --- .../internal/testdrive/TestDriveExperiment.kt | 3 +-- .../interactions/core/AppyxInteractionsContainer.kt | 11 ++++++++--- .../navigation/composable/AppyxNavigationContainer.kt | 5 +++-- .../appyx/demos/dragprediction/DragPrediction.kt | 1 - .../appyx/demos/incompletedrag/IncompleteDrag.kt | 3 ++- .../kotlin/com/bumble/appyx/demos/sample1/Sample1.kt | 3 ++- .../kotlin/com/bumble/appyx/demos/sample2/Sample2.kt | 3 ++- .../kotlin/com/bumble/appyx/demos/sample3/Sample3.kt | 3 ++- 8 files changed, 20 insertions(+), 12 deletions(-) diff --git a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt index bb0e82958..536154b33 100644 --- a/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt +++ b/appyx-components/internal/test-drive/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt @@ -138,8 +138,7 @@ fun TestDriveUi( screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, appyxComponent = testDrive, - gestureValidator = gestureValidator, - isGestureBoundingBoxTransformed = true + gestureValidator = gestureValidator ) { Box( modifier = Modifier diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt index 99937f773..bedcc51a9 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt @@ -50,6 +50,11 @@ import com.bumble.appyx.interactions.core.ui.property.motionPropertyRenderValue private val defaultExtraTouch = 48f.dp +enum class GesturesRelation { + Container, + Element +} + @Suppress("LongMethod") @Composable fun AppyxInteractionsContainer( @@ -60,7 +65,7 @@ fun AppyxInteractionsContainer( clipToBounds: Boolean = false, gestureValidator: GestureValidator = defaultValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, - isGestureBoundingBoxTransformed: Boolean = false, + gestureRelativeTo: GesturesRelation = GesturesRelation.Container, elementUi: @Composable BoxScope.(Element) -> Unit = { _ -> Text( modifier = Modifier @@ -136,7 +141,7 @@ fun AppyxInteractionsContainer( } } - isGesturesEnabled && isGestureBoundingBoxTransformed -> + gestureRelativeTo == GesturesRelation.Element -> ElementWithGestureTransformedBoundingBox( appyxComponent = appyxComponent, containerSize = containerSize, @@ -146,7 +151,7 @@ fun AppyxInteractionsContainer( elementUi = elementUi ) - isGesturesEnabled && !isGestureBoundingBoxTransformed -> + gestureRelativeTo == GesturesRelation.Container -> ElementWithGesture( appyxComponent = appyxComponent, elementUiModel = elementUiModel, diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt index b6c1839f8..3edd8af35 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt @@ -7,6 +7,7 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.bumble.appyx.interactions.core.AppyxInteractionsContainer import com.bumble.appyx.interactions.core.Element +import com.bumble.appyx.interactions.core.GesturesRelation import com.bumble.appyx.interactions.core.gesture.GestureValidator import com.bumble.appyx.interactions.core.model.BaseAppyxComponent import com.bumble.appyx.navigation.integration.LocalScreenSize @@ -23,7 +24,7 @@ fun ParentNode.AppyxNavigationCon clipToBounds: Boolean = false, gestureValidator: GestureValidator = GestureValidator.permissiveValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, - isGestureBoundingBoxTransformed: Boolean = false, + gestureRelativeTo: GesturesRelation = GesturesRelation.Container, decorator: @Composable (child: ChildRenderer, element: Element) -> Unit = { child, _ -> child() } @@ -40,7 +41,7 @@ fun ParentNode.AppyxNavigationCon clipToBounds, gestureValidator, gestureExtraTouchArea, - isGestureBoundingBoxTransformed + gestureRelativeTo ) { element -> Child(element, decorator) } diff --git a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt index 52e80e85b..c5581944e 100644 --- a/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt +++ b/demos/mkdocs/appyx-interactions/gestures/dragprediction/web/src/jsMain/kotlin/com/bumble/appyx/demos/dragprediction/DragPrediction.kt @@ -196,7 +196,6 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - isGestureBoundingBoxTransformed = true, modifier = modifier ) { Box( diff --git a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt index 599cc049b..92bde2111 100644 --- a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt +++ b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt @@ -38,6 +38,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.incompletedrag.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer +import com.bumble.appyx.interactions.core.GesturesRelation import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -146,7 +147,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - isGestureBoundingBoxTransformed = true, + gestureRelativeTo = GesturesRelation.Element, modifier = modifier ) { diff --git a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt index 289248e8b..45c0af8c5 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt @@ -37,6 +37,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample1.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer +import com.bumble.appyx.interactions.core.GesturesRelation import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -143,7 +144,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - isGestureBoundingBoxTransformed = true + gestureRelativeTo = GesturesRelation.Element ) { Box( modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt index 199f68d86..7422b7d7f 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt @@ -38,6 +38,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample2.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer +import com.bumble.appyx.interactions.core.GesturesRelation import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -144,7 +145,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - isGestureBoundingBoxTransformed = true + gestureRelativeTo = GesturesRelation.Element ) { Box( modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt index d0fb0308a..f9b43fb79 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt @@ -46,6 +46,7 @@ import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample3.InteractionTarget.Child1 import com.bumble.appyx.demos.sample3.Sample3Visualisation.Companion.toTargetUiState import com.bumble.appyx.interactions.core.AppyxInteractionsContainer +import com.bumble.appyx.interactions.core.GesturesRelation import com.bumble.appyx.interactions.core.model.transition.Keyframes import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.KEYFRAME @@ -199,7 +200,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - isGestureBoundingBoxTransformed = true, + gestureRelativeTo = GesturesRelation.Element, modifier = modifier ) { Box( From afb36ca03670ede215350298eb362012c8e763f0 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Tue, 23 Jan 2024 14:41:24 +0000 Subject: [PATCH 8/9] Rename GestureRelation to GesturesReferencePoint --- .../appyx/interactions/core/AppyxInteractionsContainer.kt | 8 ++++---- .../navigation/composable/AppyxNavigationContainer.kt | 4 ++-- .../bumble/appyx/demos/incompletedrag/IncompleteDrag.kt | 4 ++-- .../kotlin/com/bumble/appyx/demos/sample1/Sample1.kt | 4 ++-- .../kotlin/com/bumble/appyx/demos/sample2/Sample2.kt | 4 ++-- .../kotlin/com/bumble/appyx/demos/sample3/Sample3.kt | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt index bedcc51a9..d0f7c5fa9 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt @@ -50,7 +50,7 @@ import com.bumble.appyx.interactions.core.ui.property.motionPropertyRenderValue private val defaultExtraTouch = 48f.dp -enum class GesturesRelation { +enum class GesturesReferencePoint { Container, Element } @@ -65,7 +65,7 @@ fun AppyxInteractionsContainer( clipToBounds: Boolean = false, gestureValidator: GestureValidator = defaultValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, - gestureRelativeTo: GesturesRelation = GesturesRelation.Container, + gestureRelativeTo: GesturesReferencePoint = GesturesReferencePoint.Container, elementUi: @Composable BoxScope.(Element) -> Unit = { _ -> Text( modifier = Modifier @@ -141,7 +141,7 @@ fun AppyxInteractionsContainer( } } - gestureRelativeTo == GesturesRelation.Element -> + gestureRelativeTo == GesturesReferencePoint.Element -> ElementWithGestureTransformedBoundingBox( appyxComponent = appyxComponent, containerSize = containerSize, @@ -151,7 +151,7 @@ fun AppyxInteractionsContainer( elementUi = elementUi ) - gestureRelativeTo == GesturesRelation.Container -> + gestureRelativeTo == GesturesReferencePoint.Container -> ElementWithGesture( appyxComponent = appyxComponent, elementUiModel = elementUiModel, diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt index 3edd8af35..827174c6d 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt @@ -7,7 +7,7 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.bumble.appyx.interactions.core.AppyxInteractionsContainer import com.bumble.appyx.interactions.core.Element -import com.bumble.appyx.interactions.core.GesturesRelation +import com.bumble.appyx.interactions.core.GesturesReferencePoint import com.bumble.appyx.interactions.core.gesture.GestureValidator import com.bumble.appyx.interactions.core.model.BaseAppyxComponent import com.bumble.appyx.navigation.integration.LocalScreenSize @@ -24,7 +24,7 @@ fun ParentNode.AppyxNavigationCon clipToBounds: Boolean = false, gestureValidator: GestureValidator = GestureValidator.permissiveValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, - gestureRelativeTo: GesturesRelation = GesturesRelation.Container, + gestureRelativeTo: GesturesReferencePoint = GesturesReferencePoint.Container, decorator: @Composable (child: ChildRenderer, element: Element) -> Unit = { child, _ -> child() } diff --git a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt index 92bde2111..49c7b65a6 100644 --- a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt +++ b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt @@ -38,7 +38,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.incompletedrag.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer -import com.bumble.appyx.interactions.core.GesturesRelation +import com.bumble.appyx.interactions.core.GesturesReferencePoint import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -147,7 +147,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - gestureRelativeTo = GesturesRelation.Element, + gestureRelativeTo = GesturesReferencePoint.Element, modifier = modifier ) { diff --git a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt index 45c0af8c5..6de0ad26a 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt @@ -37,7 +37,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample1.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer -import com.bumble.appyx.interactions.core.GesturesRelation +import com.bumble.appyx.interactions.core.GesturesReferencePoint import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -144,7 +144,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - gestureRelativeTo = GesturesRelation.Element + gestureRelativeTo = GesturesReferencePoint.Element ) { Box( modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt index 7422b7d7f..2545f2389 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt @@ -38,7 +38,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample2.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer -import com.bumble.appyx.interactions.core.GesturesRelation +import com.bumble.appyx.interactions.core.GesturesReferencePoint import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -145,7 +145,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - gestureRelativeTo = GesturesRelation.Element + gestureRelativeTo = GesturesReferencePoint.Element ) { Box( modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt index f9b43fb79..a0aa2babb 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt @@ -46,7 +46,7 @@ import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample3.InteractionTarget.Child1 import com.bumble.appyx.demos.sample3.Sample3Visualisation.Companion.toTargetUiState import com.bumble.appyx.interactions.core.AppyxInteractionsContainer -import com.bumble.appyx.interactions.core.GesturesRelation +import com.bumble.appyx.interactions.core.GesturesReferencePoint import com.bumble.appyx.interactions.core.model.transition.Keyframes import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.KEYFRAME @@ -200,7 +200,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - gestureRelativeTo = GesturesRelation.Element, + gestureRelativeTo = GesturesReferencePoint.Element, modifier = modifier ) { Box( From 1eec5c3fe420ada558804fc44138f53ebe8fd5a9 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Tue, 23 Jan 2024 15:33:27 +0000 Subject: [PATCH 9/9] Rename GesturesReferencePoint to GestureReferencePoint --- .../appyx/interactions/core/AppyxInteractionsContainer.kt | 8 ++++---- .../navigation/composable/AppyxNavigationContainer.kt | 4 ++-- .../bumble/appyx/demos/incompletedrag/IncompleteDrag.kt | 4 ++-- .../kotlin/com/bumble/appyx/demos/sample1/Sample1.kt | 4 ++-- .../kotlin/com/bumble/appyx/demos/sample2/Sample2.kt | 4 ++-- .../kotlin/com/bumble/appyx/demos/sample3/Sample3.kt | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt index d0f7c5fa9..f27eed8ff 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/AppyxInteractionsContainer.kt @@ -50,7 +50,7 @@ import com.bumble.appyx.interactions.core.ui.property.motionPropertyRenderValue private val defaultExtraTouch = 48f.dp -enum class GesturesReferencePoint { +enum class GestureReferencePoint { Container, Element } @@ -65,7 +65,7 @@ fun AppyxInteractionsContainer( clipToBounds: Boolean = false, gestureValidator: GestureValidator = defaultValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, - gestureRelativeTo: GesturesReferencePoint = GesturesReferencePoint.Container, + gestureRelativeTo: GestureReferencePoint = GestureReferencePoint.Container, elementUi: @Composable BoxScope.(Element) -> Unit = { _ -> Text( modifier = Modifier @@ -141,7 +141,7 @@ fun AppyxInteractionsContainer( } } - gestureRelativeTo == GesturesReferencePoint.Element -> + gestureRelativeTo == GestureReferencePoint.Element -> ElementWithGestureTransformedBoundingBox( appyxComponent = appyxComponent, containerSize = containerSize, @@ -151,7 +151,7 @@ fun AppyxInteractionsContainer( elementUi = elementUi ) - gestureRelativeTo == GesturesReferencePoint.Container -> + gestureRelativeTo == GestureReferencePoint.Container -> ElementWithGesture( appyxComponent = appyxComponent, elementUiModel = elementUiModel, diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt index 6c5ddacd1..1b5609f1e 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxNavigationContainer.kt @@ -7,7 +7,7 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.bumble.appyx.interactions.core.AppyxInteractionsContainer import com.bumble.appyx.interactions.core.Element -import com.bumble.appyx.interactions.core.GesturesReferencePoint +import com.bumble.appyx.interactions.core.GestureReferencePoint import com.bumble.appyx.interactions.core.gesture.GestureValidator import com.bumble.appyx.interactions.core.model.BaseAppyxComponent import com.bumble.appyx.navigation.integration.LocalScreenSize @@ -26,7 +26,7 @@ fun AppyxNavigationContainer( clipToBounds: Boolean = false, gestureValidator: GestureValidator = GestureValidator.defaultValidator, gestureExtraTouchArea: Dp = defaultExtraTouch, - gestureRelativeTo: GesturesReferencePoint = GesturesReferencePoint.Container, + gestureRelativeTo: GestureReferencePoint = GestureReferencePoint.Container, decorator: @Composable (child: ChildRenderer, element: Element) -> Unit = { child, _ -> child() } diff --git a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt index 49c7b65a6..354cf4289 100644 --- a/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt +++ b/demos/mkdocs/appyx-interactions/gestures/incompletedrag/web/src/jsMain/kotlin/com/bumble/appyx/demos/incompletedrag/IncompleteDrag.kt @@ -38,7 +38,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.incompletedrag.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer -import com.bumble.appyx.interactions.core.GesturesReferencePoint +import com.bumble.appyx.interactions.core.GestureReferencePoint import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.gesture.GestureSettleConfig import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -147,7 +147,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - gestureRelativeTo = GesturesReferencePoint.Element, + gestureRelativeTo = GestureReferencePoint.Element, modifier = modifier ) { diff --git a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt index 6de0ad26a..761111964 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample1/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample1/Sample1.kt @@ -37,7 +37,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample1.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer -import com.bumble.appyx.interactions.core.GesturesReferencePoint +import com.bumble.appyx.interactions.core.GestureReferencePoint import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -144,7 +144,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - gestureRelativeTo = GesturesReferencePoint.Element + gestureRelativeTo = GestureReferencePoint.Element ) { Box( modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt index 2545f2389..2e55d8ca8 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample2/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample2/Sample2.kt @@ -38,7 +38,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.Eleme import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample2.InteractionTarget.Child1 import com.bumble.appyx.interactions.core.AppyxInteractionsContainer -import com.bumble.appyx.interactions.core.GesturesReferencePoint +import com.bumble.appyx.interactions.core.GestureReferencePoint import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.ui.helper.AppyxComponentSetup @@ -145,7 +145,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - gestureRelativeTo = GesturesReferencePoint.Element + gestureRelativeTo = GestureReferencePoint.Element ) { Box( modifier = Modifier diff --git a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt index a0aa2babb..69f201c47 100644 --- a/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt +++ b/demos/mkdocs/appyx-interactions/interactions/sample3/web/src/jsMain/kotlin/com/bumble/appyx/demos/sample3/Sample3.kt @@ -46,7 +46,7 @@ import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.demos.sample3.InteractionTarget.Child1 import com.bumble.appyx.demos.sample3.Sample3Visualisation.Companion.toTargetUiState import com.bumble.appyx.interactions.core.AppyxInteractionsContainer -import com.bumble.appyx.interactions.core.GesturesReferencePoint +import com.bumble.appyx.interactions.core.GestureReferencePoint import com.bumble.appyx.interactions.core.model.transition.Keyframes import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.KEYFRAME @@ -200,7 +200,7 @@ fun ModelUi( appyxComponent = testDrive, screenWidthPx = screenWidthPx, screenHeightPx = screenHeightPx, - gestureRelativeTo = GesturesReferencePoint.Element, + gestureRelativeTo = GestureReferencePoint.Element, modifier = modifier ) { Box(