Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ fun RangeTestConfigScreen(viewModel: RadioConfigViewModel = hiltViewModel(), onB
title = stringResource(Res.string.range_test),
onBack = onBack,
configState = formState,
enabled = state.connected,
enabled = state.connected && !isPublicPrimaryChannel,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's deduplicatestate.connected && !isPublicPrimaryChannel and hoist into a value that can be reused

responseState = state.responseState,
onDismissPacketResponse = viewModel::clearPacketResponse,
onSave = {
val config = moduleConfig { rangeTest = it }
val safeRangeTest = if (isPublicPrimaryChannel && it.enabled) it.copy { this.enabled = false } else it
val config = moduleConfig { rangeTest = safeRangeTest }
viewModel.setModuleConfig(config)
},
) {
Expand All @@ -63,7 +64,7 @@ fun RangeTestConfigScreen(viewModel: RadioConfigViewModel = hiltViewModel(), onB
SwitchPreference(
title = stringResource(Res.string.range_test_enabled),
checked = formState.value.enabled,
enabled = state.connected,
enabled = state.connected && !isPublicPrimaryChannel,
onCheckedChange = { formState.value = formState.value.copy { this.enabled = it } },
containerColor = CardDefaults.cardColors().containerColor,
)
Expand All @@ -72,15 +73,15 @@ fun RangeTestConfigScreen(viewModel: RadioConfigViewModel = hiltViewModel(), onB
DropDownPreference(
title = stringResource(Res.string.sender_message_interval_seconds),
selectedItem = formState.value.sender.toLong(),
enabled = state.connected,
enabled = state.connected && !isPublicPrimaryChannel,
items = rangeItems.map { it.value to it.toDisplayString() },
onItemSelected = { formState.value = formState.value.copy { sender = it.toInt() } },
)
HorizontalDivider()
SwitchPreference(
title = stringResource(Res.string.save_csv_in_storage_esp32_only),
checked = formState.value.save,
enabled = state.connected,
enabled = state.connected && !isPublicPrimaryChannel,
onCheckedChange = { formState.value = formState.value.copy { save = it } },
containerColor = CardDefaults.cardColors().containerColor,
)
Expand Down
Loading