feat(service)!: refactor configuration, nodedb, and connection states (#2661)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-08-08 16:59:54 -05:00 committed by GitHub
parent 4548a3ec7b
commit 4a7e3e35e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 1263 additions and 1387 deletions

View file

@ -45,6 +45,7 @@ import com.geeksville.mesh.DataPacket
import com.geeksville.mesh.model.DeviceVersion
import com.geeksville.mesh.model.Node
import com.geeksville.mesh.model.UIViewModel
import com.geeksville.mesh.service.ConnectionState
import com.geeksville.mesh.ui.common.components.rememberTimeTickWithLifecycle
import com.geeksville.mesh.ui.node.components.NodeFilterTextField
import com.geeksville.mesh.ui.node.components.NodeItem
@ -75,32 +76,19 @@ fun NodeScreen(
var showSharedContact: Node? by remember { mutableStateOf(null) }
if (showSharedContact != null) {
SharedContactDialog(
contact = showSharedContact,
onDismiss = { showSharedContact = null }
)
SharedContactDialog(contact = showSharedContact, onDismiss = { showSharedContact = null })
}
val isScrollInProgress by remember {
derivedStateOf { listState.isScrollInProgress }
}
val isScrollInProgress by remember { derivedStateOf { listState.isScrollInProgress } }
Box(
modifier = Modifier
.fillMaxSize()
) {
LazyColumn(
state = listState,
modifier = Modifier.fillMaxSize(),
) {
Box(modifier = Modifier.fillMaxSize()) {
LazyColumn(state = listState, modifier = Modifier.fillMaxSize()) {
stickyHeader {
val animatedAlpha by animateFloatAsState(
targetValue = if (!isScrollInProgress) 1.0f else 0f,
label = "alpha"
)
val animatedAlpha by
animateFloatAsState(targetValue = if (!isScrollInProgress) 1.0f else 0f, label = "alpha")
NodeFilterTextField(
modifier = Modifier
.fillMaxWidth()
modifier =
Modifier.fillMaxWidth()
.graphicsLayer(alpha = animatedAlpha)
.background(MaterialTheme.colorScheme.surfaceDim)
.padding(8.dp),
@ -137,8 +125,7 @@ fun NodeScreen(
is NodeMenuAction.Favorite -> model.favoriteNode(node)
is NodeMenuAction.DirectMessage -> {
val hasPKC = model.ourNodeInfo.value?.hasPKC == true && node.hasPKC
val channel =
if (hasPKC) DataPacket.PKC_CHANNEL_INDEX else node.channel
val channel = if (hasPKC) DataPacket.PKC_CHANNEL_INDEX else node.channel
navigateToMessages("$channel${node.user.id}")
}
@ -161,19 +148,10 @@ fun NodeScreen(
AnimatedVisibility(
modifier = Modifier.align(Alignment.BottomEnd),
visible = !isScrollInProgress &&
connectionState.isConnected() &&
shareCapable
visible = !isScrollInProgress && connectionState == ConnectionState.CONNECTED && shareCapable,
) {
@Suppress("NewApi")
(
AddContactFAB(
model = model,
onSharedContactImport = { contact ->
model.addSharedContact(contact)
}
)
)
(AddContactFAB(model = model, onSharedContactImport = { contact -> model.addSharedContact(contact) }))
}
}
}