The first public release of Fabled Minstrel #158
@@ -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") }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user