Fix back gesture from connection details skipping list

On phones, the Connections list and Connection Details share a single
ModalBottomSheet. System back was consumed by the sheet's default dismiss
handler, closing the sheet and returning to Dashboard. The in-app back
button just cleared selectedConnectionId, returning to the list.

Add a BackHandler that runs only while a connection is selected, matching
the in-app back button behavior. Swipe-to-dismiss remains unchanged.
This commit is contained in:
世界
2026-04-19 21:58:30 +08:00
parent 1b8f348fe1
commit dfe64c11d2

View File

@@ -8,6 +8,7 @@ import android.net.Uri
import android.net.VpnService import android.net.VpnService
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
@@ -1107,6 +1108,10 @@ class MainActivity :
} }
} }
BackHandler(enabled = selectedConnectionId != null) {
selectedConnectionId = null
}
ModalBottomSheet( ModalBottomSheet(
onDismissRequest = { onDismissRequest = {
showConnectionsSheet = false showConnectionsSheet = false