Skip to content

Instantly share code, notes, and snippets.

@realityexpander
Created October 14, 2022 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realityexpander/8dd599a31dc88f52a56eb126bf8fe196 to your computer and use it in GitHub Desktop.
Save realityexpander/8dd599a31dc88f52a56eb126bf8fe196 to your computer and use it in GitHub Desktop.
for KMM @TypeParceler Article
// commonMain/…/Platform.kt
import kotlinx.datetime.LocalDateTime
// For Android @Parcelize
@OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
expect annotation class CommonParcelize()
// For Android Parcelable
expect interface CommonParcelable
// For Android @TypeParceler
@OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation
@Retention(AnnotationRetention.SOURCE)
@Repeatable
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY)
expect annotation class CommonTypeParceler<T, P : CommonParceler<in T>>()
// For Android Parceler
expect interface CommonParceler<T>
// For Android @TypeParceler to convert LocalDateTime to Parcel
expect object LocalDateTimeParceler: CommonParceler<LocalDateTime>
@realityexpander
Copy link
Author

See my sample project here: https://github.com/realityexpander/NoteAppKMM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment