Apply fixes to navigation

This commit is contained in:
Sylwester Zieliński
2022-01-14 16:57:10 +01:00
parent 81a8918c0c
commit 8bc77aedcc
2 changed files with 7 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package no.nordicsemi.android.nrftoolbox
import android.app.Activity
import android.os.ParcelUuid
import android.util.Log
import androidx.activity.compose.BackHandler
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@@ -88,7 +89,10 @@ internal fun HomeScreen() {
when (val destination = destination.value) {
FinishDestination -> context.finish()
HomeDestination -> navController.navigateUp()
is ProfileDestination -> navController.navigate(destination.id.id)
is ProfileDestination -> {
navController.navigateUp()
navController.navigate(destination.id.id)
}
is ScannerDestination -> navController.navigate(destination.id.id)
}.exhaustive
}

View File

@@ -35,12 +35,12 @@ class HomeViewModel @Inject constructor(
fun navigateUp() {
val currentDestination = _destination.value
when (currentDestination) {
_destination.value = when (currentDestination) {
FinishDestination -> FinishDestination
HomeDestination -> FinishDestination
is ProfileDestination -> HomeDestination
is ScannerDestination -> HomeDestination
}.exhaustive
}
}
private fun onDeviceSelected(result: FindDeviceSuccessResult) {