From 3d8f6dd310e56e1237696db5b9c8fce233a1f5fa Mon Sep 17 00:00:00 2001 From: perokhe Date: Sun, 21 Jul 2024 12:42:10 -0600 Subject: [PATCH] Hide smart update icon when disabled --- .../kanade/presentation/manga/MangaScreen.kt | 7 ++++ .../manga/components/MangaInfoHeader.kt | 32 +++++++++++-------- .../kanade/tachiyomi/ui/manga/MangaScreen.kt | 1 + 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index 91546f57f..ee75baf94 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -84,6 +84,7 @@ fun MangaScreen( state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, nextUpdate: Instant?, + isUpdateIntervalEnabled: Boolean, isTabletUi: Boolean, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, @@ -139,6 +140,7 @@ fun MangaScreen( state = state, snackbarHostState = snackbarHostState, nextUpdate = nextUpdate, + isUpdateIntervalEnabled = isUpdateIntervalEnabled, chapterSwipeStartAction = chapterSwipeStartAction, chapterSwipeEndAction = chapterSwipeEndAction, onBackClicked = onBackClicked, @@ -176,6 +178,7 @@ fun MangaScreen( chapterSwipeStartAction = chapterSwipeStartAction, chapterSwipeEndAction = chapterSwipeEndAction, nextUpdate = nextUpdate, + isUpdateIntervalEnabled = isUpdateIntervalEnabled, onBackClicked = onBackClicked, onChapterClicked = onChapterClicked, onDownloadChapter = onDownloadChapter, @@ -212,6 +215,7 @@ private fun MangaScreenSmallImpl( state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, nextUpdate: Instant?, + isUpdateIntervalEnabled: Boolean, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onBackClicked: () -> Unit, @@ -400,6 +404,7 @@ private fun MangaScreenSmallImpl( favorite = state.manga.favorite, trackingCount = state.trackingCount, nextUpdate = nextUpdate, + isUpdateIntervalEnabled = isUpdateIntervalEnabled, isUserIntervalMode = state.manga.fetchInterval < 0, onAddToLibraryClicked = onAddToLibraryClicked, onWebViewClicked = onWebViewClicked, @@ -460,6 +465,7 @@ fun MangaScreenLargeImpl( state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, nextUpdate: Instant?, + isUpdateIntervalEnabled: Boolean, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onBackClicked: () -> Unit, @@ -636,6 +642,7 @@ fun MangaScreenLargeImpl( favorite = state.manga.favorite, trackingCount = state.trackingCount, nextUpdate = nextUpdate, + isUpdateIntervalEnabled = isUpdateIntervalEnabled, isUserIntervalMode = state.manga.fetchInterval < 0, onAddToLibraryClicked = onAddToLibraryClicked, onWebViewClicked = onWebViewClicked, diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaInfoHeader.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaInfoHeader.kt index f1b660626..efa6c95de 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaInfoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaInfoHeader.kt @@ -162,11 +162,13 @@ fun MangaInfoBox( } } +@Suppress("CyclomaticComplexMethod") @Composable fun MangaActionRow( favorite: Boolean, trackingCount: Int, nextUpdate: Instant?, + isUpdateIntervalEnabled: Boolean, isUserIntervalMode: Boolean, onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, @@ -200,20 +202,22 @@ fun MangaActionRow( onClick = onAddToLibraryClicked, onLongClick = onEditCategory, ) - MangaActionButton( - title = when (nextUpdateDays) { - null -> stringResource(MR.strings.not_applicable) - 0 -> stringResource(MR.strings.manga_interval_expected_update_soon) - else -> pluralStringResource( - MR.plurals.day, - count = nextUpdateDays, - nextUpdateDays, - ) - }, - icon = Icons.Default.HourglassEmpty, - color = if (isUserIntervalMode) MaterialTheme.colorScheme.primary else defaultActionButtonColor, - onClick = { onEditIntervalClicked?.invoke() }, - ) + if (nextUpdateDays != null || isUpdateIntervalEnabled) { + MangaActionButton( + title = when (nextUpdateDays) { + null -> stringResource(MR.strings.not_applicable) + 0 -> stringResource(MR.strings.manga_interval_expected_update_soon) + else -> pluralStringResource( + MR.plurals.day, + count = nextUpdateDays, + nextUpdateDays, + ) + }, + icon = Icons.Default.HourglassEmpty, + color = if (isUserIntervalMode) MaterialTheme.colorScheme.primary else defaultActionButtonColor, + onClick = { onEditIntervalClicked?.invoke() }, + ) + } MangaActionButton( title = if (trackingCount == 0) { stringResource(MR.strings.manga_tracking_tab) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt index e500a04d3..7cc3ae718 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt @@ -113,6 +113,7 @@ class MangaScreen( state = successState, snackbarHostState = screenModel.snackbarHostState, nextUpdate = successState.manga.expectedNextUpdate, + isUpdateIntervalEnabled = screenModel.isUpdateIntervalEnabled, isTabletUi = isTabletUi(), chapterSwipeStartAction = screenModel.chapterSwipeStartAction, chapterSwipeEndAction = screenModel.chapterSwipeEndAction,