Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Agregue un efecto dominó a un gesto personalizado en Jetpack Compose

Intento crear una superficie que se pueda tocar en Jetpack Compose donde la elevación cambia cuando el usuario toca la superficie. El siguiente código ya funciona:

 var tapped by remember { mutableStateOf(false) } val elevation by animateDpAsState( targetValue = if (tapped) 0.dp else 5.dp, animationSpec = tween(50) ) Surface( shape = RoundedCornerShape(20.dp), modifier = Modifier .padding(16.dp) .requiredSize(150.dp) .pointerInput(Unit) { detectTapGestures(onPress = { tapped = true tryAwaitRelease() tapped = false }) }, elevation = elevation ) { ... }

Sin embargo, me gustaría tener un efecto dominó durante el toque. ¿Cómo podría lograr esto?

El botón/superficie predeterminado onClick y en el que se clickable no es adecuado porque solo maneja las entradas de presión pero no los toques.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Utiliza Modifier.indication para agregar un efecto dominó y pasa eventos con interactionSource para actualizar su estado de esta manera:

 var tapped by remember { mutableStateOf(false) } val interactionSource = remember { MutableInteractionSource() } Surface( modifier = Modifier .indication(interactionSource, LocalIndication.current) .pointerInput(Unit) { detectTapGestures(onPress = { offset -> tapped = true val press = PressInteraction.Press(offset) interactionSource.emit(press) tryAwaitRelease() interactionSource.emit(PressInteraction.Release(press)) tapped = false }) } ) { }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!