Device screen was implemented

This commit is contained in:
2024-01-01 21:56:23 +07:00
parent d7f3bf386d
commit efa93ab912
28 changed files with 546 additions and 185 deletions

View File

@@ -57,24 +57,24 @@ class BluetoothViewModel(
it.copy(errorMessage = error)
}
}.launchIn(viewModelScope)
bluetoothController.isScanning.onEach { result ->
bluetoothController.isScanning.onEach { isDiscovering ->
_state.update {
it.copy(
isDiscovering = result,
isDiscovering = isDiscovering,
)
}
}.launchIn(viewModelScope)
bluetoothController.isEnabled.onEach { result ->
bluetoothController.isEnabled.onEach { isEnabled ->
_state.update {
it.copy(
isEnabled = result,
isEnabled = isEnabled,
)
}
}.launchIn(viewModelScope)
bluetoothController.isLocationEnabled.onEach { result ->
bluetoothController.isLocationEnabled.onEach { isLocationEnabled ->
_state.update {
it.copy(
isLocationEnabled = result
isLocationEnabled = isLocationEnabled
)
}
}.launchIn(viewModelScope)
@@ -123,6 +123,9 @@ class BluetoothViewModel(
private var deviceConnectionJob: Job? = null
fun connectToDevice(device: String) {
if(_state.value.isConnected) {
return
}
_state.update { it.copy(isConnecting = true) }
deviceConnectionJob = bluetoothController
.connectToDevice(device)