Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.hedvig.android.feature.insurances.navigation.insurancesCrossSellBotto
import com.hedvig.android.feature.login.navigation.LoginDestination
import com.hedvig.android.feature.payments.navigation.PaymentsDestination
import com.hedvig.android.feature.profile.navigation.ProfileDestination
import com.hedvig.android.feature.profile.navigation.destinationToExcludeFromSavingState
import com.hedvig.android.feature.profile.navigation.profileBottomNavPermittedDestinations
import com.hedvig.android.feature.travelcertificate.navigation.travelCertificateCrossSellBottomSheetPermittingDestinations
import com.hedvig.android.featureflags.FeatureManager
Expand Down Expand Up @@ -196,23 +197,28 @@ internal class HedvigAppState(
*/
fun navigateToLoggedIn() {
navController.navigate(RootGraph) {
restoreState = true
typedPopUpTo<LoginDestination> {
inclusive = true
}
}
}

fun navigateToLoggedOut() {

val isLoggingOutFromProfile = navController.currentDestination
?.typedHasRoute(destinationToExcludeFromSavingState) ?: false

for (entry in TopLevelGraph.entries) {
navController.typedClearBackStack(entry.destination)
}
navController.navigate(LoginDestination) {
typedPopUpTo<RootGraph> {
inclusive = true
saveState = !isLoggingOutFromProfile
}
}
}

val darkTheme: Boolean
@Composable
get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ internal sealed interface SettingsDestinations {
val profileBottomNavPermittedDestinations: List<KClass<out Destination>> = listOf(
ProfileDestinations.Eurobonus::class,
)

/*
* Not saving navigation state when explicitly logging out from Profile
*/
val destinationToExcludeFromSavingState: KClass<out Destination> = ProfileDestination.Profile::class

Loading