@@ -21,6 +21,7 @@ import android.net.InetAddresses
2121import android.os.Build
2222import android.util.Patterns
2323import androidx.compose.animation.AnimatedVisibility
24+ import androidx.compose.foundation.layout.Arrangement
2425import androidx.compose.foundation.layout.Box
2526import androidx.compose.foundation.layout.Column
2627import androidx.compose.foundation.layout.IntrinsicSize
@@ -34,6 +35,8 @@ import androidx.compose.foundation.rememberScrollState
3435import androidx.compose.foundation.selection.selectable
3536import androidx.compose.foundation.selection.selectableGroup
3637import androidx.compose.foundation.verticalScroll
38+ import androidx.compose.material.icons.Icons
39+ import androidx.compose.material.icons.rounded.Language
3740import androidx.compose.material3.MaterialTheme
3841import androidx.compose.material3.Surface
3942import androidx.compose.material3.Text
@@ -61,15 +64,18 @@ import com.geeksville.mesh.model.BTScanModel
6164import com.geeksville.mesh.model.BluetoothViewModel
6265import com.geeksville.mesh.model.DeviceListEntry
6366import com.geeksville.mesh.model.Node
67+ import com.geeksville.mesh.navigation.ConfigRoute
6468import com.geeksville.mesh.navigation.Route
6569import com.geeksville.mesh.navigation.SettingsRoutes
6670import com.geeksville.mesh.navigation.getNavRouteFrom
6771import com.geeksville.mesh.service.ConnectionState
72+ import com.geeksville.mesh.ui.common.components.TitledCard
6873import com.geeksville.mesh.ui.connections.components.BLEDevices
6974import com.geeksville.mesh.ui.connections.components.ConnectionsSegmentedBar
7075import com.geeksville.mesh.ui.connections.components.CurrentlyConnectedCard
7176import com.geeksville.mesh.ui.connections.components.NetworkDevices
7277import com.geeksville.mesh.ui.connections.components.UsbDevices
78+ import com.geeksville.mesh.ui.settings.components.SettingsItem
7379import com.geeksville.mesh.ui.settings.radio.RadioConfigViewModel
7480import com.geeksville.mesh.ui.settings.radio.components.PacketResponseStateDialog
7581import com.geeksville.mesh.ui.sharing.SharedContactDialog
@@ -101,7 +107,6 @@ fun ConnectionsScreen(
101107) {
102108 val radioConfigState by radioConfigViewModel.radioConfigState.collectAsStateWithLifecycle()
103109 val config by connectionsViewModel.localConfig.collectAsStateWithLifecycle()
104- val currentRegion = config.lora.region
105110 val scrollState = rememberScrollState()
106111 val scanStatusText by scanModel.errorText.observeAsState(" " )
107112 val connectionState by
@@ -111,8 +116,7 @@ fun ConnectionsScreen(
111116 val info by connectionsViewModel.myNodeInfo.collectAsStateWithLifecycle()
112117 val selectedDevice by scanModel.selectedNotNullFlow.collectAsStateWithLifecycle()
113118 val bluetoothEnabled by bluetoothViewModel.enabled.collectAsStateWithLifecycle(false )
114- val regionUnset =
115- currentRegion == ConfigProtos .Config .LoRaConfig .RegionCode .UNSET && connectionState == ConnectionState .CONNECTED
119+ val regionUnset = config.lora.region == ConfigProtos .Config .LoRaConfig .RegionCode .UNSET
116120
117121 val bleDevices by scanModel.bleDevicesForUi.collectAsStateWithLifecycle()
118122 val discoveredTcpDevices by scanModel.discoveredTcpDevicesForUi.collectAsStateWithLifecycle()
@@ -186,7 +190,7 @@ fun ConnectionsScreen(
186190 visible = connectionState.isConnected(),
187191 modifier = Modifier .padding(bottom = 16 .dp),
188192 ) {
189- Column {
193+ Column (verticalArrangement = Arrangement .spacedBy( 16 .dp)) {
190194 ourNode?.let { node ->
191195 Text (
192196 stringResource(R .string.connected_device),
@@ -204,23 +208,20 @@ fun ConnectionsScreen(
204208 onClickDisconnect = { scanModel.disconnect() },
205209 )
206210 }
207- }
208- }
209211
210- /* val setRegionText = stringResource(id = R.string.set_your_region)
211- val actionText = stringResource(id = R.string.action_go)
212- LaunchedEffect(connectionState.isConnected() && regionUnset && selectedDevice != "m") {
213- if (connectionState.isConnected() && regionUnset && selectedDevice != "m") {
214- uiViewModel.showSnackBar(
215- text = setRegionText,
216- actionLabel = actionText,
217- onActionPerformed = {
218- isWaiting = true
219- radioConfigViewModel.setResponseStateLoading(ConfigRoute.LORA)
220- },
221- )
212+ if (regionUnset && selectedDevice != " m" ) {
213+ TitledCard (title = null ) {
214+ SettingsItem (
215+ leadingIcon = Icons .Rounded .Language ,
216+ text = stringResource(id = R .string.set_your_region),
217+ ) {
218+ isWaiting = true
219+ radioConfigViewModel.setResponseStateLoading(ConfigRoute .LORA )
220+ }
221+ }
222+ }
222223 }
223- }*/
224+ }
224225
225226 var selectedDeviceType by remember { mutableStateOf(DeviceType .BLE ) }
226227 LaunchedEffect (selectedDevice) {
0 commit comments