Skip to content

Transpile Compose @Previews from SwiftUI #Preview #588

@dfabulich

Description

@dfabulich

It's convenient to see @Previews in Android Studio. As it stands, I have to write a lot of complicated boilerplate for this:

#if SKIP
@Preview(showBackground = true)
@Composable
fun WelcomeViewPreview() {
    ProcessInfo.launch(LocalContext.current)
    Surface(
        modifier = Modifier.fillMaxSize(),
        color = MaterialTheme.colorScheme.background
    ) {
        WelcomeView(welcomeName = Binding.constant("Skipper"))
            .Compose(context = ComposeContext())
    }
}
#else
#Preview {
    WelcomeView(welcomeName: Binding.constant("Skipper"))
}
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions