icerockdev / moko-permissions

Runtime permissions controls for mobile (android & ios) Kotlin Multiplatform development

Home Page:https://moko.icerock.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to preview Composable with BindEffect?

timurgilfanov opened this issue · comments

@Preview @Composable fun MainScreenPreview() { BindEffect(permissionsController) }

When run preview task for Android exception has been thrown:
java.lang.ClassCastException: androidx.compose.ui.tooling.PreviewActivity cannot be cast to androidx.fragment.app.FragmentActivity at dev.icerock.moko.permissions.compose.BindEffect_androidKt$BindEffect$1.invokeSuspend(BindEffect.android.kt:24)

Reason of exception is cast context to FragmentActivity in BindEffect.

I don't know is there the way to use FragmentActivity to preview Composable. Now my solution is to add parameter to skip binding. It's bad for code readability. May be someone propose better solution?