From ca86caa72ee138103db01b8757f36b7ab88033a8 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 7 Mar 2024 00:46:00 -0600 Subject: [PATCH] Add word counter to Import Account screen --- .../screen/importaccount/ImportAccountScreen.kt | 16 ++++++++++++++-- .../desktopMain/kotlin/net/agorise/kee/main.kt | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/agorise/kee/ui/screen/importaccount/ImportAccountScreen.kt b/composeApp/src/commonMain/kotlin/net/agorise/kee/ui/screen/importaccount/ImportAccountScreen.kt index 1cf39a6..36b5ff7 100644 --- a/composeApp/src/commonMain/kotlin/net/agorise/kee/ui/screen/importaccount/ImportAccountScreen.kt +++ b/composeApp/src/commonMain/kotlin/net/agorise/kee/ui/screen/importaccount/ImportAccountScreen.kt @@ -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") diff --git a/composeApp/src/desktopMain/kotlin/net/agorise/kee/main.kt b/composeApp/src/desktopMain/kotlin/net/agorise/kee/main.kt index 5ffe842..c08889f 100644 --- a/composeApp/src/desktopMain/kotlin/net/agorise/kee/main.kt +++ b/composeApp/src/desktopMain/kotlin/net/agorise/kee/main.kt @@ -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()) } }