Skip to content

Commit

Permalink
Fix param naming for AppyxComponent and TestDrive samples
Browse files Browse the repository at this point in the history
  • Loading branch information
KovalevAndrey committed Jan 11, 2024
1 parent 241bef0 commit 6c2b2c9
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,14 +67,14 @@ fun <InteractionTarget : Any> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import kotlin.math.roundToInt
* For real-life use-cases use the [Children] wrapper directly.
*/
@Composable
fun <InteractionTarget : Any, ModelState : Any> SampleChildren(
fun <InteractionTarget : Any, ModelState : Any> SampleAppyxComponent(
appyxComponent: BaseAppyxComponent<InteractionTarget, ModelState>,
modifier: Modifier = Modifier,
clipToBounds: Boolean = false,
child: @Composable BoxScope.(Element<InteractionTarget>) -> Unit = { element ->
elementUi: @Composable BoxScope.(Element<InteractionTarget>) -> Unit = { element ->
SampleElement(colors = colors, element = element)
},
) {
Expand All @@ -33,7 +33,7 @@ fun <InteractionTarget : Any, ModelState : Any> SampleChildren(
screenHeightPx = (LocalConfiguration.current.screenHeightDp * LocalDensity.current.density).roundToInt(),
modifier = modifier,
clipToBounds = clipToBounds,
child = child
elementUi = elementUi
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -54,7 +54,7 @@ private fun <InteractionTarget : Any, ModelState : Any> TestChildrenUi(
) {
BoxWithConstraints {
val padding = this.maxWidth * (1.0f - fraction) / 2
SampleChildren(
SampleAppyxComponent(
modifier = Modifier
.align(Alignment.Center)
.padding(horizontal = padding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fun <InteractionTarget : Any, ModelState : Any> AppyxComponent(
gestureValidator: GestureValidator = defaultValidator,
gestureExtraTouchArea: Dp = defaultExtraTouch,
isGestureBoundingBoxTransformed: Boolean = false,
child: @Composable BoxScope.(Element<InteractionTarget>) -> Unit = { _ ->
elementUi: @Composable BoxScope.(Element<InteractionTarget>) -> Unit = { _ ->
Text(
modifier = Modifier
.align(Alignment.Center),
Expand Down Expand Up @@ -132,25 +132,25 @@ fun <InteractionTarget : Any, ModelState : Any> 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
)
}
}
Expand All @@ -163,7 +163,7 @@ fun <InteractionTarget : Any, ModelState : Any> AppyxComponent(
}

@Composable
private fun <InteractionTarget : Any, ModelState : Any> ChildGestureSupportWithoutTransformation(
private fun <InteractionTarget : Any, ModelState : Any> ChildWithGesture(
appyxComponent: BaseAppyxComponent<InteractionTarget, ModelState>,
elementUiModel: ElementUiModel<InteractionTarget>,
child: @Composable BoxScope.(Element<InteractionTarget>) -> Unit
Expand Down Expand Up @@ -195,7 +195,7 @@ private fun <InteractionTarget : Any, ModelState : Any> ChildGestureSupportWitho
}

@Composable
private fun <InteractionTarget : Any, ModelState : Any> ChildGestureSupportTransformBoundingBox(
private fun <InteractionTarget : Any, ModelState : Any> ChildWithGestureTransformedBoundingBox(
appyxComponent: BaseAppyxComponent<InteractionTarget, ModelState>,
containerSize: State<IntSize>,
gestureExtraTouchAreaPx: Float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <InteractionTarget : Any, ModelState : Any> Children(
// appyxComponent: BaseAppyxComponent<InteractionTarget, ModelState>,
// screenWidthPx: Int,
// screenHeightPx: Int,
// modifier: Modifier = Modifier,
// clipToBounds: Boolean = false,
// childContent: @Composable (ElementUiModel<InteractionTarget>) -> Unit = {},
// childWrapper: @Composable (ElementUiModel<InteractionTarget>) -> 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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -66,7 +66,7 @@ fun BackStackExperimentDebug(modifier: Modifier = Modifier) {
Text("POP")
}

SampleChildren(
SampleAppyxComponent(
modifier = Modifier
.padding(
horizontal = 64.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fun <InteractionTarget : Any> ModalUi(
clipToBounds = false,
appyxComponent = modal,
modifier = modifier,
child = { element ->
elementUi = { element ->
Element(
color = color,
element = element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -131,15 +131,15 @@ fun <InteractionTarget : Any> SpotlightUi(
modifier: Modifier = Modifier,
color: Color = Color.Unspecified
) {
SampleChildren(
SampleAppyxComponent(
clipToBounds = false,
appyxComponent = spotlight,
modifier = modifier
.padding(
horizontal = 64.dp,
vertical = 12.dp
),
child = { element ->
elementUi = { element ->
Element(
color = color,
element = element,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private fun WidgetsUi(
),
screenWidthPx = screenWidthPx,
screenHeightPx = screenHeightPx,
child = {
elementUi = {
WidgetTypeElement(
element = it,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ fun <InteractionTarget : Any> ModelUi(
appyxComponent = testDrive,
screenWidthPx = screenWidthPx,
screenHeightPx = screenHeightPx,
isGestureBoundingBoxTransformed = true,
modifier = modifier
) {
Box(
modifier = Modifier.size(60.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ fun <InteractionTarget : Any> ModelUi(
appyxComponent = testDrive,
screenWidthPx = screenWidthPx,
screenHeightPx = screenHeightPx,
isGestureBoundingBoxTransformed = true,
modifier = modifier
)
{
Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ fun <InteractionTarget : Any> ModelUi(
appyxComponent = testDrive,
screenWidthPx = screenWidthPx,
screenHeightPx = screenHeightPx,
isGestureBoundingBoxTransformed = true
) {
Box(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ fun <InteractionTarget : Any> ModelUi(
appyxComponent = testDrive,
screenWidthPx = screenWidthPx,
screenHeightPx = screenHeightPx,
isGestureBoundingBoxTransformed = true
) {
Box(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ fun <InteractionTarget : Any> ModelUi(
appyxComponent = testDrive,
screenWidthPx = screenWidthPx,
screenHeightPx = screenHeightPx,
isGestureBoundingBoxTransformed = true,
modifier = modifier
) {
Box(
modifier = Modifier.size(60.dp)
Expand Down

0 comments on commit 6c2b2c9

Please sign in to comment.