Skip to content

Commit

Permalink
fix: cannot edit array's new value and "" string value (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
huajijam authored Jan 20, 2024
1 parent d24bbf0 commit 9ac4ef1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/dev/bluehouse/enablevolte/pages/Editor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ data class DataRow(override val field: Field, override val rawValue: Any?) : Bas
}
override val typedValue: Any? get() =
when (fieldType) {
ValueType.Int -> this.value?.toInt()
ValueType.Long -> this.value?.toLong()
ValueType.Bool -> this.value?.let { it == "true" } ?: { null }
ValueType.String -> this.value
ValueType.Int, ValueType.IntArray -> this.value?.toInt()
ValueType.Long, ValueType.LongArray -> this.value?.toLong()
ValueType.Bool, ValueType.BoolArray -> this.value?.let { it == "true" } ?: { null }
ValueType.String, ValueType.StringArray -> this.value
else -> null
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ fun SingleValueEditor(data: DataRow, onValueChange: (String) -> Unit) {
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
modifier = Modifier.fillMaxWidth(),
)
is String -> TextField(
is String, null -> TextField(
value = data.value ?: "",
onValueChange = { onValueChange(it) },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
Expand Down Expand Up @@ -232,7 +232,7 @@ fun MultiValueEditor(_data: ListDataRow, onUpdate: (List<String?>) -> Unit) {
Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
Box(modifier = Modifier.weight(1f, fill = true))
IconButton(onClick = {
val newItems = items.append("")
val newItems = items.append(null)
data = data.copy(rawValue = newItems)
}) { Icon(imageVector = Icons.Filled.Add, contentDescription = "") }
}
Expand Down

0 comments on commit 9ac4ef1

Please sign in to comment.