Skip to content

Commit

Permalink
Merge pull request #4284 from knighthat/master
Browse files Browse the repository at this point in the history
#4271 return to previous screen when not on home screen
  • Loading branch information
fast4x authored Oct 29, 2024
2 parents 3b25bcd + 3423ca0 commit 8f1641a
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.ExperimentalTextApi
import androidx.lifecycle.Lifecycle
import androidx.media3.common.util.UnstableApi
import androidx.navigation.NavController
import it.fast4x.compose.persist.PersistMapCleanup
Expand Down Expand Up @@ -250,6 +251,14 @@ fun HomeScreen(
val context = LocalContext.current
var confirmCount by remember { mutableIntStateOf( 0 ) }
BackHandler {
// Prevent this from being applied when user is not on HomeScreen
if( NavRoutes.home.isNotHere( navController ) ) {
if ( navController.currentBackStackEntry?.lifecycle?.currentState == Lifecycle.State.RESUMED )
navController.popBackStack()

return@BackHandler
}

if( confirmCount == 0 ) {
SmartMessage(
// TODO: add this string to xml
Expand Down

0 comments on commit 8f1641a

Please sign in to comment.