Created
October 14, 2022 23:42
-
-
Save realityexpander/8dd599a31dc88f52a56eb126bf8fe196 to your computer and use it in GitHub Desktop.
for KMM @TypeParceler Article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See my sample project here: https://github.com/realityexpander/NoteAppKMM