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 {
|
} else {
|
||||||
null
|
null
|
||||||
},
|
},
|
||||||
|
rankLabel =
|
||||||
|
if (showCoordinates && file == 0) {
|
||||||
|
(rank + 1).toString()
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,6 +101,7 @@ private fun ChessSquare(
|
|||||||
isLight: Boolean,
|
isLight: Boolean,
|
||||||
size: Dp,
|
size: Dp,
|
||||||
coordinate: String?,
|
coordinate: String?,
|
||||||
|
rankLabel: String? = null,
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier =
|
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
|
// Show file coordinate (a-h) on bottom rank
|
||||||
coordinate?.let {
|
coordinate?.let {
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
+17
@@ -117,6 +117,7 @@ fun InteractiveChessBoard(
|
|||||||
val isLegalMove = legalMoves.contains(square)
|
val isLegalMove = legalMoves.contains(square)
|
||||||
|
|
||||||
val showCoord = if (flipped) rank == 7 else rank == 0
|
val showCoord = if (flipped) rank == 7 else rank == 0
|
||||||
|
val showRankLabel = if (flipped) file == 7 else file == 0
|
||||||
|
|
||||||
InteractiveChessSquare(
|
InteractiveChessSquare(
|
||||||
piece = piece,
|
piece = piece,
|
||||||
@@ -125,6 +126,7 @@ fun InteractiveChessBoard(
|
|||||||
isSelected = isSelected,
|
isSelected = isSelected,
|
||||||
isLegalMove = isLegalMove,
|
isLegalMove = isLegalMove,
|
||||||
showCoordinate = showCoord,
|
showCoordinate = showCoord,
|
||||||
|
showRankLabel = showRankLabel,
|
||||||
file = file,
|
file = file,
|
||||||
rank = rank,
|
rank = rank,
|
||||||
onClick = {
|
onClick = {
|
||||||
@@ -231,6 +233,7 @@ private fun InteractiveChessSquare(
|
|||||||
isSelected: Boolean,
|
isSelected: Boolean,
|
||||||
isLegalMove: Boolean,
|
isLegalMove: Boolean,
|
||||||
showCoordinate: Boolean,
|
showCoordinate: Boolean,
|
||||||
|
showRankLabel: Boolean,
|
||||||
file: Int,
|
file: Int,
|
||||||
rank: Int,
|
rank: Int,
|
||||||
onClick: () -> Unit,
|
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
|
// Show file coordinate (a-h) on bottom rank
|
||||||
if (showCoordinate) {
|
if (showCoordinate) {
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
Reference in New Issue
Block a user