Created
March 1, 2024 17:14
-
-
Save AhmedMourad0/ca1b4ffbfb036b191db0f76aa279c5c3 to your computer and use it in GitHub Desktop.
Code snippet for the `Leveraging the Power of Snapshots in Jetpack Compose` Medium article.
This file contains 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
@Immutable | |
sealed interface BoardAction { | |
@Immutable | |
data class Add(val sticker: Sticker) : BoardAction | |
@Immutable | |
data class Remove(val id: String) : BoardAction | |
@Immutable | |
data class Transform( | |
override val id: String, | |
val offset: Offset, | |
val zIndex: Int, | |
val scaleX: Float, | |
val scaleY: Float, | |
val rotationZ: Float | |
) : BoardAction { | |
constructor(sticker: Sticker) : this( | |
id = sticker.id, | |
offset = sticker.offset, | |
zIndex = sticker.zIndex, | |
scaleX = sticker.scaleX, | |
scaleY = sticker.scaleY, | |
rotationZ = sticker.rotationZ | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment