Skip to content

Instantly share code, notes, and snippets.

@realityexpander
Last active October 17, 2022 22:55
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/de4e0f0368a265e32eb26e3f7bc2cfed to your computer and use it in GitHub Desktop.
Save realityexpander/de4e0f0368a265e32eb26e3f7bc2cfed to your computer and use it in GitHub Desktop.
for KMM @TypeParceler article
// ../shared/commonMain/…/domain/note/Note.kt
import kotlinx.datetime.LocalDateTime
@CommonParcelize // this annotation will be ignored by iOS
data class Note(
val id: Long?,
val title: String,
val content: String,
val colorHex: Long,
@CommonTypeParceler<LocalDateTime, LocalDateTimeParceler>() // this annotation will be ignored by iOS
val created: LocalDateTime,
): CommonParcelable { // The interface will be ignored by iOS
companion object {
private val colors = listOf(RedOrangeHex, RedPinkHex, LightGreenHex, BabyBlueHex, VioletHex)
fun generateRandomColor() = colors.random()
}
}
@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