You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rememberSaveable is used to retain the progress of the MotionLayout and state restoration happens, customColor and every other custom* method of the MotionLayoutScope always returns the initial value (progress == 0f).
I've created a small sample to reproduce this issue by modifying the CollapsingToolbar example.
Collapse the toolbar so that the progress becomes 1f. Notice that the background color of the image is set to blue because of the customColor("cover", Color.Blue) property set on the end1 state.
Exit the app.
Create a condition where a process is killed. I usually achieve that by enabling the "Don't keep activities" in the developer settings.
Enter the app again.
Since we have used rememberSaveable for the toolbar height, the progress is retained and set to 1f. So far, so good. However, notice that the background color of the image is now transparent instead of blue. The following code val customColor = customColor("image", "cover") returns Color.Transparent instead of Color.Blue on state restoration & progress == 1f, which is incorrect and is the core of the bug.
At 03:27:31.827 is the correct log, where for given progress = 1.0, we get the blue color. However, after state restoration at 03:28:06.071 , for given progress = 1.0, we get transparent color instead of blue.
I've also shot a video for easier understanding what is going on:
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: