mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-22 15:19:10 +00:00
confirm color in color picker dialog on done, fixes GH-1443
This commit is contained in:
parent
a3fcce26a7
commit
525c4e59b6
1 changed files with 8 additions and 2 deletions
|
@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -24,6 +25,7 @@ import androidx.compose.ui.graphics.PaintingStyle
|
||||||
import androidx.compose.ui.graphics.toArgb
|
import androidx.compose.ui.graphics.toArgb
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.text.TextRange
|
import androidx.compose.ui.text.TextRange
|
||||||
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.text.input.TextFieldValue
|
import androidx.compose.ui.text.input.TextFieldValue
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
@ -109,8 +111,12 @@ fun ColorPickerDialog(
|
||||||
)
|
)
|
||||||
TextField(
|
TextField(
|
||||||
value = textValue,
|
value = textValue,
|
||||||
// todo: KeyboardType.Password is a crappy way of avoiding suggestions... is there really no way in compose?
|
keyboardOptions = KeyboardOptions(
|
||||||
keyboardOptions = KeyboardOptions(autoCorrectEnabled = false, keyboardType = KeyboardType.Password),
|
autoCorrectEnabled = false,
|
||||||
|
keyboardType = KeyboardType.Password, // todo: KeyboardType.Password is a crappy way of avoiding suggestions... is there really no way in compose?
|
||||||
|
imeAction = ImeAction.Done,
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(onDone = { onDismissRequest(); onConfirmed(controller.selectedColor.value.toArgb()) }),
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
textValue = it
|
textValue = it
|
||||||
val androidColor = runCatching { android.graphics.Color.parseColor("#${it.text}") }.getOrNull()
|
val androidColor = runCatching { android.graphics.Color.parseColor("#${it.text}") }.getOrNull()
|
||||||
|
|
Loading…
Add table
Reference in a new issue