Add word counter to Import Account screen

This commit is contained in:
Severiano Jaramillo 2024-03-07 00:46:00 -06:00
parent ea27b33b3e
commit ca86caa72e
2 changed files with 15 additions and 3 deletions

View file

@ -5,6 +5,7 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.LocalNavigator
@ -17,6 +18,8 @@ import org.jetbrains.compose.resources.vectorResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import ui.theme.KeeTheme
private const val RECOVERY_WORDS_COUNT = 25
class ImportAccountScreen : Screen {
@Composable
@ -51,11 +54,20 @@ private fun ImportAccountScreenContent() {
OutlinedTextField(
value = recoveryText,
onValueChange = { recoveryText = it },
modifier = Modifier.fillMaxWidth(),
minLines = 5,
modifier = Modifier.fillMaxWidth()
maxLines = 5,
supportingText = {
Text(
text = "${recoveryWords.count()}/${RECOVERY_WORDS_COUNT} words",
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.End,
)
}
)
Button(
enabled = recoveryWords.size == 2,
enabled = recoveryWords.size == RECOVERY_WORDS_COUNT,
modifier = Modifier.padding(top = 16.dp),
onClick = { navigator?.replace(HomeScreen()) }
) {
Text("Import Account")

View file

@ -14,7 +14,7 @@ fun main() = application {
size = DpSize(420.dp, 880.dp),
position = WindowPosition(300.dp, 300.dp)
)
Window(title = "", onCloseRequest = ::exitApplication, state = state) {
Window(title = "Kee", onCloseRequest = ::exitApplication, state = state) {
Navigator(HomeScreen())
}
}