pepos
09/09/2023, 3:07 AMpepos
09/09/2023, 3:08 AMclass MainActivity : ComponentActivity() {
private lateinit var appyxIntegrationPoint: ActivityIntegrationPoint
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
appyxIntegrationPoint = ActivityIntegrationPoint(
activity = this,
savedInstanceState = savedInstanceState
)
setContent {
NodeHost(appyxIntegrationPoint) {
RootNode(it)
}
}
}
}
class RootNode(
buildContext: BuildContext,
private val backStack: BackStack<NavTarget> = BackStack(
initialElement = NavTarget.Child1,
savedStateMap = buildContext.savedStateMap
)
) : ParentNode<RootNode.NavTarget>(
buildContext = buildContext,
navModel = backStack
) {
sealed class NavTarget : Parcelable {
@Parcelize
data object Child1 : NavTarget()
}
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node =
when (navTarget) {
NavTarget.Child1 -> Child1Node(
buildContext = buildContext
)
}
@Composable
override fun View(modifier: Modifier) {
Box(modifier = modifier.fillMaxSize()) {
var selected by remember { mutableStateOf(true) }
Box(
modifier = modifier
.fillMaxSize()
.background(
if (selected) {
Color.Cyan
} else {
Color.Red
}
).clickable {
selected = !selected
},
contentAlignment = Alignment.Center,
) {
Text(
text = "Google Maps Appyx 1.3.0"
)
}
Children(
modifier = modifier.fillMaxSize(),
navModel = backStack,
transitionHandler = rememberBackstackSlider(transitionSpec = { spring() })
)
}
}
}
class Child1Node(
buildContext: BuildContext
) : Node(buildContext) {
@Composable
override fun View(modifier: Modifier) {
Box(
modifier = modifier,
contentAlignment = Alignment.BottomCenter
) {
Box(modifier = Modifier
.fillMaxWidth()
.height(200.dp)
.padding(10.dp)
.background(Color.Black.copy(alpha = 0.3f))
.clickable { }
)
}
}
}
pepos
09/09/2023, 3:08 AMclass MainActivity : ComponentActivity() {
private lateinit var appyxIntegrationPoint: ActivityIntegrationPoint
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
appyxIntegrationPoint = ActivityIntegrationPoint(
activity = this,
savedInstanceState = savedInstanceState
)
setContent {
NodeHost(
lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle),
integrationPoint = appyxIntegrationPoint
) {
RootNode(it)
}
}
}
}
class RootNode(
buildContext: BuildContext,
private val backStack: BackStack<NavTarget> = BackStack(
model = BackStackModel(
initialTarget = NavTarget.Child1,
savedStateMap = buildContext.savedStateMap
),
motionController = { BackStackSlider(it) }
)
) : ParentNode<RootNode.NavTarget>(
appyxComponent = backStack,
buildContext = buildContext
) {
sealed class NavTarget : Parcelable {
@Parcelize
data object Child1 : NavTarget()
}
override fun resolve(interactionTarget: NavTarget, buildContext: BuildContext): Node =
when (interactionTarget) {
NavTarget.Child1 -> Child1Node(
buildContext = buildContext
)
}
@Composable
override fun View(modifier: Modifier) {
Box(modifier = modifier.fillMaxSize()) {
var selected by remember { mutableStateOf(true) }
Box(
modifier = modifier
.fillMaxSize()
.background(
if (selected) {
Color.Cyan
} else {
Color.Red
}
).clickable {
selected = !selected
},
contentAlignment = Alignment.Center,
) {
Text(
text = "Google Maps Appyx 2.0.0-alpha04"
)
}
AppyxComponent(
appyxComponent = backStack,
modifier = modifier.fillMaxSize()
)
}
}
}
class Child1Node(
buildContext: BuildContext
) : Node(buildContext) {
@Composable
override fun View(modifier: Modifier) {
Box(
modifier = modifier,
contentAlignment = Alignment.BottomCenter
) {
Box(modifier = Modifier
.fillMaxWidth()
.height(200.dp)
.padding(10.dp)
.background(Color.Black.copy(alpha = 0.3f))
.clickable { }
)
}
}
}
Andrei Kovalev
09/09/2023, 11:34 AMAndrei Kovalev
09/09/2023, 11:38 AMZsolt
09/09/2023, 5:16 PMpepos
09/09/2023, 7:12 PMpepos
09/09/2023, 7:12 PMZsolt
09/12/2023, 7:52 AMpepos
09/14/2023, 10:47 PMAndrei Kovalev
09/15/2023, 8:25 AMpepos
09/15/2023, 4:41 PMpepos
09/18/2023, 8:06 PMAndrei Kovalev
09/19/2023, 6:59 AMZsolt
09/19/2023, 11:56 AMBox
as a sibling in the hierarchy to Children
(1.3) / AppyxComponent
(2.0)
2. In Appyx 1.x we don’t have gesture control, so Children
does not add any pointerInput-related code to the composition – meaning when compose figures out which element can handle the input, it goes to your Box
3. In Appyx 2.x we have gesture control for every component, and AppyxComponent
adds relevant pointerInput handling – but whenever the event is not a drag but a click, compose will bubble up the handling to other composables; however, your clickable is set on the Box
which is not a parent in the composable hierarchy but a siblint, so the bubbling up is never passed to it
I assume the same scenario would happen even if not using Appyx 2.0 just any other composable with pointerInput handling on it.
We can consider adding a flag for disabling gestures, but the same scenario could still happen if client code adds gesture handling anywhere down in the composition.Zsolt
10/09/2023, 5:09 PM• By default, when there are multiple eligible composables on the same level of the tree, only the composable with the highest z-index is “hit”. For example, when you add two overlappingI wonder if this would help your case.composables to aButton
, only the one drawn on top receives any pointer events. You can theoretically override this behavior by creating your ownBox
implementation and settingPointerInputModifierNode
to true.sharePointerInputWithSiblings
pepos
06/09/2024, 12:23 AMpepos
06/09/2024, 12:24 AMAppyxInteractionsContainer
opened a PR with our changes: https://github.com/bumble-tech/appyx/pull/707/files