component-parcelize

Kotlin Multiplatform support for using android.os.Parcelable from common code

APACHE-2.0 License

Stars
2
Committers
1

component-parcelize

Kotlin Multiplatform support for using android.os.Parcelable from common code.

A full list of kotlin-components projects can be found HERE

Get Started

  • Add dependency to commonMain

    // build.gradle.kts
    dependencies {
        val vParcelize = "0.1.2"
        // If usage is a part of your public api, use `api`; otherwise
        // use `implementation` for internal-only usage.
        api("io.matthewnelson.kotlin-components:parcelize:$vParcelize")
    }
    
    // build.gradle
    dependencies {
        def vParcelize = "0.1.1"
        // If usage is a part of your public api, use `api`; otherwise
        // use `implementation` for internal-only usage.
        api "io.matthewnelson.kotlin-components:parcelize:$vParcelize"
    }
    
  • Add the kotlin-parcelize plugin to your project

    plugins {
        id("kotlin-parcelize")
    }
    

Usage

  • In commonMain

    import io.matthewnelson.component.parcelize.Parcelable
    import io.matthewnelson.component.parcelize.Parcelize
    
    @Parcelize
    data class MyData(val value: String): Parcelable
    
  • Usable from androidMain

    // androidMain
    val intent = Intent()
    intent.putExtra("MY_DATA", MyData("Parcelable commonMain class"))
    
    val myData = intent.getParcelableExtra<MyData>("MY_DATA")
    println(myData.toString())
    
  • See the sample-data and sample-app examples

Kotlin Version Compatibility

parcelize kotlin
0.1.2 1.8.0
0.1.1 1.7.20
0.1.0 1.6.21

Git

This project utilizes git submodules. You will need to initialize them when cloning the repository via:

$ git clone --recursive https://github.com/05nelsonm/component-parcelize.git

If you've already cloned the repository, run:

$ git checkout master
$ git pull
$ git submodule update --init

In order to keep submodules updated when pulling the latest code, run:

$ git pull --recurse-submodules
Package Rankings
Top 31.99% on Repo1.maven.org
Badges
Extracted from project README's
badge-license badge-latest-release badge-kotlin
Related Projects