From 41435cb7f67ce38b9959adfffb6daae15826ca12 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 14 Aug 2023 16:38:51 +0200 Subject: [PATCH] Fix behavior of back button when adding additional accounts --- .../feature/launcher/navigation/FeatureLauncherNavHost.kt | 3 ++- .../app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt index 1d9b2a51b..a5b78510f 100644 --- a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt @@ -16,6 +16,7 @@ import org.koin.compose.koinInject fun FeatureLauncherNavHost( navController: NavHostController, startDestination: String?, + onBack: () -> Unit, modifier: Modifier = Modifier, importSettingsLauncher: ImportSettingsLauncher = koinInject(), accountSetupFinishedLauncher: AccountSetupFinishedLauncher = koinInject(), @@ -30,7 +31,7 @@ fun FeatureLauncherNavHost( onImport = { importSettingsLauncher.launch() }, ) accountSetupRoute( - onBack = navController::popBackStack, + onBack = onBack, onFinish = { accountSetupFinishedLauncher.launch(it) }, ) } diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt index 2d0049148..0bafc94ec 100644 --- a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.safeDrawingPadding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.navigation.compose.rememberNavController +import app.k9mail.core.ui.compose.common.activity.LocalActivity import app.k9mail.core.ui.compose.designsystem.atom.Background import app.k9mail.core.ui.compose.theme.K9Theme import app.k9mail.feature.launcher.navigation.FeatureLauncherNavHost @@ -23,9 +24,12 @@ fun FeatureLauncherApp( .safeDrawingPadding() .then(modifier), ) { + val activity = LocalActivity.current + FeatureLauncherNavHost( navController = navController, startDestination = startDestination, + onBack = { activity.finish() }, ) } }