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,
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user