From 2824e8fdffed6d8765cda6f72f7a64dd3ea0ba03 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 3 Dec 2026 11:22:42 -0500 Subject: [PATCH] android: split the server screen's buttons out of the form (#8316) The form ran past detekt's 60-line limit for one function once it gained the probe's progress and Cancel. Co-Authored-By: Claude Opus 5.5 --- .../minstrel/auth/ui/ServerUrlScreen.kt | 50 ++++++++++++------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/android/app/src/main/java/com/fabledsword/minstrel/auth/ui/ServerUrlScreen.kt b/android/app/src/main/java/com/fabledsword/minstrel/auth/ui/ServerUrlScreen.kt index 4ae2b60f..8b78a134 100644 --- a/android/app/src/main/java/com/fabledsword/minstrel/auth/ui/ServerUrlScreen.kt +++ b/android/app/src/main/java/com/fabledsword/minstrel/auth/ui/ServerUrlScreen.kt @@ -189,23 +189,39 @@ private fun ServerUrlForm( style = MaterialTheme.typography.bodySmall, ) } - Button( - onClick = onSubmit, - enabled = !state.probing && state.url.isNotBlank(), - modifier = Modifier.fillMaxWidth(), - ) { - if (state.probing) { - CircularProgressIndicator( - modifier = Modifier.size(20.dp), - color = MaterialTheme.colorScheme.onPrimary, - strokeWidth = 2.dp, - ) - } else { - Text("Continue") - } + ProbeButtons( + probing = state.probing, + canSubmit = state.url.isNotBlank(), + onSubmit = onSubmit, + onCancel = onCancel, + ) + } +} + +/** Continue, which shows progress while the address is probed, and Cancel beside it. */ +@Composable +private fun ProbeButtons( + probing: Boolean, + canSubmit: Boolean, + onSubmit: () -> Unit, + onCancel: () -> Unit, +) { + Button( + onClick = onSubmit, + enabled = !probing && canSubmit, + modifier = Modifier.fillMaxWidth(), + ) { + if (probing) { + CircularProgressIndicator( + modifier = Modifier.size(20.dp), + color = MaterialTheme.colorScheme.onPrimary, + strokeWidth = 2.dp, + ) + } else { + Text("Continue") } - if (state.probing) { - TextButton(onClick = onCancel) { Text("Cancel") } - } + } + if (probing) { + TextButton(onClick = onCancel) { Text("Cancel") } } }