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
@Stable | |
class UndoManager(private val stickers: () -> List<Sticker>) { | |
private val undoHistory = mutableStateListOf<BoardAction>() | |
private val redoHistory = mutableStateListOf<BoardAction>() | |
fun register(action: BoardAction) { | |
val invertedAction = action.invert(oldSticker = ???) | |
undoHistory.add(invertedAction) | |
redoHistory.clear() |
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 |
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
@Stable | |
sealed interface StickerType { | |
@Stable | |
class Shape( | |
shape: androidx.compose.ui.graphics.Shape, | |
color: Color, | |
borderWidth: Dp, | |
borderColor: Color | |
) : StickerType { | |
var shape by mutableStateOf(shape) |
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
@Composable | |
fun StickerBoard( | |
stickers: List<Sticker>, | |
modifier: Modifier = Modifier | |
) { | |
Box(modifier.fillMaxWidth().background(Color.White).clipToBounds()) { | |
stickers.forEach { sticker -> | |
key(sticker.id) { | |
Sticker(sticker) | |
} |
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
@Stable | |
class Sticker( | |
type: StickerType, | |
width: Dp, | |
height: Dp, | |
offset: Offset, | |
zIndex: Int, | |
rotation: Float, | |
scaleX: Float, | |
scaleY: Float |
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 | |
class Sticker( | |
val type: StickerType, | |
val width: Dp, | |
val height: Dp, | |
val offset: Offset, | |
val zIndex: Int, | |
val rotation: Float, | |
val scaleX: Float, | |
val scaleY: Float, |
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
import com.dequeue.app.common.log | |
import com.dequeue.app.common.logging.D | |
import io.ktor.client.* | |
import io.ktor.client.plugins.* | |
import io.ktor.client.plugins.contentnegotiation.* | |
import io.ktor.client.plugins.logging.* | |
import io.ktor.client.plugins.resources.* | |
import io.ktor.serialization.kotlinx.json.* | |
fun ktorHttpClient(baseUrl: String): HttpClient = ktorClient { |
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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
plugins { | |
id "org.jetbrains.intellij" version "0.7.3" | |
id "org.jetbrains.kotlin.jvm" | |
} | |
repositories { | |
mavenCentral() | |
maven { |
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
val password = Password.of("Some34Really434Hard21Password!").orThrow() //Throw on violation just for demonstration | |
val haha = password.copy(value = "gotcha") //Unresolved reference: copy |
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
@NoCopy | |
data class Password private constructor(val value: String) { | |
companion object { | |
fun of(value: String): Either<List<Violation>, Password> { | |
val violations = buildList { | |
if (value.isTooShort()) { add(Violation.PasswordTooShort(MIN_LENGTH)) } | |
if (value.containsNoNumbers()) { add(Violation.PasswordContainsNoNumbers) } | |
} | |
return if (violations.isEmpty()) Password(value).right() else violations.left() | |
} |
NewerOlder