Skip to content

Commit

Permalink
feat: trigger channel scan dialog when users paste a new valid URL
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Dec 10, 2024
1 parent a475280 commit a19a28c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import androidx.compose.material.icons.twotone.Check
import androidx.compose.material.icons.twotone.Close
import androidx.compose.material.icons.twotone.ContentCopy
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -321,6 +322,11 @@ fun ChannelScreen(
channelSelections = channelSelections,
onClick = { showChannelEditor = true }
)
EditChannelUrl(
enabled = enabled,
channelUrl = selectedChannelSet.getChannelUrl(),
onConfirm = viewModel::requestChannelUrl
)
}
} else {
dragDropItemsIndexed(
Expand Down Expand Up @@ -354,14 +360,6 @@ fun ChannelScreen(
}
}

item {
EditChannelUrl(
enabled = enabled,
channelUrl = selectedChannelSet.getChannelUrl(),
onConfirm = viewModel::requestChannelUrl
)
}

item {
DropDownPreference(title = stringResource(id = R.string.channel_options),
enabled = enabled,
Expand Down Expand Up @@ -419,6 +417,13 @@ private fun EditChannelUrl(
var valueState by remember(channelUrl) { mutableStateOf(channelUrl) }
var isError by remember { mutableStateOf(false) }

// Trigger dialog automatically when users paste a new valid URL
LaunchedEffect(valueState, isError) {
if (!isError && valueState != channelUrl) {
onConfirm(valueState)
}
}

OutlinedTextField(
value = valueState.toString(),
onValueChange = {
Expand Down

0 comments on commit a19a28c

Please sign in to comment.