Hello, is `@PreviewParameter` supposed to be worki...
# compose
a
Hello, is
@PreviewParameter
supposed to be working in
commonMain
in Android Studio? It generates a single preview instead of one for each value from my provider. For example, if I use:
Copy code
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.jetbrains.compose.ui.tooling.preview.PreviewParameter
import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider

@Preview
@Composable
private fun MyComposablePreview(
    @PreviewParameter(ThemePreviewParameterProvider::class) theme: Boolean
) {
    MyTheme(darkTheme = theme) {
        MyComposable()
    }
}

class ThemePreviewParameterProvider : PreviewParameterProvider<Boolean> {
    override val values = sequenceOf(true, false)
}
It only generates a single preview with
theme
set to
false
(whatever the order of the values). I'm wondering if that's the expected behavior or if I missed something in the configuration?
t
Did you tested with Android Studio Narwhal?
a
Yes, I tested in both Narwharl and Narwhal Feature Drop canaries.
t
Ok i am also missing all the parameters where you can simulate different device configurations. So i developed my own plugin to show previews. If you want you can have a look. But it is just developed by me: https://github.com/timo-drick/Multiplatform-Preview
a
Oh that's interesting, I'll have a look, thanks. Though I'd also be nice if the @PreviewParameter was working as expected in common code with the default setup.
t
I implemented this as well. But i renamed the annotation to avoid problems: @HotPreviewParameter. It is documented on the github project. https://github.com/timo-drick/Multiplatform-Preview?tab=readme-ov-file#using-hotpreviewparameterprovider