add readResolve for Screen & Tab

(might fix the issue key currentTab was used multiple times?)
This commit is contained in:
Tran M. Cuong 2024-06-17 01:11:29 +07:00
parent d7bc9d3021
commit 4ea29bbff6
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
8 changed files with 27 additions and 5 deletions

View file

@ -9,7 +9,6 @@ import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ChromeReaderMode
import androidx.compose.material.icons.outlined.ChromeReaderMode
import androidx.compose.material.icons.outlined.Code
import androidx.compose.material.icons.outlined.CollectionsBookmark
import androidx.compose.material.icons.outlined.Explore
@ -56,6 +55,8 @@ import tachiyomi.presentation.core.i18n.stringResource
import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen
object SettingsMainScreen : Screen() {
@Suppress("unused")
private fun readResolve(): Any = SettingsMainScreen
@Composable
override fun Content() {

View file

@ -58,8 +58,9 @@ import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
@Suppress("JavaIoSerializableObjectMustHaveReadResolve")
object AboutScreen : Screen() {
@Suppress("unused")
private fun readResolve(): Any = AboutScreen
@Composable
override fun Content() {

View file

@ -63,6 +63,8 @@ import tachiyomi.presentation.core.screens.EmptyScreen
import kotlin.math.roundToInt
object DownloadQueueScreen : Screen() {
@Suppress("unused")
private fun readResolve(): Any = DownloadQueueScreen
@Composable
override fun Content() {

View file

@ -39,6 +39,8 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object HistoryTab : Tab {
@Suppress("unused")
private fun readResolve(): Any = HistoryTab
private val snackbarHostState = SnackbarHostState()

View file

@ -65,6 +65,8 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object HomeScreen : Screen() {
@Suppress("unused")
private fun readResolve(): Any = HomeScreen
private val librarySearchEvent = Channel<String>()
private val openTabEvent = Channel<Tab>()
@ -148,6 +150,7 @@ object HomeScreen : Screen() {
materialFadeThroughOut(durationMillis = TabFadeDuration)
},
label = "tabContent",
contentKey = { it.key }
) {
tabNavigator.saveableState(key = "currentTab", it) {
it.Content()
@ -194,8 +197,10 @@ object HomeScreen : Screen() {
@Composable
private fun RowScope.NavigationBarItem(
tab: eu.kanade.presentation.util.Tab/* SY --> */,
alwaysShowLabel: Boolean, /* SY <-- */
tab: eu.kanade.presentation.util.Tab,
// SY -->
alwaysShowLabel: Boolean,
// SY <--
) {
val tabNavigator = LocalTabNavigator.current
val navigator = LocalNavigator.currentOrThrow
@ -224,7 +229,12 @@ object HomeScreen : Screen() {
}
@Composable
fun NavigationRailItem(tab: eu.kanade.presentation.util.Tab/* SY --> */, alwaysShowLabel: Boolean/* SY <-- */) {
fun NavigationRailItem(
tab: eu.kanade.presentation.util.Tab,
// SY -->
alwaysShowLabel: Boolean,
// SY <--
) {
val tabNavigator = LocalTabNavigator.current
val navigator = LocalNavigator.currentOrThrow
val scope = rememberCoroutineScope()

View file

@ -76,6 +76,8 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object LibraryTab : Tab {
@Suppress("unused")
private fun readResolve(): Any = LibraryTab
override val options: TabOptions
@Composable

View file

@ -43,6 +43,8 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object MoreTab : Tab {
@Suppress("unused")
private fun readResolve(): Any = MoreTab
override val options: TabOptions
@Composable

View file

@ -38,6 +38,8 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object UpdatesTab : Tab {
@Suppress("unused")
private fun readResolve(): Any = UpdatesTab
override val options: TabOptions
@Composable