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
fun State.next(): State = | |
when (this) { | |
is Queued -> if (queueNumber == 0) Bottom else Queued(queueNumber - 1) | |
is Bottom -> Top | |
else -> this | |
} |
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
sealed class State { | |
// Prepared but not displayed yet | |
data class Queued(val queueNumber: Int) : State() | |
// Visible below top card | |
object Bottom : State() | |
// The main card | |
object Top : State() | |
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
import androidx.compose.ui.graphics.Color | |
// reds | |
val md_red_50 = Color(0xFFFFEBEE) | |
val md_red_100 = Color(0xFFFFCDD2) | |
val md_red_200 = Color(0xFFEF9A9A) | |
val md_red_300 = Color(0xFFE57373) | |
val md_red_400 = Color(0xFFEF5350) | |
val md_red_500 = Color(0xFFF44336) | |
val md_red_600 = Color(0xFFE53935) |
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
@Composable | |
fun Game() { | |
Column { | |
Moves() | |
CapturedPieces(WHITE) | |
Board() | |
CapturedPieces(BLACK) | |
Controls() | |
} | |
} |
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
val datapoint = remember(viz, properties) { | |
viz.dataPointAt( | |
properties.position, | |
properties.boardProperties.toState | |
) | |
} |
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
@Composable | |
override fun render(properties: SquareRenderProperties) { | |
ActiveDatasetVisualisation.current.let { viz -> | |
val datapoint = viz.dataPointAt( | |
properties.position, | |
properties.boardProperties.toState | |
) | |
//... | |
} |
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
@Composable | |
fun Board( | |
fromState: GameSnapshotState, | |
toState: GameSnapshotState, | |
uiState: UiState, | |
isFlipped: Boolean = false, | |
onClick: (Position) -> Unit, | |
) { | |
BoxWithConstraints( | |
modifier = Modifier |
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
object DefaultSquareRenderer : SquareRenderer { | |
override val decorations: List<SquareDecoration> = | |
listOf( | |
DefaultSquareBackground, | |
DefaultHighlightSquare, | |
DefaultSquarePositionLabel, | |
DatasetVisualiser, | |
TargetMarks | |
) |
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
interface SquareRenderer { | |
val decorations: List<SquareDecoration> | |
} | |
interface BoardRenderer { | |
val decorations: List<BoardDecoration> | |
} |
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
interface SquareDecoration { | |
@Composable | |
fun render(properties: SquareRenderProperties) | |
} | |
interface BoardDecoration { | |
@Composable | |
fun render(properties: BoardRenderProperties) |