From 0d09039e5f0eb5d295c699ca4e6f160d7549e771 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 10 Dec 2023 17:29:02 -0500 Subject: [PATCH] Fix settings screen crashing when saving state --- .../tachiyomi/ui/setting/SettingsScreen.kt | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt index 5ac3e07166..3d396ace9a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt @@ -24,19 +24,21 @@ import eu.kanade.presentation.util.isTabletUi import tachiyomi.presentation.core.components.TwoPanelBox class SettingsScreen( - private val destination: Destination = Destination.Main, + private val destination: Int? = null, ) : Screen() { + constructor(destination: Destination) : this(destination.id) + @Composable override fun Content() { val parentNavigator = LocalNavigator.currentOrThrow if (!isTabletUi()) { Navigator( screen = when (destination) { - Destination.Main -> SettingsMainScreen - Destination.About -> AboutScreen - Destination.DataAndStorage -> SettingsDataScreen - Destination.Tracking -> SettingsTrackingScreen + Destination.About.id -> AboutScreen + Destination.DataAndStorage.id -> SettingsDataScreen + Destination.Tracking.id -> SettingsTrackingScreen + else -> SettingsMainScreen }, content = { val pop: () -> Unit = { @@ -54,10 +56,10 @@ class SettingsScreen( } else { Navigator( screen = when (destination) { - Destination.Main -> SettingsAppearanceScreen - Destination.About -> AboutScreen - Destination.DataAndStorage -> SettingsDataScreen - Destination.Tracking -> SettingsTrackingScreen + Destination.About.id -> AboutScreen + Destination.DataAndStorage.id -> SettingsDataScreen + Destination.Tracking.id -> SettingsTrackingScreen + else -> SettingsAppearanceScreen }, ) { val insets = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal) @@ -76,10 +78,9 @@ class SettingsScreen( } } - sealed interface Destination { - data object Main : Destination - data object About : Destination - data object DataAndStorage : Destination - data object Tracking : Destination + sealed class Destination(val id: Int) { + data object About : Destination(0) + data object DataAndStorage : Destination(1) + data object Tracking : Destination(2) } }