workflow-kotlin
workflow-kotlin copied to clipboard
Compose Multiplatform Support
Overview
This pull request add Kotlin Multiplatform (KMP) support for the workflow-ui:compose module. Some of the most notable changes are the build.gradle.kts configurations and changing/adding targets e.g. androidMain vs main
Note that this PR also uses a commit from @MilanJovic92 #1185. The bulk of this PR is simply copying that module over. The changes I made will cut the PR size in half.
All of the iOS target UI tests pass. Tests that contained Android code (View and Dialog) were removed for iOS but retained for Android.
The Compose samples have also been update to support iOS. Due to some limitations, the samples that use the Preview aren't shown as well any that used Android specific code. All of the Android code works the same as before.
While not tested, this should also work for Desktop and JS 🎉
Considerations
- Compose Multiplatform release cycles are different than Jetpack Compose Android so we may just want to make a new package in
:workflow-ui:compose-multiplatform
The gap between a Compose Multiplatform release and a Jetpack Compose release is usually 1–3 months.
From here
- Support for multiplatform besides Android is probably going to have to be community maintained since it's not in use at Square
- The minimal Kotlin version needed for this to work is
1.9.24which is higher than what we had before. This is due to needing Jetbrains version of lifecycle which just recently released in May 2024.
EDIT: It looks like the above may not be true after getting this message from the KMP team here https://github.com/JetBrains/compose-multiplatform/issues/5047#issuecomment-2199388204
Todo
- There's not native back handling so it needs to be done manually. I have a sample implementation in the compose-samples for how to do this for multiplatform.
- The iOS dialog equivalent is not supported, this is pure Kotlin Multiplatform code
- The snapshot saving functions are only available in Android
- There could be a lot more work on the gradle plugins which is why you see my apply stuff from the toml
- The
compose-ui-toolingpackage needs to be updated for KMP support but can be done pretty trivially - The publish plugins are commented out because I don't know how to do that and it made my syncs fail whenever I changed anything
- I added https://github.com/autonomousapps/dependency-analysis-gradle-plugin for doing project health but this will be removed if this project ever goes anywhere.
Here is a demo of the compose-samples working
https://github.com/square/workflow-kotlin/assets/9651986/c7c98176-3164-4000-8d30-6d44c5b4f724
Notes
Some UI tests are failing due to an issue with LeakCanary and Google. See here. The issue is fixed with Lifecycle 2.8.2 but Jetbrains hasn't updated their version of Lifecycle to match it.