diff --git a/app/src/main/kotlin/com/hippo/ehviewer/Settings.kt b/app/src/main/kotlin/com/hippo/ehviewer/Settings.kt index 05cc33e18..47038ada4 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/Settings.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/Settings.kt @@ -107,6 +107,7 @@ object Settings : DataStorePreferences(null) { var favCloudCount by intPref("fav_cloud", 0).emitTo(_favFlow) val gallerySite = intPref("gallery_site_2", 0).observed { updateWhenGallerySiteChanges() } + val launchPage = intPref("launch_page_2", 0) val listMode = intPref("list_mode_2", 0) val detailSize = intPref("detail_size_2", 0) val thumbColumns = intPref("thumb_columns", 3) @@ -145,7 +146,6 @@ object Settings : DataStorePreferences(null) { var timeoutSpeed by intPref("timeout_speed_level", 6) var theme by intPref("theme_2", -1).observed { updateWhenThemeChanges() } var readCacheSize by intPref("read_cache_size_2", 640) - var launchPage by intPref("launch_page_2", 0) var commentThreshold by intPref("comment_threshold", -100) var hardwareBitmapThreshold by intPref("hardware_bitmap_threshold", 16384) var showComments by boolPref("show_gallery_comments", true) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/MainActivity.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/MainActivity.kt index 97ac08b8b..a971f0ead 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/MainActivity.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/MainActivity.kt @@ -173,9 +173,6 @@ private val navItems = arrayOf>( Triple(SettingsScreenDestination, R.string.settings, Icons.Default.Settings), ) -val StartDestination - get() = navItems[Settings.launchPage].first - class MainActivity : EhActivity() { private var shareUrl: String? = null @@ -359,6 +356,7 @@ class MainActivity : EhActivity() { val density = LocalDensity.current val adaptiveInfo = currentWindowAdaptiveInfo() val needSignIn by Settings.needSignIn.collectAsState() + val launchPage by Settings.launchPage.collectAsState() CompositionLocalProvider( LocalNavDrawerState provides navDrawerState, LocalSideSheetState provides sideSheetState, @@ -443,7 +441,7 @@ class MainActivity : EhActivity() { CompositionLocalProvider(LocalSharedTransitionScope provides this) { val start = when { needSignIn -> SignInScreenDestination - hasNetwork -> StartDestination + hasNetwork -> navItems[launchPage].first else -> DownloadsScreenDestination } DestinationsNavHost( diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/EhScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/EhScreen.kt index 4dd895a81..3e0c9be01 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/EhScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/EhScreen.kt @@ -187,7 +187,7 @@ fun AnimatedVisibilityScope.EhScreen(navigator: DestinationsNavigator) = Screen( title = stringResource(id = R.string.settings_eh_launch_page), entry = R.array.launch_page_entries, entryValueRes = R.array.launch_page_entry_values, - value = Settings::launchPage.observed, + value = Settings.launchPage.asMutableState(), ) val listMode = Settings.listMode.asMutableState() SimpleMenuPreferenceInt(