This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
MotionLayout's custom properties return invalid values on state restoration #862
Labels
bug
Something isn't working
When
rememberSaveable
is used to retain the progress of theMotionLayout
and state restoration happens,customColor
and every othercustom*
method of theMotionLayoutScope
always returns the initial value (progress == 0f
).I've created a small sample to reproduce this issue by modifying the CollapsingToolbar example.
To reproduce:
progress
becomes1f
. Notice that the background color of the image is set to blue because of thecustomColor("cover", Color.Blue)
property set on theend1
state.rememberSaveable
for the toolbar height, the progress is retained and set to1f
. So far, so good. However, notice that the background color of the image is now transparent instead of blue. The following codeval customColor = customColor("image", "cover")
returnsColor.Transparent
instead ofColor.Blue
on state restoration &progress == 1f
, which is incorrect and is the core of the bug.The logging code also confirms this:
produces the following:
At
03:27:31.827
is the correct log, where for givenprogress = 1.0
, we get the blue color. However, after state restoration at03:28:06.071
, for givenprogress = 1.0
, we get transparent color instead of blue.I've also shot a video for easier understanding what is going on:
bug_demo.mp4
Version:
androidx.constraintlayout:constraintlayout-compose:1.1.0-rc01
The text was updated successfully, but these errors were encountered: