feat: replace hex pubkeys with user picture + name in chess cards

In chess note cards (NoteCompose), player hex keys were displayed as
raw strings. Now uses LoadUser + ClickableUserPicture + UsernameDisplay
to show proper profile pictures and display names for:
- Challenge cards (incoming/outgoing)
- Game end cards (both players)
- PGN metadata in game viewers (white/black players)

Added playerContent composable slot to PGNMetadata and ChessGameViewer
so callers can inject platform-specific user rendering.

https://claude.ai/code/session_0171mKrVEfQnNRabmT7Kv4gf
This commit is contained in:
Claude
2026-04-08 20:53:56 +00:00
parent b2a9215788
commit b861a71c2c
3 changed files with 161 additions and 35 deletions
@@ -51,11 +51,14 @@ import com.vitorpamplona.quartz.nip64Chess.PGNParser
*
* @param pgnContent PGN format string
* @param modifier Modifier for the viewer
* @param playerContent Optional composable to render player names with avatar + display name.
* When provided, PGN player names (which may be hex pubkeys) are rendered using this composable.
*/
@Composable
fun ChessGameViewer(
pgnContent: String,
modifier: Modifier = Modifier,
playerContent: (@Composable (String) -> Unit)? = null,
) {
val gameResult =
remember(pgnContent) {
@@ -64,7 +67,7 @@ fun ChessGameViewer(
gameResult.fold(
onSuccess = { game ->
ChessGameDisplay(game, modifier)
ChessGameDisplay(game, modifier, playerContent)
},
onFailure = { error ->
ChessGameError(
@@ -83,6 +86,7 @@ fun ChessGameViewer(
private fun ChessGameDisplay(
game: com.vitorpamplona.quartz.nip64Chess.ChessGame,
modifier: Modifier = Modifier,
playerContent: (@Composable (String) -> Unit)? = null,
) {
var currentMoveIndex by remember { mutableStateOf(0) }
@@ -96,7 +100,7 @@ private fun ChessGameDisplay(
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
// Game metadata header
PGNMetadata(game = game)
PGNMetadata(game = game, playerContent = playerContent)
// Chess board
ChessBoard(
@@ -39,11 +39,15 @@ import com.vitorpamplona.quartz.nip64Chess.ChessGame
*
* @param game The chess game with metadata to display
* @param modifier Modifier for the metadata display
* @param playerContent Optional composable to render player names (e.g. with avatar + display name).
* Receives the raw player name string from PGN (which may be a hex pubkey in Nostr context).
* When null, falls back to plain text display.
*/
@Composable
fun PGNMetadata(
game: ChessGame,
modifier: Modifier = Modifier,
playerContent: (@Composable (String) -> Unit)? = null,
) {
Column(
modifier = modifier.fillMaxWidth(),
@@ -76,12 +80,16 @@ fun PGNMetadata(
verticalAlignment = Alignment.CenterVertically,
) {
game.white?.let { white ->
Text(
text = white,
style = MaterialTheme.typography.bodyMedium,
fontWeight = FontWeight.Medium,
color = MaterialTheme.colorScheme.onSurface,
)
if (playerContent != null) {
playerContent(white)
} else {
Text(
text = white,
style = MaterialTheme.typography.bodyMedium,
fontWeight = FontWeight.Medium,
color = MaterialTheme.colorScheme.onSurface,
)
}
}
Text(
@@ -91,12 +99,16 @@ fun PGNMetadata(
)
game.black?.let { black ->
Text(
text = black,
style = MaterialTheme.typography.bodyMedium,
fontWeight = FontWeight.Medium,
color = MaterialTheme.colorScheme.onSurface,
)
if (playerContent != null) {
playerContent(black)
} else {
Text(
text = black,
style = MaterialTheme.typography.bodyMedium,
fontWeight = FontWeight.Medium,
color = MaterialTheme.colorScheme.onSurface,
)
}
}
}
}