Here lies "currentTab was used multiple times"

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
Secozzi 2024-10-31 12:42:05 +01:00
parent 9863bdc631
commit 111db99aff
No known key found for this signature in database
GPG key ID: DD93E0B3A962AA86
21 changed files with 118 additions and 77 deletions

View file

@ -25,7 +25,7 @@ enum class NavStyle(
MOVE_MANGA_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_manga, moreTab = MangaLibraryTab), MOVE_MANGA_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_manga, moreTab = MangaLibraryTab),
MOVE_UPDATES_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_updates, moreTab = UpdatesTab), MOVE_UPDATES_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_updates, moreTab = UpdatesTab),
MOVE_HISTORY_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_history, moreTab = HistoriesTab), MOVE_HISTORY_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_history, moreTab = HistoriesTab),
MOVE_BROWSE_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_browse, moreTab = BrowseTab()), MOVE_BROWSE_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_browse, moreTab = BrowseTab),
; ;
val moreIcon: ImageVector val moreIcon: ImageVector
@ -44,7 +44,7 @@ enum class NavStyle(
MangaLibraryTab, MangaLibraryTab,
UpdatesTab, UpdatesTab,
HistoriesTab, HistoriesTab,
BrowseTab(), BrowseTab,
MoreTab, MoreTab,
).apply { remove(this@NavStyle.moreTab) } ).apply { remove(this@NavStyle.moreTab) }
} }

View file

@ -14,5 +14,5 @@ enum class StartScreen(val titleRes: StringResource, val tab: Tab) {
MANGA(MR.strings.manga, MangaLibraryTab), MANGA(MR.strings.manga, MangaLibraryTab),
UPDATES(MR.strings.label_recent_updates, UpdatesTab), UPDATES(MR.strings.label_recent_updates, UpdatesTab),
HISTORY(MR.strings.label_recent_manga, HistoriesTab), HISTORY(MR.strings.label_recent_manga, HistoriesTab),
BROWSE(MR.strings.browse, BrowseTab()), BROWSE(MR.strings.browse, BrowseTab),
} }

View file

@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.PrimaryTabRow import androidx.compose.material3.PrimaryTabRow
@ -36,7 +37,7 @@ fun TabbedScreen(
titleRes: StringResource?, titleRes: StringResource?,
tabs: ImmutableList<TabContent>, tabs: ImmutableList<TabContent>,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
startIndex: Int? = null, state: PagerState = rememberPagerState { tabs.size },
mangaSearchQuery: String? = null, mangaSearchQuery: String? = null,
onChangeMangaSearchQuery: (String?) -> Unit = {}, onChangeMangaSearchQuery: (String?) -> Unit = {},
scrollable: Boolean = false, scrollable: Boolean = false,
@ -45,15 +46,8 @@ fun TabbedScreen(
) { ) {
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val state = rememberPagerState { tabs.size }
val snackbarHostState = remember { SnackbarHostState() } val snackbarHostState = remember { SnackbarHostState() }
LaunchedEffect(startIndex) {
if (startIndex != null) {
state.scrollToPage(startIndex)
}
}
Scaffold( Scaffold(
topBar = { topBar = {
if (titleRes != null) { if (titleRes != null) {

View file

@ -295,7 +295,7 @@ object SettingsDataScreen : SearchableSettings {
title = stringResource(MR.strings.label_storage), title = stringResource(MR.strings.label_storage),
icon = Icons.Outlined.Storage, icon = Icons.Outlined.Storage,
onClick = { onClick = {
navigator.push(StorageTab()) navigator.push(StorageTab)
}, },
), ),

View file

@ -103,7 +103,7 @@ object SettingsLibraryScreen : SearchableSettings {
count = userAnimeCategoriesCount, count = userAnimeCategoriesCount,
userAnimeCategoriesCount, userAnimeCategoriesCount,
), ),
onClick = { navigator.push(CategoriesTab(false)) }, onClick = { navigator.push(CategoriesTab) },
), ),
Preference.PreferenceItem.ListPreference( Preference.PreferenceItem.ListPreference(
pref = libraryPreferences.defaultAnimeCategory(), pref = libraryPreferences.defaultAnimeCategory(),
@ -117,7 +117,10 @@ object SettingsLibraryScreen : SearchableSettings {
count = userCategoriesCount, count = userCategoriesCount,
userCategoriesCount, userCategoriesCount,
), ),
onClick = { navigator.push(CategoriesTab(true)) }, onClick = {
navigator.push(CategoriesTab)
CategoriesTab.showMangaCategory()
},
), ),
Preference.PreferenceItem.ListPreference( Preference.PreferenceItem.ListPreference(
pref = libraryPreferences.defaultMangaCategory(), pref = libraryPreferences.defaultMangaCategory(),

View file

@ -36,10 +36,8 @@ val LocalBackPress: ProvidableCompositionLocal<(() -> Unit)?> = staticCompositio
private val uiPreferences: UiPreferences = Injekt.get() private val uiPreferences: UiPreferences = Injekt.get()
abstract class Tab : cafe.adriel.voyager.navigator.tab.Tab { interface Tab : cafe.adriel.voyager.navigator.tab.Tab {
suspend fun onReselect(navigator: Navigator) {}
override val key: ScreenKey = uniqueScreenKey
open suspend fun onReselect(navigator: Navigator) {}
@Composable @Composable
fun currentNavigationStyle(): NavStyle = uiPreferences.navStyle().collectAsState().value fun currentNavigationStyle(): NavStyle = uiPreferences.navStyle().collectAsState().value

View file

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.browse
import androidx.compose.animation.graphics.res.animatedVectorResource import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
import androidx.compose.animation.graphics.vector.AnimatedImageVector import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
@ -26,12 +27,14 @@ import eu.kanade.tachiyomi.ui.browse.manga.migration.sources.migrateMangaSourceT
import eu.kanade.tachiyomi.ui.browse.manga.source.mangaSourcesTab import eu.kanade.tachiyomi.ui.browse.manga.source.mangaSourcesTab
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.receiveAsFlow
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
data class BrowseTab( data object BrowseTab : Tab {
private val toExtensions: Boolean = false,
) : Tab() {
override val options: TabOptions override val options: TabOptions
@Composable @Composable
@ -50,6 +53,12 @@ data class BrowseTab(
navigator.push(GlobalAnimeSearchScreen()) navigator.push(GlobalAnimeSearchScreen())
} }
private val switchToExtensionTabChannel = Channel<Unit>(1, BufferOverflow.DROP_OLDEST)
fun showExtension() {
switchToExtensionTabChannel.trySend(Unit)
}
@Composable @Composable
override fun Content() { override fun Content() {
val context = LocalContext.current val context = LocalContext.current
@ -61,23 +70,31 @@ data class BrowseTab(
val animeExtensionsScreenModel = rememberScreenModel { AnimeExtensionsScreenModel() } val animeExtensionsScreenModel = rememberScreenModel { AnimeExtensionsScreenModel() }
val animeExtensionsState by animeExtensionsScreenModel.state.collectAsState() val animeExtensionsState by animeExtensionsScreenModel.state.collectAsState()
TabbedScreen( val tabs = persistentListOf(
titleRes = MR.strings.browse,
tabs = persistentListOf(
animeSourcesTab(), animeSourcesTab(),
mangaSourcesTab(), mangaSourcesTab(),
animeExtensionsTab(animeExtensionsScreenModel), animeExtensionsTab(animeExtensionsScreenModel),
mangaExtensionsTab(mangaExtensionsScreenModel), mangaExtensionsTab(mangaExtensionsScreenModel),
migrateAnimeSourceTab(), migrateAnimeSourceTab(),
migrateMangaSourceTab(), migrateMangaSourceTab(),
), )
startIndex = 2.takeIf { toExtensions },
val state = rememberPagerState { tabs.size }
TabbedScreen(
titleRes = MR.strings.browse,
tabs = tabs,
state = state,
mangaSearchQuery = mangaExtensionsState.searchQuery, mangaSearchQuery = mangaExtensionsState.searchQuery,
onChangeMangaSearchQuery = mangaExtensionsScreenModel::search, onChangeMangaSearchQuery = mangaExtensionsScreenModel::search,
animeSearchQuery = animeExtensionsState.searchQuery, animeSearchQuery = animeExtensionsState.searchQuery,
onChangeAnimeSearchQuery = animeExtensionsScreenModel::search, onChangeAnimeSearchQuery = animeExtensionsScreenModel::search,
scrollable = true, scrollable = true,
) )
LaunchedEffect(Unit) {
switchToExtensionTabChannel.receiveAsFlow()
.collectLatest { state.scrollToPage(1) }
}
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
(context as? MainActivity)?.ready = true (context as? MainActivity)?.ready = true

View file

@ -291,7 +291,7 @@ data class BrowseAnimeSourceScreen(
ChangeCategoryDialog( ChangeCategoryDialog(
initialSelection = dialog.initialSelection, initialSelection = dialog.initialSelection,
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
onEditCategories = { navigator.push(CategoriesTab(false)) }, onEditCategories = { navigator.push(CategoriesTab) },
onConfirm = { include, _ -> onConfirm = { include, _ ->
screenModel.changeAnimeFavorite(dialog.anime) screenModel.changeAnimeFavorite(dialog.anime)
screenModel.moveAnimeToCategories(dialog.anime, include) screenModel.moveAnimeToCategories(dialog.anime, include)

View file

@ -291,7 +291,10 @@ data class BrowseMangaSourceScreen(
ChangeCategoryDialog( ChangeCategoryDialog(
initialSelection = dialog.initialSelection, initialSelection = dialog.initialSelection,
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
onEditCategories = { navigator.push(CategoriesTab(true)) }, onEditCategories = {
navigator.push(CategoriesTab)
CategoriesTab.showMangaCategory()
},
onConfirm = { include, _ -> onConfirm = { include, _ ->
screenModel.changeMangaFavorite(dialog.manga) screenModel.changeMangaFavorite(dialog.manga)
screenModel.moveMangaToCategories(dialog.manga, include) screenModel.moveMangaToCategories(dialog.manga, include)

View file

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.category
import androidx.compose.animation.graphics.res.animatedVectorResource import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
import androidx.compose.animation.graphics.vector.AnimatedImageVector import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@ -21,13 +22,14 @@ import eu.kanade.tachiyomi.ui.category.manga.mangaCategoryTab
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.receiveAsFlow
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
data class CategoriesTab( data object CategoriesTab : Tab {
private val isManga: Boolean = false,
) : Tab() {
override val options: TabOptions override val options: TabOptions
@Composable @Composable
@ -41,6 +43,12 @@ data class CategoriesTab(
) )
} }
private val switchToMangaCategoryTabChannel = Channel<Unit>(1, BufferOverflow.DROP_OLDEST)
fun showMangaCategory() {
switchToMangaCategoryTabChannel.trySend(Unit)
}
@Composable @Composable
override fun Content() { override fun Content() {
val context = LocalContext.current val context = LocalContext.current
@ -48,15 +56,23 @@ data class CategoriesTab(
val animeCategoryScreenModel = rememberScreenModel { AnimeCategoryScreenModel() } val animeCategoryScreenModel = rememberScreenModel { AnimeCategoryScreenModel() }
val mangaCategoryScreenModel = rememberScreenModel { MangaCategoryScreenModel() } val mangaCategoryScreenModel = rememberScreenModel { MangaCategoryScreenModel() }
TabbedScreen( val tabs = persistentListOf(
titleRes = MR.strings.general_categories,
tabs = persistentListOf(
animeCategoryTab(), animeCategoryTab(),
mangaCategoryTab(), mangaCategoryTab(),
),
startIndex = 1.takeIf { isManga },
) )
val state = rememberPagerState { tabs.size }
TabbedScreen(
titleRes = MR.strings.general_categories,
tabs = tabs,
state = state,
)
LaunchedEffect(Unit) {
switchToMangaCategoryTabChannel.receiveAsFlow()
.collectLatest { state.scrollToPage(1) }
}
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
(context as? MainActivity)?.ready = true (context as? MainActivity)?.ready = true
} }

View file

@ -74,9 +74,7 @@ import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.components.material.TabText import tachiyomi.presentation.core.components.material.TabText
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
data class DownloadsTab( data object DownloadsTab : Tab {
private val isManga: Boolean = false,
) : Tab() {
override val options: TabOptions override val options: TabOptions
@Composable @Composable

View file

@ -208,7 +208,7 @@ class AnimeScreen(
ChangeCategoryDialog( ChangeCategoryDialog(
initialSelection = dialog.initialSelection, initialSelection = dialog.initialSelection,
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
onEditCategories = { navigator.push(CategoriesTab(false)) }, onEditCategories = { navigator.push(CategoriesTab) },
onConfirm = { include, _ -> onConfirm = { include, _ ->
screenModel.moveAnimeToCategoriesAndAddToLibrary(dialog.anime, include) screenModel.moveAnimeToCategoriesAndAddToLibrary(dialog.anime, include)
}, },

View file

@ -189,7 +189,10 @@ class MangaScreen(
ChangeCategoryDialog( ChangeCategoryDialog(
initialSelection = dialog.initialSelection, initialSelection = dialog.initialSelection,
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
onEditCategories = { navigator.push(CategoriesTab(true)) }, onEditCategories = {
navigator.push(CategoriesTab)
CategoriesTab.showMangaCategory()
},
onConfirm = { include, _ -> onConfirm = { include, _ ->
screenModel.moveMangaToCategoriesAndAddToLibrary(dialog.manga, include) screenModel.moveMangaToCategoriesAndAddToLibrary(dialog.manga, include)
}, },

View file

@ -26,7 +26,7 @@ import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
object HistoriesTab : Tab() { data object HistoriesTab : Tab {
override val options: TabOptions override val options: TabOptions
@Composable @Composable

View file

@ -173,7 +173,12 @@ object HomeScreen : Screen() {
is Tab.Library -> MangaLibraryTab is Tab.Library -> MangaLibraryTab
is Tab.Updates -> UpdatesTab is Tab.Updates -> UpdatesTab
is Tab.History -> HistoriesTab is Tab.History -> HistoriesTab
is Tab.Browse -> BrowseTab(it.toExtensions) is Tab.Browse -> {
if (it.toExtensions) {
BrowseTab.showExtension()
}
BrowseTab
}
is Tab.More -> MoreTab is Tab.More -> MoreTab
} }
@ -184,7 +189,7 @@ object HomeScreen : Screen() {
navigator.push(MangaScreen(it.mangaIdToOpen)) navigator.push(MangaScreen(it.mangaIdToOpen))
} }
if (it is Tab.More && it.toDownloads) { if (it is Tab.More && it.toDownloads) {
navigator.push(DownloadsTab()) navigator.push(DownloadsTab)
} }
} }
} }

View file

@ -65,7 +65,7 @@ import tachiyomi.presentation.core.screens.LoadingScreen
import tachiyomi.source.local.entries.anime.isLocal import tachiyomi.source.local.entries.anime.isLocal
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
object AnimeLibraryTab : Tab() { data object AnimeLibraryTab : Tab {
@OptIn(ExperimentalAnimationGraphicsApi::class) @OptIn(ExperimentalAnimationGraphicsApi::class)
override val options: TabOptions override val options: TabOptions
@ -252,7 +252,7 @@ object AnimeLibraryTab : Tab() {
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
onEditCategories = { onEditCategories = {
screenModel.clearSelection() screenModel.clearSelection()
navigator.push(CategoriesTab(false)) navigator.push(CategoriesTab)
}, },
onConfirm = { include, exclude -> onConfirm = { include, exclude ->
screenModel.clearSelection() screenModel.clearSelection()

View file

@ -64,7 +64,7 @@ import tachiyomi.presentation.core.screens.EmptyScreenAction
import tachiyomi.presentation.core.screens.LoadingScreen import tachiyomi.presentation.core.screens.LoadingScreen
import tachiyomi.source.local.entries.manga.isLocal import tachiyomi.source.local.entries.manga.isLocal
object MangaLibraryTab : Tab() { data object MangaLibraryTab : Tab {
@OptIn(ExperimentalAnimationGraphicsApi::class) @OptIn(ExperimentalAnimationGraphicsApi::class)
override val options: TabOptions override val options: TabOptions
@ -272,7 +272,8 @@ object MangaLibraryTab : Tab() {
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
onEditCategories = { onEditCategories = {
screenModel.clearSelection() screenModel.clearSelection()
navigator.push(CategoriesTab(true)) navigator.push(CategoriesTab)
CategoriesTab.showMangaCategory()
}, },
onConfirm = { include, exclude -> onConfirm = { include, exclude ->
screenModel.clearSelection() screenModel.clearSelection()

View file

@ -40,7 +40,7 @@ import tachiyomi.presentation.core.i18n.stringResource
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
object MoreTab : Tab() { data object MoreTab : Tab {
override val options: TabOptions override val options: TabOptions
@Composable @Composable
@ -74,10 +74,10 @@ object MoreTab : Tab() {
isFDroid = context.isInstalledFromFDroid(), isFDroid = context.isInstalledFromFDroid(),
navStyle = navStyle, navStyle = navStyle,
onClickAlt = { navigator.push(navStyle.moreTab) }, onClickAlt = { navigator.push(navStyle.moreTab) },
onClickDownloadQueue = { navigator.push(DownloadsTab()) }, onClickDownloadQueue = { navigator.push(DownloadsTab) },
onClickCategories = { navigator.push(CategoriesTab()) }, onClickCategories = { navigator.push(CategoriesTab) },
onClickStats = { navigator.push(StatsTab()) }, onClickStats = { navigator.push(StatsTab) },
onClickStorage = { navigator.push(StorageTab()) }, onClickStorage = { navigator.push(StorageTab) },
onClickDataAndStorage = { navigator.push(SettingsScreen(SettingsScreen.Destination.DataAndStorage)) }, onClickDataAndStorage = { navigator.push(SettingsScreen(SettingsScreen.Destination.DataAndStorage)) },
onClickSettings = { navigator.push(SettingsScreen()) }, onClickSettings = { navigator.push(SettingsScreen()) },
onClickAbout = { navigator.push(SettingsScreen(SettingsScreen.Destination.About)) }, onClickAbout = { navigator.push(SettingsScreen(SettingsScreen.Destination.About)) },

View file

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.stats
import androidx.compose.animation.graphics.res.animatedVectorResource import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
import androidx.compose.animation.graphics.vector.AnimatedImageVector import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@ -18,9 +19,7 @@ import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
data class StatsTab( data object StatsTab : Tab {
private val isManga: Boolean = false,
) : Tab() {
override val options: TabOptions override val options: TabOptions
@Composable @Composable
@ -38,14 +37,16 @@ data class StatsTab(
override fun Content() { override fun Content() {
val context = LocalContext.current val context = LocalContext.current
TabbedScreen( val tabs = persistentListOf(
titleRes = MR.strings.label_stats,
tabs = persistentListOf(
animeStatsTab(), animeStatsTab(),
mangaStatsTab(), mangaStatsTab(),
), )
startIndex = 1.takeIf { isManga }, val state = rememberPagerState { tabs.size }
TabbedScreen(
titleRes = MR.strings.label_stats,
tabs = tabs,
state = state,
) )
LaunchedEffect(Unit) { LaunchedEffect(Unit) {

View file

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.storage
import androidx.compose.animation.graphics.res.animatedVectorResource import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
import androidx.compose.animation.graphics.vector.AnimatedImageVector import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@ -18,9 +19,7 @@ import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
data class StorageTab( data object StorageTab : Tab {
private val isManga: Boolean = false,
) : Tab() {
override val options: TabOptions override val options: TabOptions
@Composable @Composable
@ -38,13 +37,16 @@ data class StorageTab(
override fun Content() { override fun Content() {
val context = LocalContext.current val context = LocalContext.current
TabbedScreen( val tabs = persistentListOf(
titleRes = MR.strings.label_storage,
tabs = persistentListOf(
animeStorageTab(), animeStorageTab(),
mangaStorageTab(), mangaStorageTab(),
), )
startIndex = 1.takeIf { isManga }, val state = rememberPagerState { tabs.size }
TabbedScreen(
titleRes = MR.strings.label_storage,
tabs = tabs,
state = state,
) )
LaunchedEffect(Unit) { LaunchedEffect(Unit) {

View file

@ -21,7 +21,7 @@ import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
object UpdatesTab : Tab() { data object UpdatesTab : Tab {
override val options: TabOptions override val options: TabOptions
@Composable @Composable
@ -41,7 +41,7 @@ object UpdatesTab : Tab() {
) )
} }
override suspend fun onReselect(navigator: Navigator) { override suspend fun onReselect(navigator: Navigator) {
navigator.push(DownloadsTab()) navigator.push(DownloadsTab)
} }
@Composable @Composable