I want to implement "Swipe to show buttons" feature to my card as the following:
-- Box
-- Card
-- Row(here I put the buttons which showing when swipe the card)
Now the card and row are visible next to each other so I want to offset the row to be invisible in the normal look and return it to 0 offsets(visible) when the user swipes the card.
when observing user's swipe on the card I do the following:
• Change the card's offset based on the
Row's width to the left via
animateFloat
like this:
val offsetTransitionCard by transition.animateFloat(
targetValueByState = { if (isRevealed) -rowWidth else 0f },
)
• Change the row's offset to 0 via
animateFloat
like this:
val offsetTransitionRow by transitionActions.animateFloat(
targetValueByState = { if (isRevealed) 0f else rowWidth },
)
till now all good but we have one problem, when
initial composition occurred the
rowWidth
will be 0 because it's not calculated yet which means the Row offset will be 0 too which means again the Row will be showing for mills then will offset when the
rowWidth
gets ready.
So I want a way to make the row's default offset to be like 500 instead of 0 on the
initial compose only.