added autofill

This commit is contained in:
Leandro Schaguhn 2025-06-13 16:48:51 +02:00
parent b8d6c098ac
commit 664824b368
2 changed files with 16 additions and 7 deletions

View file

@ -1,6 +1,7 @@
package de.lelehier.keeper.screens
import KeeperLargeFontFamily
import android.util.Patterns
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedContentTransitionScope
@ -48,9 +49,11 @@ import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.autofill.ContentType
import androidx.compose.ui.semantics.contentType
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.input.PasswordVisualTransformation
@Composable
fun LoginScreen(paddingValues: PaddingValues) {
@ -194,6 +197,7 @@ fun Greeting(serverURL: String, currentScreen: String) {
fun ServerDialog(serverURL: String, updateServerURL: (newServerURL: String) -> Unit) {
var dialogServerURL by remember { mutableStateOf("") }
OutlinedTextField(
singleLine = true,
modifier = Modifier.fillMaxWidth(),
label = { Text(text = "Server URL") },
textStyle = MaterialTheme.typography.bodySmall,
@ -230,23 +234,26 @@ fun PasswordDialog(username: String, password: String, updateUsername: (newUsern
var dialogPassword by remember { mutableStateOf("") }
Column {
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
singleLine = true,
modifier = Modifier.fillMaxWidth().semantics {contentType = ContentType.Username + ContentType.EmailAddress},
label = { Text(text = "Username") },
textStyle = MaterialTheme.typography.bodySmall,
value = username,
onValueChange = { text ->
dialogUsername = text
updateUsername(dialogUsername)
});
})
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
singleLine = true,
modifier = Modifier.fillMaxWidth().semantics {contentType = ContentType.Password},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
label = { Text(text = "Password") },
textStyle = MaterialTheme.typography.bodySmall,
value = password,
visualTransformation = PasswordVisualTransformation(),
onValueChange = { text ->
dialogPassword = text
updatePassword(dialogPassword)
}
updatePassword(dialogPassword)}
)
}
@ -257,6 +264,7 @@ fun ApiDialog(apiKey: String, updateApiKey: (newApiKey: String) -> Unit) {
var dialogApiKey by remember { mutableStateOf(apiKey) }
Column {
OutlinedTextField(
singleLine = true,
modifier = Modifier.fillMaxWidth(),
label = { Text(text = "API Key") },
textStyle = MaterialTheme.typography.bodySmall,