Skip to content

Commit

Permalink
obfuscated password entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Jian Liew committed Jan 24, 2024
1 parent 3c67ef5 commit 32144c2
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.steamclock.debugmenu_ui.components

import android.view.KeyEvent
import android.view.KeyEvent.KEYCODE_ENTER
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -18,6 +17,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch
Expand All @@ -37,23 +37,30 @@ fun CodeEntry(onSubmit: suspend (String) -> Unit) {
}
}

Column(Modifier.fillMaxWidth().padding(16.dp)) {
Column(
Modifier
.fillMaxWidth()
.padding(16.dp)) {
Text(text = "Enter code")

TextField(
textState.value,
singleLine = true,
onValueChange = { textState.value = it },
visualTransformation = PasswordVisualTransformation(),
keyboardActions = KeyboardActions { submit() },
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done, keyboardType = KeyboardType.Password),
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp).onKeyEvent {
return@onKeyEvent if (it.nativeKeyEvent.keyCode == KEYCODE_ENTER) {
submit()
true
} else {
false
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp)
.onKeyEvent {
return@onKeyEvent if (it.nativeKeyEvent.keyCode == KEYCODE_ENTER) {
submit()
true
} else {
false
}
}
}
)

Button(
Expand Down

0 comments on commit 32144c2

Please sign in to comment.