https://kotlinlang.org logo
s

Shivam Kanodia

06/02/2023, 10:12 AM
Hi
Urgent Help!!,
I am reading image from gallery in IOS in KMM , its returning image as UI Image , now i am unable to show it on UI in compose as we cant pass UIImage in compose, also i am not getting required methods to convert it to bitmap on ios kmm.
j

Joel Denke

06/02/2023, 11:19 AM
Check this KMM sample: https://github.com/JetBrains/compose-multiplatform/tree/master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer You can convert with ByteArray, and then converting to ImageBitmap in Compose in both directions 🙂
s

Shivam Kanodia

06/02/2023, 11:53 AM
@Joel Denke Thank you so much! 😄
j

Joel Denke

06/02/2023, 11:58 AM
No problem 🙂 Also if needed you can write code with UIKit and wrap with UIKitView wrapper back to compose, rendering iOS components/Swift code inside Compose. Not sure how much it supports interop in both directions, iOS compose still alpha, so a lot of new stuff and I am myself still learning. My feeling is the easiest is to write as much as possible with compose/KMM and avoid using native iOS/Android/web etc. In theory all can be done, just more limitation of libraries available, so need sometimes fill with your own expect/actual layers.
For files ByteArray seems to be the best way of being agnostic, and then doing extensions in Kotlin to convert between each platform if not exists library doing it for you. Makes it easier sharing between web, iOS, Android and desktop apps. Getting trickier for datetime, native specific stuff requires KeyChain or Android keystore and such 😄
5 Views