feat: M3 weighted shuffle v1 — real /api/radio with scoring #21

Merged
bvandeusen merged 262 commits from dev into main 2026-04-27 11:00:29 -04:00
2 changed files with 40 additions and 17 deletions
Showing only changes of commit 2cb9f062c5 - Show all commits
@@ -77,23 +77,45 @@ private fun ListenBrainzForm(
onSaveToken: () -> Unit,
onSetEnabled: (Boolean) -> Unit,
) {
TokenField(
tokenInput = tokenInput,
tokenSet = status?.tokenSet == true,
onChange = onTokenChange,
)
Spacer(Modifier.height(4.dp))
SaveTokenButton(
isSaving = isSaving,
enabled = !isSaving && tokenInput.isNotBlank(),
onClick = onSaveToken,
)
EnabledRow(status = status, isSaving = isSaving, onSetEnabled = onSetEnabled)
if (message != null) {
Text(
text = message,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
@Composable
private fun TokenField(tokenInput: String, tokenSet: Boolean, onChange: (String) -> Unit) {
OutlinedTextField(
value = tokenInput,
onValueChange = onTokenChange,
label = {
Text(if (status?.tokenSet == true) "Replace token" else "Token")
},
placeholder = {
Text(if (status?.tokenSet == true) "Token saved" else "")
},
onValueChange = onChange,
label = { Text(if (tokenSet) "Replace token" else "Token") },
placeholder = { Text(if (tokenSet) "Token saved" else "") },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
visualTransformation = PasswordVisualTransformation(),
)
Spacer(Modifier.height(4.dp))
}
@Composable
private fun SaveTokenButton(isSaving: Boolean, enabled: Boolean, onClick: () -> Unit) {
Button(
onClick = onSaveToken,
enabled = !isSaving && tokenInput.isNotBlank(),
onClick = onClick,
enabled = enabled,
modifier = Modifier.fillMaxWidth(),
) {
if (isSaving) {
@@ -106,6 +128,14 @@ private fun ListenBrainzForm(
}
Text(if (isSaving) "Saving…" else "Save token")
}
}
@Composable
private fun EnabledRow(
status: ListenBrainzStatus?,
isSaving: Boolean,
onSetEnabled: (Boolean) -> Unit,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
@@ -131,11 +161,4 @@ private fun ListenBrainzForm(
enabled = !isSaving && status?.tokenSet == true,
)
}
if (message != null) {
Text(
text = message,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}