feat: replace LoRa bandwidth text input with constrained dropdown (#5687)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
James Rich
2026-05-31 10:15:31 -07:00
committed by GitHub
parent 38ec47e894
commit ccf984e4b1
2 changed files with 20 additions and 5 deletions
+1 -1
View File
@@ -143,7 +143,7 @@ configuration settings screen. Constraints are sourced from two layers:
| `region` | Enum | Dropdown: `RegionInfo` entries | Regional frequency plans |
| `use_preset` | Boolean | Toggle | Controls manual vs preset LoRa settings visibility |
| `modem_preset` | Enum | Dropdown: `ChannelOption` entries | Visible only when `use_preset = true` |
| `bandwidth` | Integer | Numeric input | Visible only when `use_preset = false` |
| `bandwidth` | Integer | Dropdown: valid LoRa bandwidths (7.8500 kHz) | Visible only when `use_preset = false` |
| `spread_factor` | Integer | Numeric input | Visible only when `use_preset = false` |
| `coding_rate` | Integer | Numeric input | Visible only when `use_preset = false` |
| `hop_limit` | Integer | Dropdown: 07 | — |
@@ -67,6 +67,21 @@ import org.meshtastic.proto.Config
private val SPREAD_FACTOR_RANGE = 7..12
private val CODING_RATE_RANGE = 5..8
/** Valid LoRa bandwidth codes mapped to their display labels (kHz). */
private val BANDWIDTH_OPTIONS: List<Pair<Int, String>> =
listOf(
8 to "7.8 kHz",
10 to "10.4 kHz",
16 to "15.6 kHz",
21 to "20.8 kHz",
31 to "31.25 kHz",
42 to "41.7 kHz",
62 to "62.5 kHz",
125 to "125 kHz",
250 to "250 kHz",
500 to "500 kHz",
)
@Composable
fun LoRaConfigScreen(viewModel: RadioConfigViewModel, onBack: () -> Unit) {
val state by viewModel.radioConfigState.collectAsStateWithLifecycle()
@@ -245,12 +260,12 @@ private fun ManualModemSettings(
onConfigChange: (Config.LoRaConfig) -> Unit,
) {
androidx.compose.foundation.layout.Column {
EditTextPreference(
DropDownPreference(
title = stringResource(Res.string.bandwidth),
value = config.bandwidth,
enabled = enabled,
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
onValueChanged = { onConfigChange(config.copy(bandwidth = it)) },
items = BANDWIDTH_OPTIONS,
selectedItem = config.bandwidth,
onItemSelected = { onConfigChange(config.copy(bandwidth = it)) },
)
HorizontalDivider()
EditTextPreference(