feat(chess): add rank numbers (1-8) to board coordinates
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
+17
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user