mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-22 12:48:15 +03:00
fix(navigation): Bring back navigation options (#1300)
Co-authored-by: AbdallahMehiz <abdallahmehiz0@gmail.com>
This commit is contained in:
parent
e21beff4d3
commit
7e24066420
18 changed files with 180 additions and 114 deletions
|
@ -20,7 +20,7 @@ android {
|
|||
defaultConfig {
|
||||
applicationId = "xyz.jmir.tachiyomi.mi"
|
||||
|
||||
versionCode = 119
|
||||
versionCode = 120
|
||||
versionName = "0.15.2.1"
|
||||
|
||||
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
|
||||
|
|
|
@ -2,6 +2,8 @@ package eu.kanade.domain.ui
|
|||
|
||||
import android.os.Build
|
||||
import eu.kanade.domain.ui.model.AppTheme
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import eu.kanade.domain.ui.model.StartScreen
|
||||
import eu.kanade.domain.ui.model.TabletUiMode
|
||||
import eu.kanade.domain.ui.model.ThemeMode
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
|
@ -34,6 +36,10 @@ class UiPreferences(
|
|||
|
||||
fun tabletUiMode() = preferenceStore.getEnum("tablet_ui_mode", TabletUiMode.AUTOMATIC)
|
||||
|
||||
fun startScreen() = preferenceStore.getEnum("start_screen", StartScreen.ANIME)
|
||||
|
||||
fun navStyle() = preferenceStore.getEnum("bottom_rail_nav_style", NavStyle.MOVE_HISTORY_TO_MORE)
|
||||
|
||||
companion object {
|
||||
fun dateFormat(format: String): DateFormat = when (format) {
|
||||
"" -> DateFormat.getDateInstance(DateFormat.SHORT)
|
||||
|
|
48
app/src/main/java/eu/kanade/domain/ui/model/NavStyle.kt
Normal file
48
app/src/main/java/eu/kanade/domain/ui/model/NavStyle.kt
Normal file
|
@ -0,0 +1,48 @@
|
|||
package eu.kanade.domain.ui.model
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.CollectionsBookmark
|
||||
import androidx.compose.material.icons.outlined.History
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import eu.kanade.presentation.util.Tab
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.browse.BrowseTab
|
||||
import eu.kanade.tachiyomi.ui.history.HistoriesTab
|
||||
import eu.kanade.tachiyomi.ui.library.anime.AnimeLibraryTab
|
||||
import eu.kanade.tachiyomi.ui.library.manga.MangaLibraryTab
|
||||
import eu.kanade.tachiyomi.ui.more.MoreTab
|
||||
import eu.kanade.tachiyomi.ui.updates.UpdatesTab
|
||||
import tachiyomi.i18n.MR
|
||||
|
||||
enum class NavStyle(
|
||||
val titleRes: StringResource,
|
||||
val moreTab: Tab,
|
||||
) {
|
||||
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_HISTORY_TO_MORE(titleRes = MR.strings.pref_bottom_nav_no_history, moreTab = HistoriesTab),
|
||||
;
|
||||
|
||||
val moreIcon: ImageVector
|
||||
@Composable
|
||||
get() = when (this) {
|
||||
MOVE_MANGA_TO_MORE -> Icons.Outlined.CollectionsBookmark
|
||||
MOVE_UPDATES_TO_MORE -> ImageVector.vectorResource(id = R.drawable.ic_updates_outline_24dp)
|
||||
MOVE_HISTORY_TO_MORE -> Icons.Outlined.History
|
||||
}
|
||||
|
||||
val tabs: List<Tab>
|
||||
get() {
|
||||
return mutableListOf(
|
||||
AnimeLibraryTab,
|
||||
MangaLibraryTab,
|
||||
UpdatesTab,
|
||||
HistoriesTab,
|
||||
BrowseTab(),
|
||||
MoreTab,
|
||||
).apply { remove(this@NavStyle.moreTab) }
|
||||
}
|
||||
}
|
18
app/src/main/java/eu/kanade/domain/ui/model/StartScreen.kt
Normal file
18
app/src/main/java/eu/kanade/domain/ui/model/StartScreen.kt
Normal file
|
@ -0,0 +1,18 @@
|
|||
package eu.kanade.domain.ui.model
|
||||
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import eu.kanade.presentation.util.Tab
|
||||
import eu.kanade.tachiyomi.ui.browse.BrowseTab
|
||||
import eu.kanade.tachiyomi.ui.history.HistoriesTab
|
||||
import eu.kanade.tachiyomi.ui.library.anime.AnimeLibraryTab
|
||||
import eu.kanade.tachiyomi.ui.library.manga.MangaLibraryTab
|
||||
import eu.kanade.tachiyomi.ui.updates.UpdatesTab
|
||||
import tachiyomi.i18n.MR
|
||||
|
||||
enum class StartScreen(val titleRes: StringResource, val tab: Tab) {
|
||||
ANIME(MR.strings.label_anime, AnimeLibraryTab),
|
||||
MANGA(MR.strings.manga, MangaLibraryTab),
|
||||
UPDATES(MR.strings.label_recent_updates, UpdatesTab),
|
||||
HISTORY(MR.strings.label_recent_manga, HistoriesTab),
|
||||
BROWSE(MR.strings.browse, BrowseTab()),
|
||||
}
|
|
@ -40,6 +40,7 @@ fun LibraryToolbar(
|
|||
searchQuery: String?,
|
||||
onSearchQueryChange: (String?) -> Unit,
|
||||
scrollBehavior: TopAppBarScrollBehavior?,
|
||||
navigateUp: (() -> Unit)? = null,
|
||||
) = when {
|
||||
selectedCount > 0 -> LibrarySelectionToolbar(
|
||||
selectedCount = selectedCount,
|
||||
|
@ -57,6 +58,7 @@ fun LibraryToolbar(
|
|||
onClickGlobalUpdate = onClickGlobalUpdate,
|
||||
onClickOpenRandomEntry = onClickOpenRandomEntry,
|
||||
scrollBehavior = scrollBehavior,
|
||||
navigateUp = navigateUp,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -71,6 +73,7 @@ private fun LibraryRegularToolbar(
|
|||
onClickGlobalUpdate: () -> Unit,
|
||||
onClickOpenRandomEntry: () -> Unit,
|
||||
scrollBehavior: TopAppBarScrollBehavior?,
|
||||
navigateUp: (() -> Unit)?,
|
||||
) {
|
||||
val pillAlpha = if (isSystemInDarkTheme()) 0.12f else 0.08f
|
||||
SearchToolbar(
|
||||
|
@ -119,6 +122,7 @@ private fun LibraryRegularToolbar(
|
|||
)
|
||||
},
|
||||
scrollBehavior = scrollBehavior,
|
||||
navigateUp = navigateUp,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,7 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
|
||||
import androidx.compose.material.icons.automirrored.outlined.Label
|
||||
import androidx.compose.material.icons.outlined.CloudOff
|
||||
import androidx.compose.material.icons.outlined.CollectionsBookmark
|
||||
import androidx.compose.material.icons.outlined.GetApp
|
||||
import androidx.compose.material.icons.outlined.History
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.outlined.QueryStats
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
|
@ -25,19 +23,18 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import eu.kanade.presentation.components.WarningBanner
|
||||
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.core.Constants
|
||||
import eu.kanade.tachiyomi.ui.more.DownloadQueueState
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.pluralStringResource
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@Composable
|
||||
fun MoreScreen(
|
||||
|
@ -47,6 +44,7 @@ fun MoreScreen(
|
|||
incognitoMode: Boolean,
|
||||
onIncognitoModeChange: (Boolean) -> Unit,
|
||||
isFDroid: Boolean,
|
||||
navStyle: NavStyle,
|
||||
onClickAlt: () -> Unit,
|
||||
onClickDownloadQueue: () -> Unit,
|
||||
onClickCategories: () -> Unit,
|
||||
|
@ -107,23 +105,10 @@ fun MoreScreen(
|
|||
|
||||
item { HorizontalDivider() }
|
||||
|
||||
val libraryPreferences: LibraryPreferences by injectLazy()
|
||||
|
||||
item {
|
||||
val bottomNavStyle = libraryPreferences.bottomNavStyle().get()
|
||||
val titleRes = when (bottomNavStyle) {
|
||||
0 -> MR.strings.label_recent_manga
|
||||
1 -> MR.strings.label_recent_updates
|
||||
else -> MR.strings.label_manga
|
||||
}
|
||||
val icon = when (bottomNavStyle) {
|
||||
0 -> Icons.Outlined.History
|
||||
1 -> ImageVector.vectorResource(id = R.drawable.ic_updates_outline_24dp)
|
||||
else -> Icons.Outlined.CollectionsBookmark
|
||||
}
|
||||
TextPreferenceWidget(
|
||||
title = stringResource(titleRes),
|
||||
icon = icon,
|
||||
title = navStyle.moreTab.options.title,
|
||||
icon = navStyle.moreIcon,
|
||||
onPreferenceClick = onClickAlt,
|
||||
)
|
||||
}
|
||||
|
@ -148,6 +133,7 @@ fun MoreScreen(
|
|||
}"
|
||||
}
|
||||
}
|
||||
|
||||
is DownloadQueueState.Downloading -> {
|
||||
val pending = downloadQueueState.pending
|
||||
pluralStringResource(
|
||||
|
|
|
@ -11,6 +11,8 @@ import androidx.core.app.ActivityCompat
|
|||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.domain.ui.UiPreferences
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import eu.kanade.domain.ui.model.StartScreen
|
||||
import eu.kanade.domain.ui.model.TabletUiMode
|
||||
import eu.kanade.domain.ui.model.ThemeMode
|
||||
import eu.kanade.domain.ui.model.setAppCompatDelegateThemeMode
|
||||
|
@ -126,6 +128,25 @@ object SettingsAppearanceScreen : SearchableSettings {
|
|||
true
|
||||
},
|
||||
),
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
pref = uiPreferences.startScreen(),
|
||||
title = stringResource(MR.strings.pref_start_screen),
|
||||
entries = StartScreen.entries
|
||||
.associateWith { stringResource(it.titleRes) }
|
||||
.toImmutableMap(),
|
||||
onValueChanged = {
|
||||
context.stringResource(MR.strings.requires_app_restart)
|
||||
true
|
||||
},
|
||||
),
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
pref = uiPreferences.navStyle(),
|
||||
title = "Navigation Style",
|
||||
entries = NavStyle.entries
|
||||
.associateWith { stringResource(it.titleRes) }
|
||||
.toImmutableMap(),
|
||||
onValueChanged = { true },
|
||||
),
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
pref = uiPreferences.dateFormat(),
|
||||
title = stringResource(MR.strings.pref_date_format),
|
||||
|
|
|
@ -16,6 +16,8 @@ import cafe.adriel.voyager.core.screen.uniqueScreenKey
|
|||
import cafe.adriel.voyager.core.stack.StackEvent
|
||||
import cafe.adriel.voyager.navigator.Navigator
|
||||
import cafe.adriel.voyager.transitions.ScreenTransitionContent
|
||||
import eu.kanade.domain.ui.UiPreferences
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import kotlinx.coroutines.CoroutineName
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -24,6 +26,9 @@ import kotlinx.coroutines.cancel
|
|||
import kotlinx.coroutines.plus
|
||||
import soup.compose.material.motion.animation.materialSharedAxisX
|
||||
import soup.compose.material.motion.animation.rememberSlideDistance
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* For invoking back press to the parent activity
|
||||
|
@ -31,10 +36,15 @@ import soup.compose.material.motion.animation.rememberSlideDistance
|
|||
@SuppressLint("ComposeCompositionLocalUsage")
|
||||
val LocalBackPress: ProvidableCompositionLocal<(() -> Unit)?> = staticCompositionLocalOf { null }
|
||||
|
||||
private val uiPreferences: UiPreferences = Injekt.get()
|
||||
|
||||
abstract class Tab : cafe.adriel.voyager.navigator.tab.Tab {
|
||||
|
||||
override val key: ScreenKey = uniqueScreenKey
|
||||
open suspend fun onReselect(navigator: Navigator) {}
|
||||
|
||||
@Composable
|
||||
fun currentNavigationStyle(): NavStyle = uiPreferences.navStyle().collectAsState().value
|
||||
}
|
||||
|
||||
abstract class Screen : Screen {
|
||||
|
|
|
@ -7,6 +7,8 @@ import androidx.preference.PreferenceManager
|
|||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.domain.ui.UiPreferences
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import eu.kanade.domain.ui.model.StartScreen
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
|
||||
import eu.kanade.tachiyomi.data.library.anime.AnimeLibraryUpdateJob
|
||||
|
@ -535,6 +537,26 @@ object Migrations {
|
|||
remove(Preference.appStateKey("trusted_signatures"))
|
||||
}
|
||||
}
|
||||
|
||||
if (oldVersion < 120) {
|
||||
val bottomNavStyle = preferenceStore.getInt("bottom_nav_style", 0)
|
||||
|
||||
val isDefaultTabManga = preferenceStore.getBoolean("default_home_tab_library", false)
|
||||
prefs.edit {
|
||||
remove("bottom_nav_style")
|
||||
remove("default_home_tab_library")
|
||||
|
||||
val startScreen = if (isDefaultTabManga.get()) StartScreen.MANGA else StartScreen.ANIME
|
||||
val navStyle = when (bottomNavStyle.get()) {
|
||||
0 -> NavStyle.MOVE_HISTORY_TO_MORE
|
||||
1 -> NavStyle.MOVE_UPDATES_TO_MORE
|
||||
else -> NavStyle.MOVE_MANGA_TO_MORE
|
||||
}
|
||||
|
||||
preferenceStore.getEnum("start_screen", StartScreen.ANIME).set(startScreen)
|
||||
preferenceStore.getEnum("bottom_rail_nav_style", NavStyle.MOVE_HISTORY_TO_MORE).set(navStyle)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
|
@ -12,6 +12,7 @@ import cafe.adriel.voyager.core.model.rememberScreenModel
|
|||
import cafe.adriel.voyager.navigator.Navigator
|
||||
import cafe.adriel.voyager.navigator.tab.LocalTabNavigator
|
||||
import cafe.adriel.voyager.navigator.tab.TabOptions
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import eu.kanade.presentation.components.TabbedScreen
|
||||
import eu.kanade.presentation.util.Tab
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -25,16 +26,17 @@ import kotlinx.collections.immutable.persistentListOf
|
|||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
||||
data class HistoriesTab(
|
||||
private val fromMore: Boolean,
|
||||
) : Tab() {
|
||||
object HistoriesTab : Tab() {
|
||||
|
||||
override val options: TabOptions
|
||||
@Composable
|
||||
get() {
|
||||
val isSelected = LocalTabNavigator.current.current.key == key
|
||||
val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_history_enter)
|
||||
val index: UShort = if (fromMore) 5u else 2u
|
||||
val index: UShort = when (currentNavigationStyle()) {
|
||||
NavStyle.MOVE_HISTORY_TO_MORE -> 5u
|
||||
else -> 2u
|
||||
}
|
||||
return TabOptions(
|
||||
index = index,
|
||||
title = stringResource(MR.strings.history),
|
||||
|
@ -49,6 +51,7 @@ data class HistoriesTab(
|
|||
@Composable
|
||||
override fun Content() {
|
||||
val context = LocalContext.current
|
||||
val fromMore = currentNavigationStyle() == NavStyle.MOVE_HISTORY_TO_MORE
|
||||
// Hoisted for history tab's search bar
|
||||
val mangaHistoryScreenModel = rememberScreenModel { MangaHistoryScreenModel() }
|
||||
val mangaSearchQuery by mangaHistoryScreenModel.query.collectAsState()
|
||||
|
|
|
@ -35,6 +35,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow
|
|||
import cafe.adriel.voyager.navigator.tab.LocalTabNavigator
|
||||
import cafe.adriel.voyager.navigator.tab.TabNavigator
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.domain.ui.UiPreferences
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import eu.kanade.presentation.util.isTabletUi
|
||||
import eu.kanade.tachiyomi.ui.browse.BrowseTab
|
||||
|
@ -59,6 +60,7 @@ import tachiyomi.presentation.core.components.material.NavigationBar
|
|||
import tachiyomi.presentation.core.components.material.NavigationRail
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.pluralStringResource
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
@ -72,48 +74,13 @@ object HomeScreen : Screen() {
|
|||
private const val TabFadeDuration = 200
|
||||
private const val TabNavigatorKey = "HomeTabs"
|
||||
|
||||
private val libraryPreferences: LibraryPreferences by injectLazy()
|
||||
|
||||
val tabsNoHistory = listOf(
|
||||
AnimeLibraryTab,
|
||||
MangaLibraryTab,
|
||||
UpdatesTab(fromMore = false, inMiddle = true),
|
||||
BrowseTab(),
|
||||
MoreTab,
|
||||
)
|
||||
|
||||
val tabsNoUpdates = listOf(
|
||||
AnimeLibraryTab,
|
||||
MangaLibraryTab,
|
||||
HistoriesTab(false),
|
||||
BrowseTab(),
|
||||
MoreTab,
|
||||
)
|
||||
|
||||
val tabsNoManga = listOf(
|
||||
AnimeLibraryTab,
|
||||
UpdatesTab(fromMore = false, inMiddle = false),
|
||||
HistoriesTab(false),
|
||||
BrowseTab(),
|
||||
MoreTab,
|
||||
)
|
||||
|
||||
var tabs = when (libraryPreferences.bottomNavStyle().get()) {
|
||||
0 -> tabsNoHistory
|
||||
1 -> tabsNoUpdates
|
||||
else -> tabsNoManga
|
||||
}
|
||||
private val uiPreferences: UiPreferences by injectLazy()
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val navStyle by uiPreferences.navStyle().collectAsState()
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
val defaultTab = if (libraryPreferences.isDefaultHomeTabLibraryManga().get() &&
|
||||
libraryPreferences.bottomNavStyle().get() != 2
|
||||
) {
|
||||
MangaLibraryTab
|
||||
} else {
|
||||
AnimeLibraryTab
|
||||
}
|
||||
val defaultTab = uiPreferences.startScreen().get().tab
|
||||
TabNavigator(
|
||||
tab = defaultTab,
|
||||
key = TabNavigatorKey,
|
||||
|
@ -124,7 +91,7 @@ object HomeScreen : Screen() {
|
|||
startBar = {
|
||||
if (isTabletUi()) {
|
||||
NavigationRail {
|
||||
tabs.fastForEach {
|
||||
navStyle.tabs.fastForEach {
|
||||
NavigationRailItem(it)
|
||||
}
|
||||
}
|
||||
|
@ -136,12 +103,12 @@ object HomeScreen : Screen() {
|
|||
showBottomNavEvent.receiveAsFlow().collectLatest { value = it }
|
||||
}
|
||||
AnimatedVisibility(
|
||||
visible = bottomNavVisible,
|
||||
visible = bottomNavVisible && tabNavigator.current != navStyle.moreTab,
|
||||
enter = expandVertically(),
|
||||
exit = shrinkVertically(),
|
||||
) {
|
||||
NavigationBar {
|
||||
tabs.fastForEach {
|
||||
navStyle.tabs.fastForEach {
|
||||
NavigationBarItem(it)
|
||||
}
|
||||
}
|
||||
|
@ -174,34 +141,31 @@ object HomeScreen : Screen() {
|
|||
}
|
||||
}
|
||||
|
||||
val goToAnimelibTab = { tabNavigator.current = AnimeLibraryTab }
|
||||
val goToAnimeLibTab = { tabNavigator.current = AnimeLibraryTab }
|
||||
BackHandler(
|
||||
enabled = tabNavigator.current != AnimeLibraryTab,
|
||||
onBack = goToAnimelibTab,
|
||||
onBack = goToAnimeLibTab,
|
||||
)
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
launch {
|
||||
librarySearchEvent.receiveAsFlow().collectLatest {
|
||||
goToAnimelibTab()
|
||||
goToAnimeLibTab()
|
||||
AnimeLibraryTab.search(it)
|
||||
}
|
||||
}
|
||||
launch {
|
||||
openTabEvent.receiveAsFlow().collectLatest {
|
||||
tabNavigator.current = when (it) {
|
||||
is Tab.Animelib -> AnimeLibraryTab
|
||||
is Tab.AnimeLib -> AnimeLibraryTab
|
||||
is Tab.Library -> MangaLibraryTab
|
||||
is Tab.Updates -> UpdatesTab(
|
||||
libraryPreferences.bottomNavStyle().get() == 1,
|
||||
libraryPreferences.bottomNavStyle().get() == 0,
|
||||
)
|
||||
is Tab.History -> HistoriesTab(false)
|
||||
is Tab.Updates -> UpdatesTab
|
||||
is Tab.History -> HistoriesTab
|
||||
is Tab.Browse -> BrowseTab(it.toExtensions)
|
||||
is Tab.More -> MoreTab
|
||||
}
|
||||
|
||||
if (it is Tab.Animelib && it.animeIdToOpen != null) {
|
||||
if (it is Tab.AnimeLib && it.animeIdToOpen != null) {
|
||||
navigator.push(AnimeScreen(it.animeIdToOpen))
|
||||
}
|
||||
if (it is Tab.Library && it.mangaIdToOpen != null) {
|
||||
|
@ -348,7 +312,7 @@ object HomeScreen : Screen() {
|
|||
}
|
||||
|
||||
sealed interface Tab {
|
||||
data class Animelib(val animeIdToOpen: Long? = null) : Tab
|
||||
data class AnimeLib(val animeIdToOpen: Long? = null) : Tab
|
||||
data class Library(val mangaIdToOpen: Long? = null) : Tab
|
||||
data object Updates : Tab
|
||||
data object History : Tab
|
||||
|
|
|
@ -29,6 +29,7 @@ import cafe.adriel.voyager.navigator.Navigator
|
|||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import cafe.adriel.voyager.navigator.tab.LocalTabNavigator
|
||||
import cafe.adriel.voyager.navigator.tab.TabOptions
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import eu.kanade.presentation.category.components.ChangeCategoryDialog
|
||||
import eu.kanade.presentation.entries.components.LibraryBottomActionMenu
|
||||
import eu.kanade.presentation.library.DeleteLibraryEntryDialog
|
||||
|
@ -56,7 +57,6 @@ import tachiyomi.domain.category.model.Category
|
|||
import tachiyomi.domain.entries.anime.model.Anime
|
||||
import tachiyomi.domain.items.episode.model.Episode
|
||||
import tachiyomi.domain.library.anime.LibraryAnime
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
@ -68,13 +68,11 @@ import uy.kohesive.injekt.injectLazy
|
|||
|
||||
object AnimeLibraryTab : Tab() {
|
||||
|
||||
val libraryPreferences: LibraryPreferences by injectLazy()
|
||||
private val fromMore = libraryPreferences.bottomNavStyle().get() == 2
|
||||
|
||||
@OptIn(ExperimentalAnimationGraphicsApi::class)
|
||||
override val options: TabOptions
|
||||
@Composable
|
||||
get() {
|
||||
val fromMore = currentNavigationStyle() == NavStyle.MOVE_MANGA_TO_MORE
|
||||
val title = if (fromMore) {
|
||||
MR.strings.label_library
|
||||
} else {
|
||||
|
@ -124,7 +122,7 @@ object AnimeLibraryTab : Tab() {
|
|||
MainActivity.startPlayerActivity(context, episode.animeId, episode.id, extPlayer)
|
||||
}
|
||||
|
||||
val defaultTitle = if (fromMore) {
|
||||
val defaultTitle = if (currentNavigationStyle() == NavStyle.MOVE_MANGA_TO_MORE) {
|
||||
stringResource(MR.strings.label_library)
|
||||
} else {
|
||||
stringResource(
|
||||
|
|
|
@ -29,6 +29,7 @@ import cafe.adriel.voyager.navigator.Navigator
|
|||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import cafe.adriel.voyager.navigator.tab.LocalTabNavigator
|
||||
import cafe.adriel.voyager.navigator.tab.TabOptions
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import eu.kanade.presentation.category.components.ChangeCategoryDialog
|
||||
import eu.kanade.presentation.entries.components.LibraryBottomActionMenu
|
||||
import eu.kanade.presentation.library.DeleteLibraryEntryDialog
|
||||
|
@ -55,7 +56,6 @@ import tachiyomi.core.util.lang.launchIO
|
|||
import tachiyomi.domain.category.model.Category
|
||||
import tachiyomi.domain.entries.manga.model.Manga
|
||||
import tachiyomi.domain.library.manga.LibraryManga
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
@ -63,17 +63,14 @@ import tachiyomi.presentation.core.screens.EmptyScreen
|
|||
import tachiyomi.presentation.core.screens.EmptyScreenAction
|
||||
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||
import tachiyomi.source.local.entries.manga.isLocal
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
object MangaLibraryTab : Tab() {
|
||||
|
||||
val libraryPreferences: LibraryPreferences by injectLazy()
|
||||
private val fromMore = libraryPreferences.bottomNavStyle().get() == 2
|
||||
|
||||
@OptIn(ExperimentalAnimationGraphicsApi::class)
|
||||
override val options: TabOptions
|
||||
@Composable
|
||||
get() {
|
||||
val fromMore = currentNavigationStyle() == NavStyle.MOVE_MANGA_TO_MORE
|
||||
val title = if (fromMore) {
|
||||
MR.strings.label_library
|
||||
} else {
|
||||
|
@ -116,6 +113,8 @@ object MangaLibraryTab : Tab() {
|
|||
started
|
||||
}
|
||||
|
||||
val fromMore = currentNavigationStyle() == NavStyle.MOVE_MANGA_TO_MORE
|
||||
|
||||
val navigateUp: (() -> Unit)? = if (fromMore) navigator::pop else null
|
||||
|
||||
val defaultTitle = if (fromMore) {
|
||||
|
@ -167,6 +166,7 @@ object MangaLibraryTab : Tab() {
|
|||
searchQuery = state.searchQuery,
|
||||
onSearchQueryChange = screenModel::search,
|
||||
scrollBehavior = scrollBehavior.takeIf { !tabVisible }, // For scroll overlay when no tab
|
||||
navigateUp = navigateUp,
|
||||
)
|
||||
},
|
||||
bottomBar = {
|
||||
|
|
|
@ -455,7 +455,7 @@ class MainActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
val tabToOpen = when (intent.action) {
|
||||
Constants.SHORTCUT_ANIMELIB -> HomeScreen.Tab.Animelib()
|
||||
Constants.SHORTCUT_ANIMELIB -> HomeScreen.Tab.AnimeLib()
|
||||
Constants.SHORTCUT_LIBRARY -> HomeScreen.Tab.Library()
|
||||
Constants.SHORTCUT_MANGA -> {
|
||||
val idToOpen = intent.extras?.getLong(Constants.MANGA_EXTRA) ?: return false
|
||||
|
@ -465,7 +465,7 @@ class MainActivity : BaseActivity() {
|
|||
Constants.SHORTCUT_ANIME -> {
|
||||
val idToOpen = intent.extras?.getLong(Constants.ANIME_EXTRA) ?: return false
|
||||
navigator.popUntilRoot()
|
||||
HomeScreen.Tab.Animelib(idToOpen)
|
||||
HomeScreen.Tab.AnimeLib(idToOpen)
|
||||
}
|
||||
Constants.SHORTCUT_UPDATES -> HomeScreen.Tab.Updates
|
||||
Constants.SHORTCUT_HISTORY -> HomeScreen.Tab.History
|
||||
|
|
|
@ -25,12 +25,9 @@ import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadManager
|
|||
import eu.kanade.tachiyomi.data.download.manga.MangaDownloadManager
|
||||
import eu.kanade.tachiyomi.ui.category.CategoriesTab
|
||||
import eu.kanade.tachiyomi.ui.download.DownloadsTab
|
||||
import eu.kanade.tachiyomi.ui.history.HistoriesTab
|
||||
import eu.kanade.tachiyomi.ui.library.manga.MangaLibraryTab
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsScreen
|
||||
import eu.kanade.tachiyomi.ui.stats.StatsTab
|
||||
import eu.kanade.tachiyomi.ui.storage.StorageTab
|
||||
import eu.kanade.tachiyomi.ui.updates.UpdatesTab
|
||||
import eu.kanade.tachiyomi.util.system.isInstalledFromFDroid
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
@ -38,12 +35,10 @@ import kotlinx.coroutines.flow.asStateFlow
|
|||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import tachiyomi.core.util.lang.launchIO
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
object MoreTab : Tab() {
|
||||
|
||||
|
@ -69,6 +64,7 @@ object MoreTab : Tab() {
|
|||
val navigator = LocalNavigator.currentOrThrow
|
||||
val screenModel = rememberScreenModel { MoreScreenModel() }
|
||||
val downloadQueueState by screenModel.downloadQueueState.collectAsState()
|
||||
val navStyle = currentNavigationStyle()
|
||||
MoreScreen(
|
||||
downloadQueueStateProvider = { downloadQueueState },
|
||||
downloadedOnly = screenModel.downloadedOnly,
|
||||
|
@ -76,7 +72,8 @@ object MoreTab : Tab() {
|
|||
incognitoMode = screenModel.incognitoMode,
|
||||
onIncognitoModeChange = { screenModel.incognitoMode = it },
|
||||
isFDroid = context.isInstalledFromFDroid(),
|
||||
onClickAlt = { navigator.push(altOpen) },
|
||||
navStyle = navStyle,
|
||||
onClickAlt = { navigator.push(navStyle.moreTab) },
|
||||
onClickDownloadQueue = { navigator.push(DownloadsTab()) },
|
||||
onClickCategories = { navigator.push(CategoriesTab()) },
|
||||
onClickStats = { navigator.push(StatsTab()) },
|
||||
|
@ -88,14 +85,6 @@ object MoreTab : Tab() {
|
|||
}
|
||||
}
|
||||
|
||||
private val libraryPreferences: LibraryPreferences by injectLazy()
|
||||
|
||||
private val altOpen = when (libraryPreferences.bottomNavStyle().get()) {
|
||||
0 -> HistoriesTab(true)
|
||||
1 -> UpdatesTab(fromMore = true, inMiddle = false)
|
||||
else -> MangaLibraryTab
|
||||
}
|
||||
|
||||
private class MoreScreenModel(
|
||||
private val downloadManager: MangaDownloadManager = Injekt.get(),
|
||||
private val animeDownloadManager: AnimeDownloadManager = Injekt.get(),
|
||||
|
|
|
@ -9,6 +9,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import cafe.adriel.voyager.navigator.Navigator
|
||||
import cafe.adriel.voyager.navigator.tab.LocalTabNavigator
|
||||
import cafe.adriel.voyager.navigator.tab.TabOptions
|
||||
import eu.kanade.domain.ui.model.NavStyle
|
||||
import eu.kanade.presentation.components.TabbedScreen
|
||||
import eu.kanade.presentation.util.Tab
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -20,17 +21,18 @@ import kotlinx.collections.immutable.persistentListOf
|
|||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
||||
data class UpdatesTab(
|
||||
private val fromMore: Boolean,
|
||||
private val inMiddle: Boolean,
|
||||
) : Tab() {
|
||||
object UpdatesTab : Tab() {
|
||||
|
||||
override val options: TabOptions
|
||||
@Composable
|
||||
get() {
|
||||
val isSelected = LocalTabNavigator.current.current.key == key
|
||||
val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_updates_enter)
|
||||
val index: UShort = if (fromMore) 5u else if (inMiddle) 2u else 1u
|
||||
val index: UShort = when (currentNavigationStyle()) {
|
||||
NavStyle.MOVE_UPDATES_TO_MORE -> 5u
|
||||
NavStyle.MOVE_HISTORY_TO_MORE -> 2u
|
||||
NavStyle.MOVE_MANGA_TO_MORE -> 1u
|
||||
}
|
||||
return TabOptions(
|
||||
index = index,
|
||||
title = stringResource(MR.strings.label_recent_updates),
|
||||
|
@ -44,6 +46,7 @@ data class UpdatesTab(
|
|||
@Composable
|
||||
override fun Content() {
|
||||
val context = LocalContext.current
|
||||
val fromMore = currentNavigationStyle() == NavStyle.MOVE_UPDATES_TO_MORE
|
||||
|
||||
TabbedScreen(
|
||||
titleRes = MR.strings.label_recent_updates,
|
||||
|
|
|
@ -14,13 +14,6 @@ class LibraryPreferences(
|
|||
private val preferenceStore: PreferenceStore,
|
||||
) {
|
||||
|
||||
// Common options
|
||||
|
||||
fun bottomNavStyle() = preferenceStore.getInt("bottom_nav_style", 0)
|
||||
|
||||
fun isDefaultHomeTabLibraryManga() =
|
||||
preferenceStore.getBoolean("default_home_tab_library", false)
|
||||
|
||||
fun displayMode() = preferenceStore.getObject(
|
||||
"pref_display_mode_library",
|
||||
LibraryDisplayMode.default,
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<string name="label_anime_sources">Anime Sources</string>
|
||||
<string name="label_watched_duration">Watched duration</string>
|
||||
<string name="label_watched_episodes">Watched</string>
|
||||
<string name="pref_start_screen">Start Screen</string>
|
||||
<string name="pref_library_manga_columns">Manga items per row</string>
|
||||
<string name="pref_library_anime_columns">Anime items per row</string>
|
||||
<string name="pref_bottom_nav_no_history">Move History to the More tab</string>
|
||||
|
|
Loading…
Reference in a new issue