فهرست منبع

Fix settings screen crashing when saving state

arkon 1 سال پیش
والد
کامیت
0d09039e5f
1فایلهای تغییر یافته به همراه15 افزوده شده و 14 حذف شده
  1. 15 14
      app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt

+ 15 - 14
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)
     }
 }