mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: consolidate QR code scanning methods
This commit is contained in:
parent
75003bb6f0
commit
f73d909cd0
44 changed files with 89 additions and 226 deletions
|
|
@ -51,13 +51,16 @@ fun ScannedQrCodeDialog(
|
|||
onDismiss: () -> Unit,
|
||||
onConfirm: (ChannelSet) -> Unit
|
||||
) {
|
||||
var shouldReplace by remember { mutableStateOf(true) }
|
||||
var shouldReplace by remember { mutableStateOf(incoming.hasLoraConfig()) }
|
||||
|
||||
val channelSet = remember(shouldReplace) {
|
||||
if (shouldReplace) {
|
||||
incoming
|
||||
} else {
|
||||
channels.copy {
|
||||
// To guarantee consistent ordering, using a LinkedHashSet which iterates through
|
||||
// it's entries according to the order an item was *first* inserted.
|
||||
// https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-linked-hash-set/
|
||||
val result = LinkedHashSet(settings + incoming.settingsList)
|
||||
settings.clear()
|
||||
settings.addAll(result)
|
||||
|
|
@ -134,6 +137,7 @@ fun ScannedQrCodeDialog(
|
|||
modifier = Modifier
|
||||
.height(48.dp)
|
||||
.weight(1f),
|
||||
enabled = incoming.hasLoraConfig(),
|
||||
colors = if (shouldReplace) selectedColors else unselectedColors,
|
||||
) { Text(text = stringResource(R.string.replace)) }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue