mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-17 11:59:34 +00:00
bring up keyboard when adding a new word in personal dictionary screen
fixes GH-1663
This commit is contained in:
parent
8ae241b032
commit
83ff9b3345
1 changed files with 9 additions and 1 deletions
|
@ -20,12 +20,15 @@ import androidx.compose.material3.MaterialTheme
|
|||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
|
@ -83,6 +86,11 @@ fun PersonalDictionaryScreen(
|
|||
)
|
||||
if (selectedWord != null) {
|
||||
val selWord = selectedWord!!
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
LaunchedEffect(selectedWord) {
|
||||
if (selWord.word == "" && selWord.weight == null && selWord.shortcut == null)
|
||||
focusRequester.requestFocus() // user clicked add word
|
||||
}
|
||||
var newWord by remember { mutableStateOf(selWord) }
|
||||
var newLocale by remember { mutableStateOf(locale) }
|
||||
val wordValid = (newWord.word == selWord.word && locale == newLocale) || !doesWordExist(newWord.word, newLocale, ctx)
|
||||
|
@ -119,7 +127,7 @@ fun PersonalDictionaryScreen(
|
|||
TextField(
|
||||
value = newWord.word,
|
||||
onValueChange = { newWord = newWord.copy(word = it) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier.fillMaxWidth().focusRequester(focusRequester),
|
||||
singleLine = true
|
||||
)
|
||||
Row(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue