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

View file

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

View file

@ -169,7 +169,7 @@ fun MangaActionRow(
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?,
onTrackingClicked: () -> Unit,
onEditIntervalClicked: (() -> Unit)?,
onEditCategory: (() -> Unit)?,
modifier: Modifier = Modifier,
@ -200,18 +200,16 @@ fun MangaActionRow(
onClick = onEditIntervalClicked,
)
}
if (onTrackingClicked != null) {
MangaActionButton(
title = if (trackingCount == 0) {
stringResource(MR.strings.manga_tracking_tab)
} else {
pluralStringResource(MR.plurals.num_trackers, count = trackingCount, trackingCount)
},
icon = if (trackingCount == 0) Icons.Outlined.Sync else Icons.Outlined.Done,
color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary,
onClick = onTrackingClicked,
)
}
MangaActionButton(
title = if (trackingCount == 0) {
stringResource(MR.strings.manga_tracking_tab)
} else {
pluralStringResource(MR.plurals.num_trackers, count = trackingCount, trackingCount)
},
icon = if (trackingCount == 0) Icons.Outlined.Sync else Icons.Outlined.Done,
color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary,
onClick = onTrackingClicked,
)
if (onWebViewClicked != null) {
MangaActionButton(
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.manga.track.TrackInfoDialogHomeScreen
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.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.system.toShareIntent
@ -130,7 +131,13 @@ class MangaScreen(
screenModel.source,
)
}.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!!) } },
onFilterButtonClicked = screenModel::showSettingsDialog,
onRefresh = screenModel::fetchAllFromSource,

View file

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

View file

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

View file

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