diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/ChessBoard.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/ChessBoard.kt index dc0cec5bb7..66191aff2e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/ChessBoard.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/ChessBoard.kt @@ -79,6 +79,12 @@ fun ChessBoard( } else { null }, + rankLabel = + if (showCoordinates && file == 0) { + (rank + 1).toString() + } else { + null + }, ) } } @@ -95,6 +101,7 @@ private fun ChessSquare( isLight: Boolean, size: Dp, coordinate: String?, + rankLabel: String? = null, ) { Box( modifier = @@ -114,6 +121,20 @@ private fun ChessSquare( ) } + // Show rank label (1-8) on left file + rankLabel?.let { + Text( + text = it, + fontSize = 10.sp, + fontWeight = FontWeight.Bold, + color = if (isLight) Color(0xFFB58863) else Color(0xFFF0D9B5), + modifier = + Modifier + .align(Alignment.TopStart) + .padding(2.dp), + ) + } + // Show file coordinate (a-h) on bottom rank coordinate?.let { Text( diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/InteractiveChessBoard.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/InteractiveChessBoard.kt index c91613b26e..d103bb747f 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/InteractiveChessBoard.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/chess/InteractiveChessBoard.kt @@ -117,6 +117,7 @@ fun InteractiveChessBoard( val isLegalMove = legalMoves.contains(square) val showCoord = if (flipped) rank == 7 else rank == 0 + val showRankLabel = if (flipped) file == 7 else file == 0 InteractiveChessSquare( piece = piece, @@ -125,6 +126,7 @@ fun InteractiveChessBoard( isSelected = isSelected, isLegalMove = isLegalMove, showCoordinate = showCoord, + showRankLabel = showRankLabel, file = file, rank = rank, onClick = { @@ -231,6 +233,7 @@ private fun InteractiveChessSquare( isSelected: Boolean, isLegalMove: Boolean, showCoordinate: Boolean, + showRankLabel: Boolean, file: Int, rank: Int, onClick: () -> Unit, @@ -286,6 +289,20 @@ private fun InteractiveChessSquare( ) } + // Show rank label (1-8) on left file + if (showRankLabel) { + Text( + text = (rank + 1).toString(), + fontSize = 10.sp, + fontWeight = FontWeight.Bold, + color = if (isLight) Color(0xFFB58863) else Color(0xFFF0D9B5), + modifier = + Modifier + .align(Alignment.TopStart) + .padding(2.dp), + ) + } + // Show file coordinate (a-h) on bottom rank if (showCoordinate) { Text(