From 44260af32e315e702f81494baede5b287560e164 Mon Sep 17 00:00:00 2001 From: Carlos <2092019+CarlosEsco@users.noreply.github.com> Date: Wed, 11 Jan 2023 08:52:32 -0500 Subject: [PATCH] Use informationActions object for information clicking --- .../tachiyomi/ui/manga/MangaConstants.kt | 5 ++++ .../ui/manga/MangaDetailController.kt | 23 ++++++++++++------- .../presentation/screens/MangaScreen.kt | 7 +++--- .../mangadetails/MangaDetailsHeader.kt | 8 +++---- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaConstants.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaConstants.kt index e01425e4ea..3ee2620b7b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaConstants.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaConstants.kt @@ -194,6 +194,11 @@ object MangaConstants { val altTitleResetClick: () -> Unit, ) + class InformationActions( + val titleLongClick: (String) -> Unit, + val creatorLongClick: (String) -> Unit, + ) + class TrackActions( val statusChange: (Int, TrackingConstants.TrackAndService) -> Unit, val scoreChange: (Int, TrackingConstants.TrackAndService) -> Unit, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailController.kt index 576ced58dc..b23950025f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailController.kt @@ -12,6 +12,7 @@ import androidx.annotation.StringRes import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState +import androidx.compose.ui.platform.LocalContext import androidx.core.content.getSystemService import androidx.palette.graphics.Palette import eu.kanade.tachiyomi.R @@ -27,6 +28,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaConstants.ChapterActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.ChapterFilterActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.CoverActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.DescriptionActions +import eu.kanade.tachiyomi.ui.manga.MangaConstants.InformationActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.MergeActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.TrackActions import eu.kanade.tachiyomi.ui.reader.ReaderActivity @@ -67,6 +69,7 @@ class MangaDetailController(private val mangaId: Long) : BaseComposeController presenter.updateMangaCategories(enabledCategories) }, addNew = { newCategory -> presenter.addNewCategory(newCategory) }, ), + informationActions = InformationActions( + titleLongClick = { + presenter.copiedToClipboard(it) + copyToClipboard(context, it, R.string.title) + }, + creatorLongClick = { + presenter.copiedToClipboard(it) + copyToClipboard(context, it, R.string.creator) + }, + + ), descriptionActions = DescriptionActions( genreClick = this::tagClicked, genreLongClick = this::tagLongClicked, @@ -86,14 +100,7 @@ class MangaDetailController(private val mangaId: Long) : BaseComposeController - presenter.copiedToClipboard(context.getString(R.string.title)) - copyToClipboard(context, content, R.string.title) - }, - creatorLongClick = { context, content -> - presenter.copiedToClipboard(context.getString(R.string.creator)) - copyToClipboard(context, content, R.string.creator) - }, + toggleFavorite = presenter::toggleFavorite, dateFormat = preferences.dateFormat(), trackActions = TrackActions( diff --git a/app/src/main/java/org/nekomanga/presentation/screens/MangaScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/MangaScreen.kt index 0d56587d47..ad667ebe47 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/MangaScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/MangaScreen.kt @@ -57,6 +57,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaConstants.ChapterActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.ChapterFilterActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.CoverActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.DescriptionActions +import eu.kanade.tachiyomi.ui.manga.MangaConstants.InformationActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.MangaScreenGeneralState import eu.kanade.tachiyomi.ui.manga.MangaConstants.MergeActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.TrackActions @@ -95,8 +96,6 @@ fun MangaScreen( isRefreshing: State, onRefresh: () -> Unit, generatePalette: (Drawable) -> Unit = {}, - titleLongClick: (Context, String) -> Unit, - creatorLongClick: (Context, String) -> Unit, toggleFavorite: (Boolean) -> Unit, categoryActions: CategoryActions, dateFormat: DateFormat, @@ -105,6 +104,7 @@ fun MangaScreen( coverActions: CoverActions, mergeActions: MergeActions, shareClick: (Context) -> Unit, + informationActions: InformationActions, descriptionActions: DescriptionActions, chapterFilterActions: ChapterFilterActions, chapterActions: ChapterActions, @@ -244,8 +244,7 @@ fun MangaScreen( mangaState = mangaState, generalState = generalState, windowSizeClass = windowSizeClass, - titleLongClick = { title: String -> titleLongClick(context, title) }, - creatorLongClick = { creator: String -> creatorLongClick(context, creator) }, + informationActions = informationActions, themeColorState = themeColorState, generatePalette = generatePalette, isLoggedIntoTrackersProvider = { trackMergeState.value.loggedInTrackService.isNotEmpty() }, diff --git a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/MangaDetailsHeader.kt b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/MangaDetailsHeader.kt index 8473f7e0cc..5875dd83da 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/MangaDetailsHeader.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/MangaDetailsHeader.kt @@ -37,6 +37,7 @@ import androidx.compose.ui.unit.dp import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.manga.MangaConstants import eu.kanade.tachiyomi.ui.manga.MangaConstants.DescriptionActions +import eu.kanade.tachiyomi.ui.manga.MangaConstants.InformationActions import eu.kanade.tachiyomi.ui.manga.MangaConstants.NextUnreadChapter import eu.kanade.tachiyomi.ui.manga.MergeConstants import jp.wasabeef.gap.Gap @@ -55,8 +56,6 @@ fun MangaDetailsHeader( isLoggedIntoTrackersProvider: () -> Boolean, themeColorState: ThemeColorState, generatePalette: (Drawable) -> Unit = {}, - titleLongClick: (String) -> Unit = {}, - creatorLongClick: (String) -> Unit = {}, toggleFavorite: () -> Unit = {}, moveCategories: () -> Unit = {}, trackingClick: () -> Unit = {}, @@ -66,6 +65,7 @@ fun MangaDetailsHeader( linksClick: () -> Unit = {}, shareClick: () -> Unit = {}, descriptionActions: DescriptionActions, + informationActions: InformationActions, quickReadClick: () -> Unit = {}, ) { CompositionLocalProvider(LocalRippleTheme provides themeColorState.rippleTheme, LocalTextSelectionColors provides themeColorState.textSelectionColors) { @@ -122,8 +122,8 @@ fun MangaDetailsHeader( .padding(top = 70.dp), isExpandedProvider = { isExpanded.value }, showMergedIconProvider = { mangaState.value.isMerged is MergeConstants.IsMergedManga.Yes && !generalState.value.hideButtonText }, - titleLongClick = titleLongClick, - creatorLongClicked = creatorLongClick, + titleLongClick = informationActions.titleLongClick, + creatorLongClicked = informationActions.creatorLongClick, ) Gap(height = 16.dp) ButtonBlock(