button enabled/disabled logic

This commit is contained in:
Leandro Schaguhn 2025-06-11 17:36:52 +02:00
parent e7086791c8
commit 078a1a9efe

View file

@ -71,7 +71,15 @@ fun homeScreen(paddingValues: PaddingValues) {
} }
} }
Button(onClick = {currentScreen = nextScreen}, modifier = Modifier.padding(top = 24.dp)) { Button(
onClick = {currentScreen = nextScreen},
modifier = Modifier.padding(top = 24.dp),
enabled = when(currentScreen) {
0 -> isValidUrl(serverURL)
1 -> username.isNotEmpty() && password.isNotEmpty()
else -> false
},
) {
Row() { Row() {
Text(text = "Next") Text(text = "Next")
} }
@ -122,7 +130,7 @@ fun serverDialog(serverURL: String, updateServerURL: (newServerURL: String) -> U
}, },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
supportingText = { supportingText = {
AnimatedVisibility(!isValidUrl(serverURL)) { AnimatedVisibility(!isValidUrl(serverURL) && serverURL != "") {
Text( Text(
text = "No valid URL", text = "No valid URL",
color = MaterialTheme.colorScheme.error color = MaterialTheme.colorScheme.error