fix(connections): label the connecting-card button "Stop Connecting" (#6046)

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
James Rich
2026-07-01 14:01:09 -05:00
committed by GitHub
parent ae5afc9022
commit 735a57bc70
6 changed files with 27 additions and 3 deletions

View File

@@ -1390,6 +1390,7 @@ state_broadcast_seconds
status_message
status_message_config
stay_connected_anywhere
stop_connecting
store_forward
store_forward_config
store_forward_enabled

View File

@@ -1432,6 +1432,7 @@
<string name="status_message">Status Message</string>
<string name="status_message_config">Status Message Config</string>
<string name="stay_connected_anywhere">Stay Connected Anywhere</string>
<string name="stop_connecting">Stop Connecting</string>
<string name="store_forward">Store &amp; Forward</string>
<string name="store_forward_config">Store &amp; Forward Config</string>
<string name="store_forward_enabled">Store &amp; Forward enabled</string>

View File

@@ -37,9 +37,11 @@ import org.meshtastic.core.resources.Res
import org.meshtastic.core.resources.connected
import org.meshtastic.core.resources.connected_sleeping
import org.meshtastic.core.resources.connecting
import org.meshtastic.core.resources.disconnect
import org.meshtastic.core.resources.must_set_region
import org.meshtastic.core.resources.not_connected
import org.meshtastic.core.resources.reconnecting
import org.meshtastic.core.resources.stop_connecting
import org.meshtastic.core.ui.viewmodel.ConnectionStatus
/**
@@ -65,6 +67,21 @@ fun ConnectingDeviceInfo(
ConnectionStatus.NOT_CONNECTED -> stringResource(Res.string.not_connected)
}
// This card also renders when the transport is already CONNECTED but node info hasn't arrived yet
// (or the region needs setting), so only the not-yet-established states get "Stop Connecting".
val disconnectLabel =
when (connectionStatus) {
ConnectionStatus.CONNECTED,
ConnectionStatus.CONNECTED_SLEEPING,
ConnectionStatus.MUST_SET_REGION,
-> stringResource(Res.string.disconnect)
ConnectionStatus.CONNECTING,
ConnectionStatus.RECONNECTING,
ConnectionStatus.NOT_CONNECTED,
-> stringResource(Res.string.stop_connecting)
}
Column(modifier = modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
Row(
modifier = Modifier.fillMaxWidth(),
@@ -84,6 +101,6 @@ fun ConnectingDeviceInfo(
}
}
DisconnectButton(onClick = onClickDisconnect)
DisconnectButton(onClick = onClickDisconnect, label = disconnectLabel)
}
}

View File

@@ -32,13 +32,18 @@ import org.meshtastic.core.resources.disconnect
* Centralises the color/label so every call site stays in lock-step.
*/
@Composable
fun DisconnectButton(onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true) {
fun DisconnectButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
label: String = stringResource(Res.string.disconnect),
) {
OutlinedButton(
modifier = modifier.fillMaxWidth(),
colors = ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.error),
enabled = enabled,
onClick = onClick,
) {
Text(stringResource(Res.string.disconnect))
Text(label)
}
}

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 28 KiB