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
Currently I want to implement custom theme switching. When I click a button I want to generate bitmap of original screen and basically show it instantly on top of everything. During the next frame the theme switches and I would like to capture second bitmap there.
But can I do that in the same onClick callback?
I tried with rememberCoroutineScope but capture method is documented like below and I don't think it's correct thing to do so?
Make sure to call this method as a part of callback function and not as a part of the Composable function itself.
If I do like this:
scope.launch {
captureController.capture()
themeViewModel.setDarkThemeEnabled(!darkThemeEnabled)
// Wait until the next frame to capture the image after the theme change.
delay(50)
captureController.capture()
}
I see that I capture both light mode and dark mode bitmaps, but I get recomposition problem where my texts do not switch to the correct color.
That can be seen in the below image where I switched from dark to light mode and texts show correctly in bitmap images but not in the light mode.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently I want to implement custom theme switching. When I click a button I want to generate bitmap of original screen and basically show it instantly on top of everything. During the next frame the theme switches and I would like to capture second bitmap there.
But can I do that in the same onClick callback?
I tried with
rememberCoroutineScope
but capture method is documented like below and I don't think it's correct thing to do so?If I do like this:
I see that I capture both light mode and dark mode bitmaps, but I get recomposition problem where my texts do not switch to the correct color.
That can be seen in the below image where I switched from dark to light mode and texts show correctly in bitmap images but not in the light mode.
Beta Was this translation helpful? Give feedback.
All reactions