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 0d35107d66..f543dd2db3 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/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 3bc207584e..00af0fe3bd 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-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 53cb4d4659..b3b414e3a4 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 ba590b3d24..42e8266aad 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 9fc9a3fa84..091cae762f 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/sample/Children.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/sample/Children.kt index 1f205eccf9..9df8dbba5e 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/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 170d4b3379..1359b1570a 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 73da8093e1..608799b0a9 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 c7221f2887..ddeb6a00cf 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 c30da9d7c5..d0258bdeb8 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 4f0154ba48..b435ddb6e2 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 49fce746b2..36ff494dce 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/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 7c930eedab..e05c1d20c9 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/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 b22f31ca94..5594e6efb9 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/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 ab85c9181d..ad8a5c9db7 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/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 db04c1a79a..7319655aec 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)