-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Jetpack Compose preview option #92
Comments
Hello, I prefer to separate navDestination logic and pure Compose UI. It allows to use Preview without any restrictions. Please take a look some example: |
@BioRyajenka
|
Yeah, I did it this way, but with complex logic/structure you also probably don't want to pass lambdas multiple levels down in many places. So I ended up with a mix: extracted a function + passing demo data for the preview purposes, but also created custom dummy navController with reflection and pass it down instead of lambdas. |
We will add some options to perview a screen... Proposed syntax: val SomeScreen by navDestination<Input>{...}
@Preview
@Composable
fun SomeScreenPreview(){
ScreenPreview(SomeScreen, args=Input(), freeArgs = Smth, navResult = Smth)
} |
Hey @vkatz , thanks for reply! |
Taskt to do so already created, this conversation marked as |
@BioRyajenka |
Whats the best way to preview components if you use tiamat?
Since the lib encourage users to create a components like that:
I tried to preview a component with the following code:
But it fails with
java.lang.ClassCastException: class com.android.layoutlib.bridge.android.BridgeContext cannot be cast to class android.content.ContextWrapper (com.android.layoutlib.bridge.android.BridgeContext and android.content.ContextWrapper are in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @7d9d7378) at com.composegears.tiamat.RootDataStorageKt.rememberRootDataStore(RootDataStorage.kt:31) at com.composegears.tiamat.Platform_androidKt.rootNavControllersStore(Platform.android.kt:12)
...
The text was updated successfully, but these errors were encountered: