From e56bf82c319f63ff2bdbabf68647a243bcd451d0 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 13 Dec 2023 22:21:55 -0500 Subject: [PATCH] Clean up some text alpha modifiers --- .../library/components/CommonMangaItem.kt | 32 +++++++++---------- .../manga/components/MangaChapterListItem.kt | 3 +- .../manga/components/MangaInfoHeader.kt | 2 +- .../manga/components/MangaToolbar.kt | 8 +++-- .../presentation/track/TrackInfoDialogHome.kt | 3 +- .../presentation/core/util/Modifier.kt | 7 ++-- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/library/components/CommonMangaItem.kt b/app/src/main/java/eu/kanade/presentation/library/components/CommonMangaItem.kt index 5e4cb8d34b..92957384a8 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/CommonMangaItem.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/CommonMangaItem.kt @@ -62,15 +62,15 @@ private const val GridSelectedCoverAlpha = 0.76f */ @Composable fun MangaCompactGridItem( + coverData: tachiyomi.domain.manga.model.MangaCover, + onClick: () -> Unit, + onLongClick: () -> Unit, isSelected: Boolean = false, title: String? = null, - coverData: tachiyomi.domain.manga.model.MangaCover, + onClickContinueReading: (() -> Unit)? = null, coverAlpha: Float = 1f, coverBadgeStart: @Composable (RowScope.() -> Unit)? = null, coverBadgeEnd: @Composable (RowScope.() -> Unit)? = null, - onLongClick: () -> Unit, - onClick: () -> Unit, - onClickContinueReading: (() -> Unit)? = null, ) { GridItemSelectable( isSelected = isSelected, @@ -163,15 +163,15 @@ private fun BoxScope.CoverTextOverlay( */ @Composable fun MangaComfortableGridItem( - isSelected: Boolean = false, - title: String, - titleMaxLines: Int = 2, coverData: tachiyomi.domain.manga.model.MangaCover, + title: String, + onClick: () -> Unit, + onLongClick: () -> Unit, + isSelected: Boolean = false, + titleMaxLines: Int = 2, coverAlpha: Float = 1f, coverBadgeStart: (@Composable RowScope.() -> Unit)? = null, coverBadgeEnd: (@Composable RowScope.() -> Unit)? = null, - onLongClick: () -> Unit, - onClick: () -> Unit, onClickContinueReading: (() -> Unit)? = null, ) { GridItemSelectable( @@ -253,10 +253,10 @@ private fun MangaGridCover( @Composable private fun GridItemTitle( - modifier: Modifier, title: String, style: TextStyle, minLines: Int, + modifier: Modifier = Modifier, maxLines: Int = 2, ) { Text( @@ -276,10 +276,10 @@ private fun GridItemTitle( */ @Composable private fun GridItemSelectable( - modifier: Modifier = Modifier, isSelected: Boolean, onClick: () -> Unit, onLongClick: () -> Unit, + modifier: Modifier = Modifier, content: @Composable () -> Unit, ) { Box( @@ -316,13 +316,13 @@ private fun Modifier.selectedOutline( */ @Composable fun MangaListItem( - isSelected: Boolean = false, - title: String, coverData: tachiyomi.domain.manga.model.MangaCover, - coverAlpha: Float = 1f, - badge: @Composable (RowScope.() -> Unit), - onLongClick: () -> Unit, + title: String, onClick: () -> Unit, + onLongClick: () -> Unit, + badge: @Composable (RowScope.() -> Unit), + isSelected: Boolean = false, + coverAlpha: Float = 1f, onClickContinueReading: (() -> Unit)? = null, ) { Row( 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 991b494869..b14d2ed14f 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 @@ -33,7 +33,6 @@ import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clipToBounds import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector @@ -189,7 +188,7 @@ fun MangaChapterListItem( text = readProgress, maxLines = 1, overflow = TextOverflow.Ellipsis, - modifier = Modifier.alpha(ReadItemAlpha), + color = LocalContentColor.current.copy(alpha = ReadItemAlpha), ) if (scanlator != null) DotSeparatorText() } 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 a643a15b2e..5d33206b2d 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 @@ -124,7 +124,7 @@ fun MangaInfoBox( ) } .blur(4.dp) - .alpha(.2f), + .alpha(0.2f), ) // Manga & source info diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt index e25eb8b259..12c14ce788 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt @@ -35,10 +35,8 @@ import tachiyomi.presentation.core.theme.active @Composable fun MangaToolbar( - modifier: Modifier = Modifier, title: String, titleAlphaProvider: () -> Float, - backgroundAlphaProvider: () -> Float = titleAlphaProvider, hasFilters: Boolean, onBackClicked: () -> Unit, onClickFilter: () -> Unit, @@ -47,10 +45,14 @@ fun MangaToolbar( onClickEditCategory: (() -> Unit)?, onClickRefresh: () -> Unit, onClickMigrate: (() -> Unit)?, + // For action mode actionModeCounter: Int, onSelectAll: () -> Unit, onInvertSelection: () -> Unit, + + modifier: Modifier = Modifier, + backgroundAlphaProvider: () -> Float = titleAlphaProvider, ) { Column( modifier = modifier, @@ -62,7 +64,7 @@ fun MangaToolbar( text = if (isActionMode) actionModeCounter.toString() else title, maxLines = 1, overflow = TextOverflow.Ellipsis, - modifier = Modifier.alpha(if (isActionMode) 1f else titleAlphaProvider()), + color = LocalContentColor.current.copy(alpha = if (isActionMode) 1f else titleAlphaProvider()), ) }, navigationIcon = { diff --git a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt index 78b8fc953a..07693aa3a5 100644 --- a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt @@ -248,7 +248,6 @@ private fun TrackDetailsItem( Box( modifier = modifier .clickable(onClick = onClick) - .alpha(if (text == null) UnsetStatusTextAlpha else 1f) .fillMaxHeight() .padding(12.dp), contentAlignment = Alignment.Center, @@ -259,7 +258,7 @@ private fun TrackDetailsItem( overflow = TextOverflow.Ellipsis, style = MaterialTheme.typography.bodyMedium, textAlign = TextAlign.Center, - color = MaterialTheme.colorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface.copy(alpha = if (text == null) UnsetStatusTextAlpha else 1f), ) } } diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/util/Modifier.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/util/Modifier.kt index 795c6e211c..411fc99833 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/util/Modifier.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/util/Modifier.kt @@ -1,6 +1,5 @@ package tachiyomi.presentation.core.util -import androidx.compose.foundation.background import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.isSystemInDarkTheme @@ -16,6 +15,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.draw.alpha +import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.focus.onFocusChanged @@ -28,7 +28,10 @@ import tachiyomi.presentation.core.components.material.SecondaryItemAlpha fun Modifier.selectedBackground(isSelected: Boolean): Modifier = if (isSelected) { composed { val alpha = if (isSystemInDarkTheme()) 0.16f else 0.22f - Modifier.background(MaterialTheme.colorScheme.secondary.copy(alpha = alpha)) + val color = MaterialTheme.colorScheme.secondary.copy(alpha = alpha) + Modifier.drawBehind { + drawRect(color) + } } } else { this