layout fix

CircularProgressIndicator was moved into the devices list.
This commit is contained in:
2023-09-28 21:55:35 +07:00
parent 415b5ef0d8
commit 0c949a9bda
3 changed files with 31 additions and 20 deletions

View File

@@ -93,11 +93,7 @@ class MainActivity : ComponentActivity() {
permissionLauncher.launch(permissionsToRequest) permissionLauncher.launch(permissionsToRequest)
} }
LaunchedEffect(key1 = bluetoothState.errorMessage) {
bluetoothState.errorMessage?.let { message ->
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
}
}
LaunchedEffect(key1 = bluetoothState) { LaunchedEffect(key1 = bluetoothState) {
if (bluetoothState.isConnected) { if (bluetoothState.isConnected) {
Toast.makeText(applicationContext, "Подключение завершено", Toast.LENGTH_LONG) Toast.makeText(applicationContext, "Подключение завершено", Toast.LENGTH_LONG)
@@ -106,6 +102,14 @@ class MainActivity : ComponentActivity() {
} }
val navController = rememberNavController() val navController = rememberNavController()
LaunchedEffect(key1 = bluetoothState.errorMessage) {
bluetoothState.errorMessage?.let { message ->
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
navController.navigate("scanner")
}
}
TestblueTheme { TestblueTheme {
Surface(color = MaterialTheme.colorScheme.background) { Surface(color = MaterialTheme.colorScheme.background) {
PermissionsRequest( PermissionsRequest(

View File

@@ -64,14 +64,6 @@ fun BluetoothScannerScreen(
} }
) )
if (bluetoothState.scannedDevices.isEmpty() && bluetoothState.isDiscovering) {
Box(
modifier = Modifier.fillMaxSize()
) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
}
Row( Row(
modifier = Modifier modifier = Modifier
.padding(5.dp) .padding(5.dp)

View File

@@ -1,12 +1,15 @@
package com.helible.pilot.components package com.helible.pilot.components
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
@@ -73,12 +76,24 @@ fun DiscoveredDevicesList(
) )
) )
} }
if(bluetoothState.pairedDevices.isEmpty() && !bluetoothState.isDiscovering) { if(bluetoothState.scannedDevices.isEmpty()) {
item { if(bluetoothState.isDiscovering) {
Text( item {
text = "Устройства поблизости не обнаружены.", Column(modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) {
modifier = Modifier.fillMaxSize() CircularProgressIndicator()
) Text(text = "Поиск устройств", modifier=Modifier.padding(10.dp))
}
}
} else {
item {
Text(
text = "Устройства поблизости не обнаружены",
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxSize()
.padding(10.dp)
)
}
} }
} }
} }