From c10cd6c808786e896d16a82fce63b565c4e425af Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 17 Dec 2023 18:30:43 -0500 Subject: [PATCH] Prevent backing out from initial onboarding --- .../kanade/tachiyomi/ui/more/OnboardingScreen.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/OnboardingScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/OnboardingScreen.kt index 038df42ca..bc211445e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/OnboardingScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/OnboardingScreen.kt @@ -1,6 +1,8 @@ package eu.kanade.tachiyomi.ui.more +import androidx.activity.compose.BackHandler import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow @@ -8,6 +10,7 @@ import eu.kanade.domain.base.BasePreferences import eu.kanade.presentation.more.onboarding.OnboardingScreen import eu.kanade.presentation.util.Screen import eu.kanade.tachiyomi.ui.setting.SettingsScreen +import tachiyomi.presentation.core.util.collectAsState import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -18,14 +21,22 @@ class OnboardingScreen : Screen() { val navigator = LocalNavigator.currentOrThrow val basePreferences = remember { Injekt.get() } + val shownOnboardingFlow by basePreferences.shownOnboardingFlow().collectAsState() - val finishOnboarding = { + val finishOnboarding: () -> Unit = { basePreferences.shownOnboardingFlow().set(true) navigator.pop() } + BackHandler( + enabled = !shownOnboardingFlow, + onBack = { + // Prevent exiting if onboarding hasn't been completed + }, + ) + OnboardingScreen( - onComplete = { finishOnboarding() }, + onComplete = finishOnboarding, onRestoreBackup = { finishOnboarding() navigator.push(SettingsScreen(SettingsScreen.Destination.DataAndStorage))