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