Kotlin Multiplatform support #1206
Unanswered
blakelee
asked this question in
Show and tell
Replies: 2 comments
-
|
Here's a sample project with it running https://github.com/blakelee/WorkflowMultiplatform |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
cool |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was messing around with workflow to see if I could get it working for a KMP project and I managed to get it working for Compose Multiplatform. I was trying to manage state for a personal app I'm making and after seeing the existing solutions recommended on jetbrains' website, I decided it was worth a shot to see if I could make it myself. Here is a simple hello world showing it working
How did I do it?
workflow-coreandworkflow-runtimealready supported KMP.workflow-ui/composemodule so I imported all of those classes except forViewEnvironmentWithComposeSupport.ktand removed the functions related toViewFactoryinScreenComposableFactory.ktwhich left me with POKO's and nothing Android related.LocalLifecycleOwnerinWorkflowRendering.ktbut I needed a KMP solution. There was also this recent change which caused some friction.LocalLifecycleOwnerwas moved toandroidx.lifecycle:lifecycle-runtime-composewhich doesn't have KMP binaries. Luckily for us Jetbrains just released their own version for KMP here which is available in the Compose plugin 1.6.10.compose.uiin the compose plugin as well asorg.jetbrains.androidx.lifecycle:lifecycle-runtime-compose, I could editWorkflowRendering.ktto support our KMP lifecycle. Simply importandroidx.lifecycle.compose.LocalLifecycleOwnerthen modify the functionrememberChildLifecycleOwnerwhere theparentLifecyclewill now beandroidx.compose.ui.platform.LocalLifecycleOwner.current.lifecycleI faced a lot of dependency issues trying to figure this out. So as of right now I could only get it working on Android and iOS with Kotlin 2.0.0, Compose-plugin 1.6.10 and Lifecycle-runtime-compose 2.8.0.
If we wanted to make these changes public, we'd have to take the Android code out of
workflow-ui/composeand possibly make another module for the Android View factories.Beta Was this translation helpful? Give feedback.
All reactions