Always show trackers action in MangaScreen

Goes to tracker settings to log in if none are set up.
This commit is contained in:
arkon 2023-12-10 11:58:20 -05:00
parent 47e544b710
commit 3a0b3de175
7 changed files with 45 additions and 46 deletions
app/src/main/java/eu/kanade

View File

@ -96,7 +96,7 @@ fun MangaScreen(
onAddToLibraryClicked: () -> Unit, onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?, onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?, onTrackingClicked: () -> Unit,
// For tags menu // For tags menu
onTagSearch: (String) -> Unit, onTagSearch: (String) -> Unit,
@ -229,7 +229,7 @@ private fun MangaScreenSmallImpl(
onAddToLibraryClicked: () -> Unit, onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?, onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?, onTrackingClicked: () -> Unit,
// For tags menu // For tags menu
onTagSearch: (String) -> Unit, onTagSearch: (String) -> Unit,
@ -481,7 +481,7 @@ fun MangaScreenLargeImpl(
onAddToLibraryClicked: () -> Unit, onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?, onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?, onTrackingClicked: () -> Unit,
// For tags menu // For tags menu
onTagSearch: (String) -> Unit, onTagSearch: (String) -> Unit,

View File

@ -169,7 +169,7 @@ fun MangaActionRow(
onAddToLibraryClicked: () -> Unit, onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?, onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?, onTrackingClicked: () -> Unit,
onEditIntervalClicked: (() -> Unit)?, onEditIntervalClicked: (() -> Unit)?,
onEditCategory: (() -> Unit)?, onEditCategory: (() -> Unit)?,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
@ -200,7 +200,6 @@ fun MangaActionRow(
onClick = onEditIntervalClicked, onClick = onEditIntervalClicked,
) )
} }
if (onTrackingClicked != null) {
MangaActionButton( MangaActionButton(
title = if (trackingCount == 0) { title = if (trackingCount == 0) {
stringResource(MR.strings.manga_tracking_tab) stringResource(MR.strings.manga_tracking_tab)
@ -211,7 +210,6 @@ fun MangaActionRow(
color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary, color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary,
onClick = onTrackingClicked, onClick = onTrackingClicked,
) )
}
if (onWebViewClicked != null) { if (onWebViewClicked != null) {
MangaActionButton( MangaActionButton(
title = stringResource(MR.strings.action_web_view), title = stringResource(MR.strings.action_web_view),

View File

@ -47,6 +47,7 @@ import eu.kanade.tachiyomi.ui.category.CategoryScreen
import eu.kanade.tachiyomi.ui.home.HomeScreen import eu.kanade.tachiyomi.ui.home.HomeScreen
import eu.kanade.tachiyomi.ui.manga.track.TrackInfoDialogHomeScreen import eu.kanade.tachiyomi.ui.manga.track.TrackInfoDialogHomeScreen
import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.setting.SettingsScreen
import eu.kanade.tachiyomi.ui.webview.WebViewScreen import eu.kanade.tachiyomi.ui.webview.WebViewScreen
import eu.kanade.tachiyomi.util.system.copyToClipboard import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.system.toShareIntent import eu.kanade.tachiyomi.util.system.toShareIntent
@ -130,7 +131,13 @@ class MangaScreen(
screenModel.source, screenModel.source,
) )
}.takeIf { isHttpSource }, }.takeIf { isHttpSource },
onTrackingClicked = screenModel::showTrackDialog.takeIf { successState.trackingAvailable }, onTrackingClicked = {
if (successState.trackingCount == 0) {
navigator.push(SettingsScreen(SettingsScreen.Destination.Tracking))
} else {
screenModel.showTrackDialog()
}
},
onTagSearch = { scope.launch { performGenreSearch(navigator, it, screenModel.source!!) } }, onTagSearch = { scope.launch { performGenreSearch(navigator, it, screenModel.source!!) } },
onFilterButtonClicked = screenModel::showSettingsDialog, onFilterButtonClicked = screenModel::showSettingsDialog,
onRefresh = screenModel::fetchAllFromSource, onRefresh = screenModel::fetchAllFromSource,

View File

@ -1090,9 +1090,6 @@ class MangaScreenModel(
val filterActive: Boolean val filterActive: Boolean
get() = scanlatorFilterActive || manga.chaptersFiltered() get() = scanlatorFilterActive || manga.chaptersFiltered()
val trackingAvailable: Boolean
get() = trackItems.isNotEmpty()
val trackingCount: Int val trackingCount: Int
get() = trackItems.count { it.track != null } get() = trackItems.count { it.track != null }

View File

@ -53,7 +53,7 @@ object MoreTab : Tab {
} }
override suspend fun onReselect(navigator: Navigator) { override suspend fun onReselect(navigator: Navigator) {
navigator.push(SettingsScreen.toMainScreen()) navigator.push(SettingsScreen())
} }
@Composable @Composable
@ -72,9 +72,9 @@ object MoreTab : Tab {
onClickDownloadQueue = { navigator.push(DownloadQueueScreen) }, onClickDownloadQueue = { navigator.push(DownloadQueueScreen) },
onClickCategories = { navigator.push(CategoryScreen()) }, onClickCategories = { navigator.push(CategoryScreen()) },
onClickStats = { navigator.push(StatsScreen()) }, onClickStats = { navigator.push(StatsScreen()) },
onClickDataAndStorage = { navigator.push(SettingsScreen.toDataAndStorageScreen()) }, onClickDataAndStorage = { navigator.push(SettingsScreen(SettingsScreen.Destination.DataAndStorage)) },
onClickSettings = { navigator.push(SettingsScreen.toMainScreen()) }, onClickSettings = { navigator.push(SettingsScreen()) },
onClickAbout = { navigator.push(SettingsScreen.toAboutScreen()) }, onClickAbout = { navigator.push(SettingsScreen(SettingsScreen.Destination.About)) },
) )
} }
} }

View File

@ -34,7 +34,7 @@ class OnboardingScreen : Screen() {
onComplete = { finishOnboarding() }, onComplete = { finishOnboarding() },
onRestoreBackup = { onRestoreBackup = {
finishOnboarding() finishOnboarding()
navigator.push(SettingsScreen.toDataAndStorageScreen()) navigator.push(SettingsScreen(SettingsScreen.Destination.DataAndStorage))
}, },
) )
} }

View File

@ -15,6 +15,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.presentation.more.settings.screen.SettingsAppearanceScreen import eu.kanade.presentation.more.settings.screen.SettingsAppearanceScreen
import eu.kanade.presentation.more.settings.screen.SettingsDataScreen import eu.kanade.presentation.more.settings.screen.SettingsDataScreen
import eu.kanade.presentation.more.settings.screen.SettingsMainScreen import eu.kanade.presentation.more.settings.screen.SettingsMainScreen
import eu.kanade.presentation.more.settings.screen.SettingsTrackingScreen
import eu.kanade.presentation.more.settings.screen.about.AboutScreen import eu.kanade.presentation.more.settings.screen.about.AboutScreen
import eu.kanade.presentation.util.DefaultNavigatorScreenTransition import eu.kanade.presentation.util.DefaultNavigatorScreenTransition
import eu.kanade.presentation.util.LocalBackPress import eu.kanade.presentation.util.LocalBackPress
@ -22,9 +23,8 @@ import eu.kanade.presentation.util.Screen
import eu.kanade.presentation.util.isTabletUi import eu.kanade.presentation.util.isTabletUi
import tachiyomi.presentation.core.components.TwoPanelBox import tachiyomi.presentation.core.components.TwoPanelBox
class SettingsScreen private constructor( class SettingsScreen(
val toDataAndStorage: Boolean, private val destination: Destination = Destination.Main,
val toAbout: Boolean,
) : Screen() { ) : Screen() {
@Composable @Composable
@ -32,12 +32,11 @@ class SettingsScreen private constructor(
val parentNavigator = LocalNavigator.currentOrThrow val parentNavigator = LocalNavigator.currentOrThrow
if (!isTabletUi()) { if (!isTabletUi()) {
Navigator( Navigator(
screen = if (toDataAndStorage) { screen = when (destination) {
SettingsDataScreen Destination.Main -> SettingsMainScreen
} else if (toAbout) { Destination.About -> AboutScreen
AboutScreen Destination.DataAndStorage -> SettingsDataScreen
} else { Destination.Tracking -> SettingsTrackingScreen
SettingsMainScreen
}, },
content = { content = {
val pop: () -> Unit = { val pop: () -> Unit = {
@ -54,12 +53,11 @@ class SettingsScreen private constructor(
) )
} else { } else {
Navigator( Navigator(
screen = if (toDataAndStorage) { screen = when (destination) {
SettingsDataScreen Destination.Main -> SettingsAppearanceScreen
} else if (toAbout) { Destination.About -> AboutScreen
AboutScreen Destination.DataAndStorage -> SettingsDataScreen
} else { Destination.Tracking -> SettingsTrackingScreen
SettingsAppearanceScreen
}, },
) { ) {
val insets = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal) val insets = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal)
@ -78,11 +76,10 @@ class SettingsScreen private constructor(
} }
} }
companion object { sealed interface Destination {
fun toMainScreen() = SettingsScreen(toDataAndStorage = false, toAbout = false) data object Main : Destination
data object About : Destination
fun toDataAndStorageScreen() = SettingsScreen(toDataAndStorage = true, toAbout = false) data object DataAndStorage : Destination
data object Tracking : Destination
fun toAboutScreen() = SettingsScreen(toDataAndStorage = false, toAbout = true)
} }
} }