Hey there kotlin community! I’m working on a iOS/Android kotlin multiplatform small project where I want to display an image fetched from the network. I’m new to multiplatform but I know Android and Kotlin well enough.
I have one concrete question:
With the current available libraries, is most of the code for such a use case going to be shared or will I need to build the image views and the fetching in kotlin and in swift, only sharing the HTTP fetch code?
03/20/2020, 2:30 PM
what do you wish to do with the images, treating or manipulate it? or just show in the ui of your App (transforming it or not)?
03/20/2020, 3:03 PM
Thanks for your answer.
I’m trying to keep it as simple as possible, so just to display it would be the first step.
The more I can share, the better, but I’m not sure how much code I can share, for example:
• Getting the image from an URL
• Passing the image to an android and iOS view
03/20/2020, 3:06 PM
if your goal is only to get and show the images on your Apps's UI, I recommend you do it on each platform (not shared).
I follow the principle to keep the UI code separeted for the business logic (that can be shared)
the UI code I keep to the each platform to deal with
03/20/2020, 3:13 PM
I see… Yes that’s also what I am seeing in the examples I’ve taken a look at.
I think each view (ios/android) can get the image in a callback and put in into the view. What format or object type can I pass to the view (Drawable is android-specific)?
03/20/2020, 3:14 PM
I simply don't delegate the image loading to the Kotlin Multiplatform module
this code is handle by each platform, on Android I use Glide to do it, in iOS I do it with another library (in Swift)