Uploading images in Kotlin Multiplatform

Robert Nagy
3 min readApr 12, 2021

I’ve been working on sharing logic between Android and iOS and I’d like to share my experience with working with images in a platform agnostic way.

Introduction

Kotlin Multiplatform lets you share non platform specific logic ( “non UI code”) between different platforms (Android, jvm, js, iOS, macOS, etc…) and gives you the possibility of creating abstractions over platform specific logic.
I won’t dive into more detail about the technology, you can read more about it here.

Context

The feature was about uploading an application, with an icon and screenshots. Check out the final versions:

Android, iOS, macOS (left to right)

Additionally my goal was to test out Kotlin Multiplatform with the following technical decisions:

  • A shared ViewModel layer
  • Unidirectional data flow

Practically this means, that all the icons, screenshots you see above will be part of the state stored in a shared ViewModel, with the following events:

  1. All platforms submit their platform specific representation of the selected image
  2. The ViewModel works with these images in a platform agnostic way
  3. All platforms receive back the platform specific…

--

--

Robert Nagy
Robert Nagy

Written by Robert Nagy

Senior Android Developer — Contractor — Freelancer

Responses (1)