Compare commits
2 commits
2056e7f8d4
...
7668743a1f
| Author | SHA1 | Date | |
|---|---|---|---|
| 7668743a1f | |||
| 0d44832747 |
1 changed files with 36 additions and 23 deletions
|
|
@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.padding
|
|||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -67,11 +68,22 @@ fun HomeScreen(paddingValues: PaddingValues) {
|
|||
},
|
||||
|
||||
) { targetState -> when(targetState) {
|
||||
0 -> serverDialog(serverURL, {newServerURL -> serverURL = newServerURL })
|
||||
1 -> passwordDialog(username, password, {newUsername -> username = newUsername}, {newPassword -> password = newPassword })
|
||||
0 -> ServerDialog(serverURL, {newServerURL -> serverURL = newServerURL })
|
||||
1 -> PasswordDialog(username, password, {newUsername -> username = newUsername}, {newPassword -> password = newPassword })
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
AnimatedVisibility(currentScreen == 1) {
|
||||
OutlinedButton (
|
||||
onClick = {currentScreen = nextScreen},
|
||||
modifier = Modifier.padding(top = 24.dp)
|
||||
) {
|
||||
Row() {
|
||||
Text(text = "Use API Key")
|
||||
}
|
||||
}
|
||||
}
|
||||
Button(
|
||||
onClick = {currentScreen = nextScreen},
|
||||
modifier = Modifier.padding(top = 24.dp),
|
||||
|
|
@ -87,6 +99,7 @@ fun HomeScreen(paddingValues: PaddingValues) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Greeting(serverURL: String, currentScreen: Int) {
|
||||
|
|
@ -119,15 +132,15 @@ fun Greeting(serverURL: String, currentScreen: Int) {
|
|||
|
||||
|
||||
@Composable
|
||||
fun serverDialog(serverURL: String, updateServerURL: (newServerURL: String) -> Unit) {
|
||||
var serverURL by remember { mutableStateOf("") }
|
||||
fun ServerDialog(serverURL: String, updateServerURL: (newServerURL: String) -> Unit) {
|
||||
var dialogServerURL by remember { mutableStateOf("") }
|
||||
OutlinedTextField(
|
||||
label = { Text(text = "Server URL") },
|
||||
textStyle = MaterialTheme.typography.bodySmall,
|
||||
value = serverURL,
|
||||
onValueChange = { text ->
|
||||
serverURL = text
|
||||
updateServerURL(serverURL)
|
||||
dialogServerURL = text
|
||||
updateServerURL(dialogServerURL)
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
|
||||
supportingText = {
|
||||
|
|
@ -152,25 +165,25 @@ fun isValidUrl(url: String): Boolean {
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun passwordDialog(username: String, password: String, updateUsername: (newUsername: String) -> Unit, updatePassword: (newPassword: String) -> Unit) {
|
||||
var username by remember { mutableStateOf("") }
|
||||
var password by remember { mutableStateOf("") }
|
||||
fun PasswordDialog(username: String, password: String, updateUsername: (newUsername: String) -> Unit, updatePassword: (newPassword: String) -> Unit) {
|
||||
var dialogUsername by remember { mutableStateOf("") }
|
||||
var dialogPassword by remember { mutableStateOf("") }
|
||||
Column {
|
||||
OutlinedTextField(
|
||||
label = { Text(text = "Username") },
|
||||
textStyle = MaterialTheme.typography.bodySmall,
|
||||
value = username,
|
||||
onValueChange = { text ->
|
||||
username = text
|
||||
updateUsername(username)
|
||||
dialogUsername = text
|
||||
updateUsername(dialogUsername)
|
||||
});
|
||||
OutlinedTextField(
|
||||
label = { Text(text = "Password") },
|
||||
textStyle = MaterialTheme.typography.bodySmall,
|
||||
value = password,
|
||||
onValueChange = { text ->
|
||||
password = text
|
||||
updatePassword(password)
|
||||
dialogPassword = text
|
||||
updatePassword(dialogPassword)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue