From 8cc42bce5a37c256edbddd4a618787dfec9c2118 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 8 Jul 2023 15:54:30 -0400 Subject: [PATCH] Tweak chapter swipe directions and icon color --- .../kanade/presentation/manga/MangaScreen.kt | 18 +++++++++--------- .../manga/components/MangaChapterListItem.kt | 13 +++++++------ .../settings/screen/SettingsLibraryScreen.kt | 4 ++-- .../kanade/tachiyomi/ui/manga/MangaScreen.kt | 2 +- .../tachiyomi/ui/manga/MangaScreenModel.kt | 4 ++-- .../library/service/LibraryPreferences.kt | 4 ++-- 6 files changed, 23 insertions(+), 22 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 c0c2b3f6a..7fb49250a 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -87,8 +87,8 @@ fun MangaScreen( dateRelativeTime: Int, dateFormat: DateFormat, isTabletUi: Boolean, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onBackClicked: () -> Unit, onChapterClicked: (Chapter) -> Unit, onDownloadChapter: ((List, ChapterDownloadAction) -> Unit)?, @@ -141,8 +141,8 @@ fun MangaScreen( snackbarHostState = snackbarHostState, dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, onBackClicked = onBackClicked, onChapterClicked = onChapterClicked, onDownloadChapter = onDownloadChapter, @@ -175,8 +175,8 @@ fun MangaScreen( state = state, snackbarHostState = snackbarHostState, dateRelativeTime = dateRelativeTime, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, dateFormat = dateFormat, onBackClicked = onBackClicked, onChapterClicked = onChapterClicked, @@ -214,8 +214,8 @@ private fun MangaScreenSmallImpl( snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onBackClicked: () -> Unit, onChapterClicked: (Chapter) -> Unit, onDownloadChapter: ((List, ChapterDownloadAction) -> Unit)?, @@ -421,8 +421,8 @@ private fun MangaScreenSmallImpl( chapters = chapters, dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, onChapterClicked = onChapterClicked, onDownloadChapter = onDownloadChapter, onChapterSelected = onChapterSelected, @@ -440,8 +440,8 @@ fun MangaScreenLargeImpl( snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onBackClicked: () -> Unit, onChapterClicked: (Chapter) -> Unit, onDownloadChapter: ((List, ChapterDownloadAction) -> Unit)?, @@ -641,8 +641,8 @@ fun MangaScreenLargeImpl( chapters = chapters, dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, onChapterClicked = onChapterClicked, onDownloadChapter = onDownloadChapter, onChapterSelected = onChapterSelected, @@ -703,8 +703,8 @@ private fun LazyListScope.sharedChapterItems( chapters: List, dateRelativeTime: Int, dateFormat: DateFormat, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onChapterClicked: (Chapter) -> Unit, onDownloadChapter: ((List, ChapterDownloadAction) -> Unit)?, onChapterSelected: (ChapterItem, Boolean, Boolean, Boolean) -> Unit, @@ -751,8 +751,8 @@ private fun LazyListScope.sharedChapterItems( downloadIndicatorEnabled = chapters.fastAll { !it.selected }, downloadStateProvider = { chapterItem.downloadState }, downloadProgressProvider = { chapterItem.downloadProgress }, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, onLongClick = { onChapterSelected(chapterItem, !chapterItem.selected, true, true) haptic.performHapticFeedback(HapticFeedbackType.LongPress) diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt index 63fdfecca..1fb0abb52 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt @@ -22,6 +22,7 @@ import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ProvideTextStyle import androidx.compose.material3.Text +import androidx.compose.material3.contentColorFor import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect @@ -68,8 +69,8 @@ fun MangaChapterListItem( downloadIndicatorEnabled: Boolean, downloadStateProvider: () -> Download.State, downloadProgressProvider: () -> Int, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onLongClick: () -> Unit, onClick: () -> Unit, onDownloadClick: ((ChapterDownloadAction) -> Unit)?, @@ -226,19 +227,19 @@ private fun getSwipeAction( onSwipe: () -> Unit, ): me.saket.swipe.SwipeAction? { return when (action) { - LibraryPreferences.ChapterSwipeAction.ToggleRead -> SwipeAction( + LibraryPreferences.ChapterSwipeAction.ToggleRead -> swipeAction( icon = if (!read) Icons.Outlined.Done else Icons.Outlined.RemoveDone, background = background, isUndo = read, onSwipe = onSwipe, ) - LibraryPreferences.ChapterSwipeAction.ToggleBookmark -> SwipeAction( + LibraryPreferences.ChapterSwipeAction.ToggleBookmark -> swipeAction( icon = if (!bookmark) Icons.Outlined.BookmarkAdd else Icons.Outlined.BookmarkRemove, background = background, isUndo = bookmark, onSwipe = onSwipe, ) - LibraryPreferences.ChapterSwipeAction.Download -> SwipeAction( + LibraryPreferences.ChapterSwipeAction.Download -> swipeAction( icon = when (downloadState) { Download.State.NOT_DOWNLOADED, Download.State.ERROR -> Icons.Outlined.Download Download.State.QUEUE, Download.State.DOWNLOADING -> Icons.Outlined.FileDownloadOff @@ -251,7 +252,7 @@ private fun getSwipeAction( } } -private fun SwipeAction( +private fun swipeAction( onSwipe: () -> Unit, icon: ImageVector, background: Color, @@ -262,7 +263,7 @@ private fun SwipeAction( Icon( modifier = Modifier.padding(16.dp), imageVector = icon, - tint = MaterialTheme.colorScheme.onSurface, + tint = contentColorFor(background), contentDescription = null, ) }, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt index 625157427..b6bd25489 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt @@ -281,7 +281,7 @@ object SettingsLibraryScreen : SearchableSettings { title = stringResource(R.string.pref_chapter_swipe), preferenceItems = listOf( Preference.PreferenceItem.ListPreference( - pref = libraryPreferences.swipeEndAction(), + pref = libraryPreferences.swipeToStartAction(), title = stringResource(R.string.pref_chapter_swipe_end), entries = mapOf( LibraryPreferences.ChapterSwipeAction.Disabled to stringResource(R.string.disabled), @@ -291,7 +291,7 @@ object SettingsLibraryScreen : SearchableSettings { ), ), Preference.PreferenceItem.ListPreference( - pref = libraryPreferences.swipeStartAction(), + pref = libraryPreferences.swipeToEndAction(), title = stringResource(R.string.pref_chapter_swipe_start), entries = mapOf( LibraryPreferences.ChapterSwipeAction.Disabled to stringResource(R.string.disabled), 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 dce1c8f46..33244db67 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 @@ -101,8 +101,8 @@ class MangaScreen( dateRelativeTime = screenModel.relativeTime, dateFormat = screenModel.dateFormat, isTabletUi = isTabletUi(), - chapterSwipeEndAction = screenModel.chapterSwipeEndAction, chapterSwipeStartAction = screenModel.chapterSwipeStartAction, + chapterSwipeEndAction = screenModel.chapterSwipeEndAction, onBackClicked = navigator::pop, onChapterClicked = { openChapter(context, it) }, onDownloadChapter = screenModel::runChapterDownloadActions.takeIf { !successState.source.isLocalOrStub() }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt index 98e4338d3..5f78f9726 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt @@ -122,8 +122,8 @@ class MangaInfoScreenModel( private val filteredChapters: List? get() = successState?.processedChapters - val chapterSwipeEndAction = libraryPreferences.swipeEndAction().get() - val chapterSwipeStartAction = libraryPreferences.swipeStartAction().get() + val chapterSwipeStartAction = libraryPreferences.swipeToEndAction().get() + val chapterSwipeEndAction = libraryPreferences.swipeToStartAction().get() val relativeTime by uiPreferences.relativeTime().asState(coroutineScope) val dateFormat by mutableStateOf(UiPreferences.dateFormat(uiPreferences.dateFormat().get())) diff --git a/domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt b/domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt index de66117ad..7aa496c54 100644 --- a/domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt +++ b/domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt @@ -134,9 +134,9 @@ class LibraryPreferences( // region Swipe Actions - fun swipeEndAction() = preferenceStore.getEnum("pref_chapter_swipe_end_action", ChapterSwipeAction.ToggleBookmark) + fun swipeToStartAction() = preferenceStore.getEnum("pref_chapter_swipe_end_action", ChapterSwipeAction.ToggleBookmark) - fun swipeStartAction() = preferenceStore.getEnum("pref_chapter_swipe_start_action", ChapterSwipeAction.ToggleRead) + fun swipeToEndAction() = preferenceStore.getEnum("pref_chapter_swipe_start_action", ChapterSwipeAction.ToggleRead) // endregion