title: How to change state due to action on a different composable
body: <p>I'd like to appologise first, I'm trying to follow the MRE guidline, but, since it's my first time doing it, I might not ommiited enough code to make it as simple as possible, I will try to get better at this s I progress.</p>
  <p>I am having a bit of trouble to work how to recompose animation upon action.</p>
  <p>I have two data classes just for the sake of keeping things orginaize as mucha s I can:</p>
  <pre><code>class DataSize(val width: Float = 0f, val height: Float = 0f, val expand: Float = 0f) {}
  data class DataCoordinates(val x: Float = 0f, val y: Float = 0f) {}
  </code></pre>
  <p>I also have a composable that represents a playing card, which, receives information about the location where it needs to snap on (because that snappable area can and should be dynamic to be changed)
  Once the object is being released out of that snapable area, it returns to it's original position:</p>
  <pre><code>@Composable
  fun CardBox(
      title: String,
      initCoordinated: DataCoordinates = DataCoordinates(),
      boxDimensions: DataSize = DataSize(),
      placementDimensions: DataSize = DataSize(),
      lockCoordinated: DataCoordinates = DataCoordinates(),
      z: Float = 0f,
      content: @Composable() () -&gt; Unit
  ) {
      val cardInitWidth = boxDimensions.width
      val cardInitHeight = boxDimensions.height
      val cardInitWidthInPx = with(LocalDensity.current) { (cardInitWidth).dp.toPx() }
      val cardInitHeightInPx = with(LocalDensity.current) { (cardInitHeight).dp.toPx() }
      val marginSpace = 150
      val lockCoordinatedMarginLow = DataCoordinates(x = lockCoordinated.x - marginSpace, y = lockCoordinated.y - marginSpace)
      val lockCoordinatedMarginHigh = DataCoordinates(x= lockCoordinated.x + marginSpace, y = lockCoordinated.y + marginSpace)
      val placementDimensionsWidthInPx = with(LocalDensity.current) { (placementDimensions.width).dp.toPx() }
      val placementDimensionsHeightInPx = with(LocalDensity.current) { (placementDimensions.height).dp.toPx() }
      val enabledDragging = remember { mutableStateOf(true) }
      val interactionSource = remember { MutableInteractionSource() }
      val isPressed by interactionSource.collectIsPressedAsState()
      val coroutineScope = rememberCoroutineScope()
      val clickable = Modifier.clickable(interactionSource = interactionSource, indication = LocalIndication.current) {}
      val size = animateSizeAsState(targetValue = if (enabledDragging.value &amp;&amp; !isPressed) { Size(width = cardInitWidth, height = cardInitHeight) } else { Size(width = cardInitWidth + boxDimensions.expand, height = cardInitHeight + boxDimensions.expand) })
      val offsetX  =  remember { Animatable(initialValue = initCoordinated.x) }
      val offsetY  =  remember { Animatable(initialValue = initCoordinated.y) }
      val zV = remember { mutableStateOf(z) }
      val atLockPosition = remember { mutableStateOf(false) }
  
      Box(
          modifier = Modifier
              .fillMaxSize()
              .zIndex(
                  zIndex = if (enabledDragging.value &amp;&amp; !isPressed) {
                      zV.value
                  } else {
                      100f
                  }
              )
              .offset {
                  IntOffset(
                      x = offsetX.value.roundToInt(),
                      y = offsetY.value.roundToInt()
                  )
              }
      ) {
          Box(
              modifier = Modifier
                  .size(size.value.width.dp, size.value.height.dp)
                  .background(color = MaterialTheme.colors.primary)
                  .border(BorderStroke(1.dp, Color.Black))
                  .pointerInput(Unit) {
                      detectDragGestures(
                          onDragStart = {
                              enabledDragging.value = !enabledDragging.value
                          },
                          onDrag = { change, dragAmount -&gt;
                              change.consumeAllChanges()
                              coroutineScope.launch {
                                  offsetX.snapTo(targetValue = offsetX.value + dragAmount.x)
                                  offsetY.snapTo(targetValue = offsetY.value + dragAmount.y)
                              }
                              spring(stiffness = Spring.StiffnessHigh, visibilityThreshold = 0.1.dp)
                          },
                          onDragEnd = {
                              enabledDragging.value = !enabledDragging.value
                              if (offsetX.value in lockCoordinatedMarginLow.x..lockCoordinatedMarginHigh.x &amp;&amp; offsetY.value in lockCoordinatedMarginLow.y..lockCoordinatedMarginHigh.y) {
                                  atLockPosition.value = true
                                  coroutineScope.launch {
                                      launch {
                                          offsetY.animateTo(
                                              targetValue = lockCoordinated.y + ((placementDimensionsHeightInPx - cardInitHeightInPx) / 2),
                                              animationSpec = tween(
                                                  durationMillis = 500,
                                                  delayMillis = 50,
                                                  easing = LinearOutSlowInEasing
                                              )
                                          )
                                      }
                                      offsetX.animateTo(
                                          targetValue = lockCoordinated.x + ((placementDimensionsWidthInPx - cardInitWidthInPx) / 2),
                                          animationSpec = tween(
                                              durationMillis = 500,
                                              delayMillis = 50,
                                              easing = LinearOutSlowInEasing
                                          )
                                      )
                                  }
                              } else {
                                  atLockPosition.value = false
                                  coroutineScope.launch {
                                      launch {
                                          offsetY.animateTo(
                                              targetValue = initCoordinated.y,
                                              animationSpec = tween(
                                                  durationMillis = 700,
                                                  delayMillis = 50,
                                                  easing = LinearOutSlowInEasing
                                              )
                                          )
                                      }
                                      offsetX.animateTo(
                                          targetValue = initCoordinated.x,
                                          animationSpec = tween(
                                              durationMillis = 700,
                                              delayMillis = 50,
                                              easing = LinearOutSlowInEasing
                                          )
                                      )
                                  }
                              }
                              spring(stiffness = Spring.StiffnessLow, visibilityThreshold = 0.1.dp)
                          }
                      )
                  }
                  .then(clickable)
          )
      }
  }
  </code></pre>
  <p>I have another composable to represent a hand of playing cards, this one is the tricky one because as far as I want to it behave, is, once you pull out a card out of the hand, it size should shrink automatically (and it doesn't do it currently, see the GIF I attached):</p>
  <pre><code>@Composable
  fun CardHand(
      cardDimensions: DataSize = DataSize(),
      placementDimentions: DataSize = DataSize(),
      lockCoordinated: DataCoordinates = DataCoordinates(),
      numberOfCards: Int
  ) {
      val context = LocalContext.current
      val displayMetrics = context.getResources().getDisplayMetrics()
      val dmWidthInPx = displayMetrics.widthPixels
      val cardDimensionsInPx = with(LocalDensity.current) { (cardDimensions.width.dp.toPx()) }
  
      val singleCardOffset = 100
      val cardCounter by remember { mutableStateOf(numberOfCards) }
  
      repeat(cardCounter) {
          val dataCoordinates = DataCoordinates(x = (dmWidthInPx - ((cardDimensionsInPx) + ((cardCounter - 1) * singleCardOffset))) / 2 , y = 0f)
          CardBox(
              title = &quot;Box_$cardCounter&quot;,
              initCoordinated = DataCoordinates(x = dataCoordinates.x + (it * singleCardOffset), y = 50f),
              boxDimensions = cardDimensions,
              placementDimensions = placementDimentions,
              lockCoordinated = lockCoordinated,
              z = cardCounter.toFloat(),
              content = {}
          )
      }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/61eDB.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/61eDB.gif" alt="current operation" /></a></p>
  <p>So basically, I see my issue as passing the state of the snapped card onto the hand composable so that I'll be able to recomposite how it looks, and that's where I struggle.</p>