mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-07-02 09:26:01 -04:00
fix(connections): label the connecting-card button "Stop Connecting" (#6046)
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1
.skills/compose-ui/strings-index.txt
generated
1
.skills/compose-ui/strings-index.txt
generated
@@ -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
|
||||
|
||||
@@ -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 & Forward</string>
|
||||
<string name="store_forward_config">Store & Forward Config</string>
|
||||
<string name="store_forward_enabled">Store & Forward enabled</string>
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
Reference in New Issue
Block a user