Skip to content

Instantly share code, notes, and snippets.

@AhmedMourad0
Created March 1, 2024 17:14
Show Gist options
  • Save AhmedMourad0/ca1b4ffbfb036b191db0f76aa279c5c3 to your computer and use it in GitHub Desktop.
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.
@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