Skip to content

Commit

Permalink
prevent back navigation from login screen
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenheger committed Nov 1, 2024
1 parent 8e7bc43 commit 32fe6c1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
3 changes: 0 additions & 3 deletions driver-app/app/src/main/java/de/motis/prima/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ fun Home(
viewModel.logoutEvent.collect {
Log.d("Logout", "Logout event triggered.")
navController.navigate("login") {
popUpTo(navController.graph.startDestinationId) {
inclusive = true
}
launchSingleTop = true
}
}
Expand Down
8 changes: 8 additions & 0 deletions driver-app/app/src/main/java/de/motis/prima/Login.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.motis.prima

import android.app.Activity
import android.util.Log
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
Expand All @@ -25,6 +27,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.KeyboardType
Expand Down Expand Up @@ -81,6 +84,11 @@ fun Login(

val networkErrorMessage = stringResource(id = R.string.network_error_message)

val activity = (LocalContext.current as? Activity)
BackHandler {
activity?.finish()
}

LaunchedEffect(key1 = viewModel) {
// Catching successful login event and navigation to the next screen
launch {
Expand Down
3 changes: 0 additions & 3 deletions driver-app/app/src/main/java/de/motis/prima/Tours.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ fun Tours(
viewModel.logoutEvent.collect {
Log.d("Logout", "Logout event triggered.")
navController.navigate("login") {
popUpTo(navController.graph.startDestinationId) {
inclusive = true
}
launchSingleTop = true
}
}
Expand Down
3 changes: 0 additions & 3 deletions driver-app/app/src/main/java/de/motis/prima/Vehicles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ fun Vehicles(
viewModel.logoutEvent.collect {
Log.d("Logout", "Logout event triggered.")
navController.navigate("login") {
popUpTo(navController.graph.startDestinationId) {
inclusive = true
}
launchSingleTop = true
}
}
Expand Down

0 comments on commit 32fe6c1

Please sign in to comment.