fix(android) detekt: rename ListenBrainz wire file + shrink ListenBrainzForm
* MatchingDeclarationName: ListenBrainzWire.kt → ListenBrainzStatusWire.kt. * LongMethod: extracted TokenField / SaveTokenButton / EnabledRow helpers so ListenBrainzForm stays under the 60-line cap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+40
-17
@@ -77,23 +77,45 @@ private fun ListenBrainzForm(
|
|||||||
onSaveToken: () -> Unit,
|
onSaveToken: () -> Unit,
|
||||||
onSetEnabled: (Boolean) -> 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(
|
OutlinedTextField(
|
||||||
value = tokenInput,
|
value = tokenInput,
|
||||||
onValueChange = onTokenChange,
|
onValueChange = onChange,
|
||||||
label = {
|
label = { Text(if (tokenSet) "Replace token" else "Token") },
|
||||||
Text(if (status?.tokenSet == true) "Replace token" else "Token")
|
placeholder = { Text(if (tokenSet) "Token saved" else "") },
|
||||||
},
|
|
||||||
placeholder = {
|
|
||||||
Text(if (status?.tokenSet == true) "Token saved" else "")
|
|
||||||
},
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
visualTransformation = PasswordVisualTransformation(),
|
visualTransformation = PasswordVisualTransformation(),
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(4.dp))
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun SaveTokenButton(isSaving: Boolean, enabled: Boolean, onClick: () -> Unit) {
|
||||||
Button(
|
Button(
|
||||||
onClick = onSaveToken,
|
onClick = onClick,
|
||||||
enabled = !isSaving && tokenInput.isNotBlank(),
|
enabled = enabled,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) {
|
) {
|
||||||
if (isSaving) {
|
if (isSaving) {
|
||||||
@@ -106,6 +128,14 @@ private fun ListenBrainzForm(
|
|||||||
}
|
}
|
||||||
Text(if (isSaving) "Saving…" else "Save token")
|
Text(if (isSaving) "Saving…" else "Save token")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun EnabledRow(
|
||||||
|
status: ListenBrainzStatus?,
|
||||||
|
isSaving: Boolean,
|
||||||
|
onSetEnabled: (Boolean) -> Unit,
|
||||||
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
@@ -131,11 +161,4 @@ private fun ListenBrainzForm(
|
|||||||
enabled = !isSaving && status?.tokenSet == true,
|
enabled = !isSaving && status?.tokenSet == true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (message != null) {
|
|
||||||
Text(
|
|
||||||
text = message,
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user