Skip to content

Commit

Permalink
feat: J2K-ification (2/?)
Browse files Browse the repository at this point in the history
  • Loading branch information
Caio99BR committed Jul 2, 2024
1 parent b66530d commit b97758e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
39 changes: 5 additions & 34 deletions app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,12 @@ import eu.kanade.tachiyomi.ui.history.HistoryTab
import eu.kanade.tachiyomi.ui.library.LibraryTab
import eu.kanade.tachiyomi.ui.manga.MangaScreen
import eu.kanade.tachiyomi.ui.more.MoreTab
import eu.kanade.tachiyomi.ui.updates.UpdatesTab
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import soup.compose.material.motion.animation.materialFadeThroughIn
import soup.compose.material.motion.animation.materialFadeThroughOut
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.NavigationBar
import tachiyomi.presentation.core.components.material.NavigationRail
Expand All @@ -66,12 +63,11 @@ object HomeScreen : Screen() {
private val openTabEvent = Channel<Tab>()
private val showBottomNavEvent = Channel<Boolean>()

private const val TabFadeDuration = 200
private const val TabNavigatorKey = "HomeTabs"
private const val TAB_FADE_DURATION = 200
private const val TAB_NAVIGATION_KEY = "HomeTabs"

private val tabs = listOf(
LibraryTab,
UpdatesTab,
HistoryTab,
BrowseTab(),
MoreTab,
Expand All @@ -82,7 +78,7 @@ object HomeScreen : Screen() {
val navigator = LocalNavigator.currentOrThrow
TabNavigator(
tab = LibraryTab,
key = TabNavigatorKey,
key = TAB_NAVIGATION_KEY,
) { tabNavigator ->
// Provide usable navigator to content screen
CompositionLocalProvider(LocalNavigator provides navigator) {
Expand Down Expand Up @@ -124,8 +120,8 @@ object HomeScreen : Screen() {
AnimatedContent(
targetState = tabNavigator.current,
transitionSpec = {
materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) togetherWith
materialFadeThroughOut(durationMillis = TabFadeDuration)
materialFadeThroughIn(initialScale = 1f, durationMillis = TAB_FADE_DURATION) togetherWith
materialFadeThroughOut(durationMillis = TAB_FADE_DURATION)
},
label = "tabContent",
) {
Expand Down Expand Up @@ -154,7 +150,6 @@ object HomeScreen : Screen() {
openTabEvent.receiveAsFlow().collectLatest {
tabNavigator.current = when (it) {
is Tab.Library -> LibraryTab
Tab.Updates -> UpdatesTab
Tab.History -> HistoryTab
is Tab.Browse -> BrowseTab(it.toExtensions)
is Tab.More -> MoreTab
Expand Down Expand Up @@ -233,29 +228,6 @@ object HomeScreen : Screen() {
BadgedBox(
badge = {
when {
tab is UpdatesTab -> {
val count by produceState(initialValue = 0) {
val pref = Injekt.get<LibraryPreferences>()
combine(
pref.newShowUpdatesCount().changes(),
pref.newUpdatesCount().changes(),
) { show, count -> if (show) count else 0 }
.collectLatest { value = it }
}
if (count > 0) {
Badge {
val desc = pluralStringResource(
MR.plurals.notification_chapters_generic,
count = count,
count,
)
Text(
text = count.toString(),
modifier = Modifier.semantics { contentDescription = desc },
)
}
}
}
BrowseTab::class.isInstance(tab) -> {
val count by produceState(initialValue = 0) {
Injekt.get<SourcePreferences>().extensionUpdatesCount().changes()
Expand Down Expand Up @@ -301,7 +273,6 @@ object HomeScreen : Screen() {

sealed interface Tab {
data class Library(val mangaIdToOpen: Long? = null) : Tab
data object Updates : Tab
data object History : Tab
data class Browse(val toExtensions: Boolean = false) : Tab
data class More(val toDownloads: Boolean) : Tab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ class MainActivity : BaseActivity() {
navigator.popUntilRoot()
HomeScreen.Tab.Library(idToOpen)
}
Constants.SHORTCUT_UPDATES -> HomeScreen.Tab.Updates
Constants.SHORTCUT_HISTORY -> HomeScreen.Tab.History
Constants.SHORTCUT_SOURCES -> HomeScreen.Tab.Browse(false)
Constants.SHORTCUT_EXTENSIONS -> HomeScreen.Tab.Browse(true)
Expand Down

0 comments on commit b97758e

Please sign in to comment.