Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onSwipe not work when sub composable item with clickable Modifier #850

Open
CarefulDeveloper opened this issue Jan 10, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@CarefulDeveloper
Copy link

CarefulDeveloper commented Jan 10, 2024

I use MotionLayout(Compose) like this:

MaterialTheme {
    MotionLayout(
        motionScene = MotionScene {
            val mainScreenRef = createRefFor("mainScreen")
            val optionRef = createRefFor("option")

            val start = constraintSet(name = "start") {
                constrain(optionRef) {

                }

                constrain(mainScreenRef) {
                    this.start.linkTo(parent.end)
                    this.translationX = (-72).dp
                    this.scaleX = 0.8f
                    this.scaleY = 0.8f
                    this.customFloat("elevation", 4f)
                    this.customFloat("rounder", 28.0f)
                }
            }
            val end = constraintSet(name = "end") {
                constrain(optionRef) {
                    this.scaleX = 0.8f
                    this.scaleY = 0.8f
                }

                constrain(mainScreenRef) {
                    this.start.linkTo(parent.start)
                    this.top.linkTo(parent.top)
                    this.scaleX = 1f
                    this.scaleY = 1f
                    this.translationX = 0.dp
                    this.customFloat("elevation", 0f)
                    this.customFloat("rounder", 0f)
                }
            }

            defaultTransition(start, end) {
                this.onSwipe = OnSwipe(
                    anchor = mainScreenRef,
                    side = SwipeSide.Start,
                    direction = SwipeDirection.Start
                )
            }
        },
        progress = 0f,
        modifier = Modifier.fillMaxSize()
    ) {

        Box(
            modifier = Modifier
                .fillMaxSize()
                .layoutId("option")
                .border(1.dp, Color.Blue)
        ){
            LazyColumn {
                repeat(100){
                    item {
                        Text(text = "Left Drawer Content ...")
                    }
                }
            }
        }

        Box(
            modifier = Modifier
                .fillMaxSize()
                .layoutId("mainScreen")
                .border(1.dp, Color.Red)
        ){
        }
    }
}

swipe action can work fine:
20240110102832_rec_

If I add Modifier.clickable{}:

// ...
        Box(
            modifier = Modifier
                .fillMaxSize()
                .layoutId("mainScreen")
                .border(1.dp, Color.Red)
                .clickable {  }
        ){
        }
// ...

Swipe action not work now:
20240110102731_rec_

@CarefulDeveloper CarefulDeveloper added the bug Something isn't working label Jan 10, 2024
@CarefulDeveloper CarefulDeveloper changed the title onSwipe not effect when sub composable item with clickable Modifier onSwipe not work when sub composable item with clickable Modifier Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant