feat(app): 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 committed by Claudemirovsky
parent 6450eb775f
commit 922293bd87
No known key found for this signature in database
GPG key ID: 82AE76162407356E
9 changed files with 68 additions and 68 deletions

View file

@ -112,7 +112,7 @@ fun AnimeScreen(
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?,
onTrackingClicked: () -> Unit,
// For tags menu
onTagSearch: (String) -> Unit,
@ -262,7 +262,7 @@ private fun AnimeScreenSmallImpl(
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?,
onTrackingClicked: () -> Unit,
// For tags menu
onTagSearch: (String) -> Unit,
@ -559,7 +559,7 @@ fun AnimeScreenLargeImpl(
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?,
onTrackingClicked: () -> Unit,
// For tags menu
onTagSearch: (String) -> Unit,

View file

@ -172,7 +172,7 @@ fun AnimeActionRow(
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?,
onTrackingClicked: () -> Unit,
onEditIntervalClicked: (() -> Unit)?,
onEditCategory: (() -> Unit)?,
) {
@ -202,22 +202,17 @@ fun AnimeActionRow(
onClick = onEditIntervalClicked,
)
}
if (onTrackingClicked != null) {
AnimeActionButton(
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,
)
}
AnimeActionButton(
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) {
AnimeActionButton(
title = stringResource(MR.strings.action_web_view),

View file

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

View file

@ -171,7 +171,7 @@ fun MangaActionRow(
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?,
onTrackingClicked: () -> Unit,
onEditIntervalClicked: (() -> Unit)?,
onEditCategory: (() -> Unit)?,
modifier: Modifier = Modifier,
@ -202,22 +202,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.entries.anime.track.AnimeTrackInfoDialogHomeScreen
import eu.kanade.tachiyomi.ui.home.HomeScreen
import eu.kanade.tachiyomi.ui.library.anime.AnimeLibraryTab
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.setting.SettingsScreen
import eu.kanade.tachiyomi.ui.player.settings.dialogs.SkipIntroLengthDialog
import eu.kanade.tachiyomi.ui.webview.WebViewScreen
import eu.kanade.tachiyomi.util.system.copyToClipboard
@ -140,7 +141,13 @@ class AnimeScreen(
screenModel.source,
)
}.takeIf { isAnimeHttpSource },
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

@ -48,6 +48,7 @@ import eu.kanade.tachiyomi.ui.entries.manga.track.MangaTrackInfoDialogHomeScreen
import eu.kanade.tachiyomi.ui.home.HomeScreen
import eu.kanade.tachiyomi.ui.library.manga.MangaLibraryTab
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
@ -131,7 +132,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

@ -60,7 +60,7 @@ object MoreTab : Tab() {
}
override suspend fun onReselect(navigator: Navigator) {
navigator.push(SettingsScreen.toMainScreen())
navigator.push(SettingsScreen())
}
@Composable
@ -81,9 +81,9 @@ object MoreTab : Tab() {
onClickCategories = { navigator.push(CategoriesTab()) },
onClickStats = { navigator.push(StatsTab()) },
onClickStorage = { navigator.push(StorageTab()) },
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
}
}