kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
rodzic
5da827473a
commit
d8f67e011a
|
@ -46,6 +46,40 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.geeksville.mesh.R
|
||||
|
||||
@Composable
|
||||
fun SignedIntegerEditTextPreference(
|
||||
title: String,
|
||||
value: Int,
|
||||
enabled: Boolean,
|
||||
keyboardActions: KeyboardActions,
|
||||
onValueChanged: (Int) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onFocusChanged: (FocusState) -> Unit = {},
|
||||
trailingIcon: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
var valueState by remember(value) { mutableStateOf(value.toString()) }
|
||||
|
||||
EditTextPreference(
|
||||
title = title,
|
||||
value = valueState,
|
||||
enabled = enabled,
|
||||
isError = valueState.toIntOrNull() == null,
|
||||
keyboardOptions = KeyboardOptions.Default.copy(
|
||||
keyboardType = KeyboardType.Number, imeAction = ImeAction.Done
|
||||
),
|
||||
keyboardActions = keyboardActions,
|
||||
onValueChanged = {
|
||||
valueState = it
|
||||
it.toIntOrNull()?.let { int ->
|
||||
onValueChanged(int)
|
||||
}
|
||||
},
|
||||
onFocusChanged = onFocusChanged,
|
||||
modifier = modifier,
|
||||
trailingIcon = trailingIcon
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun EditTextPreference(
|
||||
title: String,
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.geeksville.mesh.ui.components.EditListPreference
|
|||
import com.geeksville.mesh.ui.components.EditTextPreference
|
||||
import com.geeksville.mesh.ui.components.PreferenceCategory
|
||||
import com.geeksville.mesh.ui.components.PreferenceFooter
|
||||
import com.geeksville.mesh.ui.components.SignedIntegerEditTextPreference
|
||||
import com.geeksville.mesh.ui.components.SwitchPreference
|
||||
import com.geeksville.mesh.ui.radioconfig.RadioConfigViewModel
|
||||
|
||||
|
@ -171,11 +172,13 @@ fun LoRaConfigItemList(
|
|||
item { Divider() }
|
||||
|
||||
item {
|
||||
EditTextPreference(title = "TX power (dBm)",
|
||||
SignedIntegerEditTextPreference(
|
||||
title = "TX power (dBm)",
|
||||
value = loraInput.txPower,
|
||||
enabled = enabled,
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
|
||||
onValueChanged = { loraInput = loraInput.copy { txPower = it } })
|
||||
onValueChanged = { loraInput = loraInput.copy { txPower = it } },
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
|
|
Ładowanie…
Reference in New Issue