fix: preshared key should be hidden

closes #547
This commit is contained in:
Zane Schepke 2025-01-18 05:47:23 -05:00
parent 02dea1e6b0
commit ff97c65d4f
1 changed files with 24 additions and 6 deletions

View File

@ -677,15 +677,33 @@ fun ConfigScreen(tunnelConfig: TunnelConfig?, appViewModel: AppViewModel) {
hint = stringResource(R.string.base64_key),
modifier = Modifier.fillMaxWidth(),
)
ConfigurationTextBox(
val presharedKeyEnabled = (tunnelConfig == null) || isAuthenticated || peer.preSharedKey.isBlank()
OutlinedTextField(
textStyle = MaterialTheme.typography.labelLarge,
modifier =
Modifier
.fillMaxWidth()
.clickable { showAuthPrompt = true },
value = peer.preSharedKey,
onValueChange = { value ->
peersState[index] = peersState[index].copy(preSharedKey = value)
visualTransformation =
if (presharedKeyEnabled) {
VisualTransformation.None
} else {
PasswordVisualTransformation()
},
enabled = presharedKeyEnabled,
onValueChange = { value -> peersState[index] = peersState[index].copy(preSharedKey = value) },
label = { Text(stringResource(R.string.preshared_key)) },
singleLine = true,
placeholder = {
Text(
stringResource(R.string.optional),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.outline,
)
},
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
label = stringResource(R.string.preshared_key),
hint = stringResource(R.string.optional),
modifier = Modifier.fillMaxWidth(),
)
OutlinedTextField(
textStyle = MaterialTheme.typography.labelLarge,