From 3f7911235c595fe6925e8e22c0c64a368700066e Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 19 Feb 2023 11:09:41 -0500 Subject: [PATCH] Use unique keys for all screens to avoid crashes Fixes #9008 Fixes #9110 --- .../java/eu/kanade/core/navigation/Screen.kt | 12 ++++++++++++ .../presentation/components/AdaptiveSheet.kt | 2 +- .../more/settings/screen/AboutScreen.kt | 4 ++-- .../more/settings/screen/ClearDatabaseScreen.kt | 7 ++----- .../more/settings/screen/LicensesScreen.kt | 4 ++-- .../more/settings/screen/SettingsMainScreen.kt | 9 +++++---- .../more/settings/screen/SettingsSearchScreen.kt | 9 +++++---- .../more/settings/screen/WorkerInfoScreen.kt | 4 ++-- .../ui/browse/extension/ExtensionFilterScreen.kt | 4 ++-- .../extension/details/ExtensionDetailsScreen.kt | 4 ++-- .../extension/details/SourcePreferencesScreen.kt | 7 ++----- .../migration/manga/MigrationMangaScreen.kt | 4 ++-- .../migration/search/MigrateSearchScreen.kt | 4 ++-- .../migration/search/SourceSearchScreen.kt | 4 ++-- .../ui/browse/source/SourcesFilterScreen.kt | 4 ++-- .../browse/source/browse/BrowseSourceScreen.kt | 7 ++----- .../source/globalsearch/GlobalSearchScreen.kt | 7 ++----- .../tachiyomi/ui/category/CategoryScreen.kt | 7 ++----- .../tachiyomi/ui/download/DownloadQueueScreen.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/home/HomeScreen.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/manga/MangaScreen.kt | 7 ++----- .../tachiyomi/ui/manga/track/TrackInfoDialog.kt | 16 ++++++++-------- .../kanade/tachiyomi/ui/more/NewUpdateScreen.kt | 4 ++-- .../tachiyomi/ui/setting/SettingsScreen.kt | 4 ++-- .../eu/kanade/tachiyomi/ui/stats/StatsScreen.kt | 7 ++----- .../kanade/tachiyomi/ui/webview/WebViewScreen.kt | 7 ++----- 26 files changed, 73 insertions(+), 83 deletions(-) create mode 100644 app/src/main/java/eu/kanade/core/navigation/Screen.kt diff --git a/app/src/main/java/eu/kanade/core/navigation/Screen.kt b/app/src/main/java/eu/kanade/core/navigation/Screen.kt new file mode 100644 index 0000000000..0f0cac0da6 --- /dev/null +++ b/app/src/main/java/eu/kanade/core/navigation/Screen.kt @@ -0,0 +1,12 @@ +package eu.kanade.core.navigation + +import cafe.adriel.voyager.core.screen.ScreenKey +import cafe.adriel.voyager.core.screen.uniqueScreenKey +import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen + +// TODO: this prevents crashes in nested navigators with transitions not being disposed +// properly. Go back to using vanilla Voyager Screens once fixed upstream. +abstract class Screen : VoyagerScreen { + + override val key: ScreenKey = uniqueScreenKey +} diff --git a/app/src/main/java/eu/kanade/presentation/components/AdaptiveSheet.kt b/app/src/main/java/eu/kanade/presentation/components/AdaptiveSheet.kt index b349891a73..cb2a06102f 100644 --- a/app/src/main/java/eu/kanade/presentation/components/AdaptiveSheet.kt +++ b/app/src/main/java/eu/kanade/presentation/components/AdaptiveSheet.kt @@ -53,9 +53,9 @@ import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.Velocity import androidx.compose.ui.unit.dp import cafe.adriel.voyager.core.lifecycle.DisposableEffectIgnoringConfiguration -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.transitions.ScreenTransition +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.util.isTabletUi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collectLatest diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/AboutScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/AboutScreen.kt index 2a1d85af09..be0e9ed87c 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/AboutScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/AboutScreen.kt @@ -16,9 +16,9 @@ import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.domain.ui.UiPreferences import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.more.LogoHeader @@ -49,7 +49,7 @@ import java.text.SimpleDateFormat import java.util.Locale import java.util.TimeZone -object AboutScreen : Screen { +object AboutScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/ClearDatabaseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/ClearDatabaseScreen.kt index df9a1171bd..988b56aef9 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/ClearDatabaseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/ClearDatabaseScreen.kt @@ -30,10 +30,9 @@ import androidx.compose.ui.util.fastMap import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen -import cafe.adriel.voyager.core.screen.uniqueScreenKey import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.domain.source.interactor.GetSourcesWithNonLibraryManga import eu.kanade.presentation.browse.components.SourceIcon import eu.kanade.presentation.components.AppBar @@ -57,9 +56,7 @@ import tachiyomi.presentation.core.util.selectedBackground import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -class ClearDatabaseScreen : Screen { - - override val key = uniqueScreenKey +class ClearDatabaseScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/LicensesScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/LicensesScreen.kt index 6bf1297723..7ae37b3ea5 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/LicensesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/LicensesScreen.kt @@ -5,16 +5,16 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer import com.mikepenz.aboutlibraries.ui.compose.LibraryDefaults +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.components.AppBar import eu.kanade.tachiyomi.R import tachiyomi.presentation.core.components.material.Scaffold -class LicensesScreen : Screen { +class LicensesScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt index 49d3f0cf0b..8b3611d2be 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt @@ -41,10 +41,10 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.core.graphics.ColorUtils -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.AppBarActions import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget @@ -52,8 +52,9 @@ import eu.kanade.presentation.util.LocalBackPress import eu.kanade.tachiyomi.R import tachiyomi.presentation.core.components.LazyColumn import tachiyomi.presentation.core.components.material.Scaffold +import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen -object SettingsMainScreen : Screen { +object SettingsMainScreen : Screen() { @Composable override fun Content() { @@ -173,7 +174,7 @@ object SettingsMainScreen : Screen { ) } - private fun Navigator.navigate(screen: Screen, twoPane: Boolean) { + private fun Navigator.navigate(screen: VoyagerScreen, twoPane: Boolean) { if (twoPane) replaceAll(screen) else push(screen) } @@ -182,7 +183,7 @@ object SettingsMainScreen : Screen { @StringRes val subtitleRes: Int, val formatSubtitle: @Composable () -> String = { stringResource(subtitleRes) }, val icon: ImageVector, - val screen: Screen, + val screen: VoyagerScreen, ) private val items = listOf( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt index 0490495f07..5cde66936d 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt @@ -47,9 +47,9 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.more.settings.Preference import eu.kanade.tachiyomi.R @@ -57,8 +57,9 @@ import eu.kanade.tachiyomi.util.system.isLTR import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.util.runOnEnterKeyPressed +import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen -class SettingsSearchScreen : Screen { +class SettingsSearchScreen : Screen() { @Composable override fun Content() { @@ -297,12 +298,12 @@ private val settingScreens = listOf( private data class SettingsData( val title: String, - val route: Screen, + val route: VoyagerScreen, val contents: List, ) private data class SearchResultItem( - val route: Screen, + val route: VoyagerScreen, val title: String, val breadcrumbs: String, val highlightKey: String, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/WorkerInfoScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/WorkerInfoScreen.kt index eb652d0ae9..edd1e71322 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/WorkerInfoScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/WorkerInfoScreen.kt @@ -34,9 +34,9 @@ import androidx.work.WorkQuery import cafe.adriel.voyager.core.model.ScreenModel import cafe.adriel.voyager.core.model.coroutineScope import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.tachiyomi.R import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.map @@ -46,7 +46,7 @@ import tachiyomi.presentation.core.components.LazyColumn import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.util.plus -object WorkerInfoScreen : Screen { +object WorkerInfoScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterScreen.kt index a18e5a8903..1ec16ba28b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterScreen.kt @@ -6,16 +6,16 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.platform.LocalContext import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.browse.ExtensionFilterScreen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.flow.collectLatest import tachiyomi.presentation.core.components.LoadingScreen -class ExtensionFilterScreen : Screen { +class ExtensionFilterScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreen.kt index 355ca8dafd..2191d218d2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsScreen.kt @@ -7,16 +7,16 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalUriHandler import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.browse.ExtensionDetailsScreen import kotlinx.coroutines.flow.collectLatest import tachiyomi.presentation.core.components.LoadingScreen data class ExtensionDetailsScreen( private val pkgName: String, -) : Screen { +) : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesScreen.kt index f4c9ea37bd..e28d800304 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesScreen.kt @@ -35,10 +35,9 @@ import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceScreen import androidx.preference.forEach import androidx.preference.getOnBindEditTextListener -import cafe.adriel.voyager.core.screen.Screen -import cafe.adriel.voyager.core.screen.uniqueScreenKey import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.SharedPreferencesDataStore import eu.kanade.tachiyomi.source.ConfigurableSource @@ -49,9 +48,7 @@ import tachiyomi.presentation.core.components.material.Scaffold import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -class SourcePreferencesScreen(val sourceId: Long) : Screen { - - override val key = uniqueScreenKey +class SourcePreferencesScreen(val sourceId: Long) : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaScreen.kt index 5b14dab0ac..c6d634c17a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaScreen.kt @@ -6,9 +6,9 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.platform.LocalContext import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.browse.MigrateMangaScreen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.browse.migration.search.MigrateSearchScreen @@ -19,7 +19,7 @@ import tachiyomi.presentation.core.components.LoadingScreen data class MigrationMangaScreen( private val sourceId: Long, -) : Screen { +) : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt index baed936bb0..604a6e7fb8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt @@ -4,13 +4,13 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.browse.MigrateSearchScreen import eu.kanade.tachiyomi.ui.manga.MangaScreen -class MigrateSearchScreen(private val mangaId: Long) : Screen { +class MigrateSearchScreen(private val mangaId: Long) : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt index 3bef46ecf6..8189512e1a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt @@ -19,9 +19,9 @@ import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.paging.compose.collectAsLazyPagingItems import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.browse.BrowseSourceContent import eu.kanade.presentation.components.SearchToolbar import eu.kanade.tachiyomi.R @@ -41,7 +41,7 @@ data class SourceSearchScreen( private val oldManga: Manga, private val sourceId: Long, private val query: String?, -) : Screen { +) : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterScreen.kt index 02b574a87e..5bc5f7ce8b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterScreen.kt @@ -6,15 +6,15 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.platform.LocalContext import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.browse.SourcesFilterScreen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.toast import tachiyomi.presentation.core.components.LoadingScreen -class SourcesFilterScreen : Screen { +class SourcesFilterScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt index a1e6851604..b6da64329c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt @@ -34,10 +34,9 @@ import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.paging.compose.collectAsLazyPagingItems import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen -import cafe.adriel.voyager.core.screen.uniqueScreenKey import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.browse.BrowseSourceContent import eu.kanade.presentation.browse.MissingSourceScreen import eu.kanade.presentation.browse.components.BrowseSourceToolbar @@ -66,12 +65,10 @@ import tachiyomi.presentation.core.components.material.padding data class BrowseSourceScreen( private val sourceId: Long, private val listingQuery: String?, -) : Screen, AssistContentScreen { +) : Screen(), AssistContentScreen { private var assistUrl: String? = null - override val key = uniqueScreenKey - override fun onProvideAssistUrl() = assistUrl @Composable diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreen.kt index 368806bb21..ec5aabbee5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreen.kt @@ -4,10 +4,9 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen -import cafe.adriel.voyager.core.screen.uniqueScreenKey import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.browse.GlobalSearchScreen import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreen import eu.kanade.tachiyomi.ui.manga.MangaScreen @@ -15,9 +14,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaScreen class GlobalSearchScreen( val searchQuery: String = "", val extensionFilter: String = "", -) : Screen { - - override val key = uniqueScreenKey +) : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryScreen.kt index e115f2aca3..6b4437ebf5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryScreen.kt @@ -6,10 +6,9 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.platform.LocalContext import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen -import cafe.adriel.voyager.core.screen.uniqueScreenKey import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.category.CategoryScreen import eu.kanade.presentation.category.components.CategoryCreateDialog import eu.kanade.presentation.category.components.CategoryDeleteDialog @@ -18,9 +17,7 @@ import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.flow.collectLatest import tachiyomi.presentation.core.components.LoadingScreen -class CategoryScreen : Screen { - - override val key = uniqueScreenKey +class CategoryScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt index c8e82247ae..6a2836122e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt @@ -45,9 +45,9 @@ import androidx.core.view.updateLayoutParams import androidx.core.view.updatePadding import androidx.recyclerview.widget.LinearLayoutManager import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.OverflowMenu @@ -60,7 +60,7 @@ import tachiyomi.presentation.core.components.material.ExtendedFloatingActionBut import tachiyomi.presentation.core.components.material.Scaffold import kotlin.math.roundToInt -object DownloadQueueScreen : Screen { +object DownloadQueueScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt index 0fafc5a93f..e8b0591324 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt @@ -30,11 +30,11 @@ import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.util.fastForEach -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import cafe.adriel.voyager.navigator.tab.LocalTabNavigator import cafe.adriel.voyager.navigator.tab.TabNavigator +import eu.kanade.core.navigation.Screen import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.presentation.util.isTabletUi @@ -59,7 +59,7 @@ import tachiyomi.presentation.core.components.material.Scaffold import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -object HomeScreen : Screen { +object HomeScreen : Screen() { private val librarySearchEvent = Channel() private val openTabEvent = Channel() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt index d02eb80a8d..be9107dd5c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt @@ -17,11 +17,10 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalHapticFeedback import androidx.core.net.toUri import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen -import cafe.adriel.voyager.core.screen.uniqueScreenKey import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.domain.manga.model.hasCustomCover import eu.kanade.domain.manga.model.toSManga import eu.kanade.presentation.category.ChangeCategoryDialog @@ -60,12 +59,10 @@ import tachiyomi.presentation.core.components.LoadingScreen class MangaScreen( private val mangaId: Long, val fromSource: Boolean = false, -) : Screen, AssistContentScreen { +) : Screen(), AssistContentScreen { private var assistUrl: String? = null - override val key = uniqueScreenKey - override fun onProvideAssistUrl() = assistUrl @Composable diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackInfoDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackInfoDialog.kt index b8030fb7cf..5b3311d335 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackInfoDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackInfoDialog.kt @@ -32,10 +32,10 @@ import cafe.adriel.voyager.core.model.ScreenModel import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay import eu.kanade.domain.track.model.toDbTrack import eu.kanade.domain.track.model.toDomainTrack @@ -83,7 +83,7 @@ data class TrackInfoDialogHomeScreen( private val mangaId: Long, private val mangaTitle: String, private val sourceId: Long, -) : Screen { +) : Screen() { @Composable override fun Content() { @@ -265,7 +265,7 @@ data class TrackInfoDialogHomeScreen( private data class TrackStatusSelectorScreen( private val track: Track, private val serviceId: Long, -) : Screen { +) : Screen() { @Composable override fun Content() { @@ -314,7 +314,7 @@ private data class TrackStatusSelectorScreen( private data class TrackChapterSelectorScreen( private val track: Track, private val serviceId: Long, -) : Screen { +) : Screen() { @Composable override fun Content() { @@ -369,7 +369,7 @@ private data class TrackChapterSelectorScreen( private data class TrackScoreSelectorScreen( private val track: Track, private val serviceId: Long, -) : Screen { +) : Screen() { @Composable override fun Content() { @@ -420,7 +420,7 @@ private data class TrackDateSelectorScreen( private val track: Track, private val serviceId: Long, private val start: Boolean, -) : Screen { +) : Screen() { @Composable override fun Content() { @@ -514,7 +514,7 @@ private data class TrackDateRemoverScreen( private val track: Track, private val serviceId: Long, private val start: Boolean, -) : Screen { +) : Screen() { @Composable override fun Content() { @@ -597,7 +597,7 @@ data class TrackServiceSearchScreen( private val initialQuery: String, private val currentUrl: String?, private val serviceId: Long, -) : Screen { +) : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateScreen.kt index f634f38c3f..2ee4339fe4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateScreen.kt @@ -3,9 +3,9 @@ package eu.kanade.tachiyomi.ui.more import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalContext -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.more.NewUpdateScreen import eu.kanade.tachiyomi.data.updater.AppUpdateService import eu.kanade.tachiyomi.util.system.openInBrowser @@ -15,7 +15,7 @@ class NewUpdateScreen( private val changelogInfo: String, private val releaseLink: String, private val downloadLink: String, -) : Screen { +) : Screen() { @Composable override fun Content() { 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 0ded25b459..4be9b01faf 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 @@ -9,10 +9,10 @@ import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier -import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.more.settings.screen.AboutScreen import eu.kanade.presentation.more.settings.screen.SettingsBackupScreen import eu.kanade.presentation.more.settings.screen.SettingsGeneralScreen @@ -25,7 +25,7 @@ import tachiyomi.presentation.core.components.TwoPanelBox class SettingsScreen private constructor( val toBackup: Boolean, val toAbout: Boolean, -) : Screen { +) : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreen.kt index 4f264f2bbe..4d738745fd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreen.kt @@ -5,10 +5,9 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.res.stringResource import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen -import cafe.adriel.voyager.core.screen.uniqueScreenKey import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.more.stats.StatsScreenContent import eu.kanade.presentation.more.stats.StatsScreenState @@ -16,9 +15,7 @@ import eu.kanade.tachiyomi.R import tachiyomi.presentation.core.components.LoadingScreen import tachiyomi.presentation.core.components.material.Scaffold -class StatsScreen : Screen { - - override val key = uniqueScreenKey +class StatsScreen : Screen() { @Composable override fun Content() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewScreen.kt index 7ae6100c8f..8d4485ece2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewScreen.kt @@ -3,10 +3,9 @@ package eu.kanade.tachiyomi.ui.webview import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import cafe.adriel.voyager.core.model.rememberScreenModel -import cafe.adriel.voyager.core.screen.Screen -import cafe.adriel.voyager.core.screen.uniqueScreenKey import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.navigation.Screen import eu.kanade.presentation.util.AssistContentScreen import eu.kanade.presentation.webview.WebViewScreenContent @@ -14,12 +13,10 @@ class WebViewScreen( private val url: String, private val initialTitle: String? = null, private val sourceId: Long? = null, -) : Screen, AssistContentScreen { +) : Screen(), AssistContentScreen { private var assistUrl: String? = null - override val key = uniqueScreenKey - override fun onProvideAssistUrl() = assistUrl @Composable