From 91dba13104abb687d9e4d5a558fbb0e49023de45 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 13 Dec 2023 22:21:55 -0500 Subject: [PATCH] refactor: Clean up some text alpha modifiers --- .../anime/components/AnimeEpisodeListItem.kt | 2 +- .../anime/components/AnimeInfoHeader.kt | 2 +- .../entries/components/EntryToolbar.kt | 2 +- .../manga/components/MangaChapterListItem.kt | 3 +-- .../manga/components/MangaInfoHeader.kt | 2 +- .../library/components/CommonEntryItem.kt | 18 +++++++++--------- .../track/manga/MangaTrackInfoDialogHome.kt | 3 +-- .../presentation/core/util/Modifier.kt | 7 +++++-- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeEpisodeListItem.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeEpisodeListItem.kt index 10840cc1a..101445bb7 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeEpisodeListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeEpisodeListItem.kt @@ -195,7 +195,7 @@ fun AnimeEpisodeListItem( text = watchProgress, 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/entries/anime/components/AnimeInfoHeader.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt index 53c7f9a99..4736f15f6 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt @@ -126,7 +126,7 @@ fun AnimeInfoBox( ) } .blur(4.dp) - .alpha(.2f), + .alpha(0.2f), ) // Anime & source info diff --git a/app/src/main/java/eu/kanade/presentation/entries/components/EntryToolbar.kt b/app/src/main/java/eu/kanade/presentation/entries/components/EntryToolbar.kt index 2626529d3..16e290f0e 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/components/EntryToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/components/EntryToolbar.kt @@ -66,7 +66,7 @@ fun EntryToolbar( 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/entries/manga/components/MangaChapterListItem.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaChapterListItem.kt index 261778789..6d672767d 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaChapterListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/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 @@ -194,7 +193,7 @@ fun MangaChapterListItem( text = readProgress, maxLines = 1, overflow = TextOverflow.Ellipsis, - modifier = Modifier.alpha(ReadItemAlpha), + color = LocalContentColor.current.copy(alpha = ReadItemAlpha), ) } if (scanlator != null) { diff --git a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt index 0c1a4b927..d1ef695cc 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt @@ -126,7 +126,7 @@ fun MangaInfoBox( ) } .blur(4.dp) - .alpha(.2f), + .alpha(0.2f), ) // Manga & source info diff --git a/app/src/main/java/eu/kanade/presentation/library/components/CommonEntryItem.kt b/app/src/main/java/eu/kanade/presentation/library/components/CommonEntryItem.kt index ab57df6d0..9738a8bb4 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/CommonEntryItem.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/CommonEntryItem.kt @@ -63,15 +63,15 @@ private const val GridSelectedCoverAlpha = 0.76f */ @Composable fun EntryCompactGridItem( + coverData: EntryCover, + onClick: () -> Unit, + onLongClick: () -> Unit, isSelected: Boolean = false, title: String? = null, - coverData: EntryCover, + onClickContinueViewing: (() -> Unit)? = null, coverAlpha: Float = 1f, coverBadgeStart: @Composable (RowScope.() -> Unit)? = null, coverBadgeEnd: @Composable (RowScope.() -> Unit)? = null, - onLongClick: () -> Unit, - onClick: () -> Unit, - onClickContinueViewing: (() -> Unit)? = null, ) { GridItemSelectable( isSelected = isSelected, @@ -166,13 +166,13 @@ private fun BoxScope.CoverTextOverlay( fun EntryComfortableGridItem( isSelected: Boolean = false, title: String, + onClick: () -> Unit, + onLongClick: () -> Unit, titleMaxLines: Int = 2, coverData: EntryCover, coverAlpha: Float = 1f, coverBadgeStart: (@Composable RowScope.() -> Unit)? = null, coverBadgeEnd: (@Composable RowScope.() -> Unit)? = null, - onLongClick: () -> Unit, - onClick: () -> Unit, onClickContinueViewing: (() -> Unit)? = null, ) { GridItemSelectable( @@ -254,10 +254,10 @@ private fun EntryGridCover( @Composable private fun GridItemTitle( - modifier: Modifier, title: String, style: TextStyle, minLines: Int, + modifier: Modifier = Modifier, maxLines: Int = 2, ) { Text( @@ -277,10 +277,10 @@ private fun GridItemTitle( */ @Composable private fun GridItemSelectable( - modifier: Modifier = Modifier, isSelected: Boolean, onClick: () -> Unit, onLongClick: () -> Unit, + modifier: Modifier = Modifier, content: @Composable () -> Unit, ) { Box( @@ -321,9 +321,9 @@ fun EntryListItem( title: String, coverData: EntryCover, coverAlpha: Float = 1f, - badge: @Composable (RowScope.() -> Unit), onLongClick: () -> Unit, onClick: () -> Unit, + badge: @Composable (RowScope.() -> Unit), onClickContinueViewing: (() -> Unit)? = null, ) { Row( diff --git a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt index 069b15719..d4873de7c 100644 --- a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt @@ -251,7 +251,6 @@ fun TrackDetailsItem( Box( modifier = modifier .clickable(onClick = onClick) - .alpha(if (text == null) UnsetStatusTextAlpha else 1f) .fillMaxHeight() .padding(12.dp), contentAlignment = Alignment.Center, @@ -262,7 +261,7 @@ 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 795c6e211..411fc9983 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