Skip to content

Commit

Permalink
Use informationActions object for information clicking
Browse files Browse the repository at this point in the history
  • Loading branch information
nonproto committed Jan 11, 2023
1 parent 83f31a4 commit 44260af
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -67,6 +69,7 @@ class MangaDetailController(private val mangaId: Long) : BaseComposeController<M
@Composable
override fun ScreenContent() {
val windowSizeClass = calculateWindowSizeClass(this.activity!!)
val context = LocalContext.current
MangaScreen(
generalState = presenter.generalState.collectAsState(),
mangaState = presenter.mangaState.collectAsState(),
Expand All @@ -79,21 +82,25 @@ class MangaDetailController(private val mangaId: Long) : BaseComposeController<M
set = { enabledCategories -> 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,
altTitleClick = presenter::setAltTitle,
altTitleResetClick = { presenter.setAltTitle(null) },
),
generatePalette = this::setPalette,
titleLongClick = { context, content ->
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,8 +96,6 @@ fun MangaScreen(
isRefreshing: State<Boolean>,
onRefresh: () -> Unit,
generatePalette: (Drawable) -> Unit = {},
titleLongClick: (Context, String) -> Unit,
creatorLongClick: (Context, String) -> Unit,
toggleFavorite: (Boolean) -> Unit,
categoryActions: CategoryActions,
dateFormat: DateFormat,
Expand All @@ -105,6 +104,7 @@ fun MangaScreen(
coverActions: CoverActions,
mergeActions: MergeActions,
shareClick: (Context) -> Unit,
informationActions: InformationActions,
descriptionActions: DescriptionActions,
chapterFilterActions: ChapterFilterActions,
chapterActions: ChapterActions,
Expand Down Expand Up @@ -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() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = {},
Expand All @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 44260af

Please sign in to comment.